Skip to content

PostgreSQL: Parse a grantee after PUBLIC in GRANT and REVOKE - #2741

Merged
alamb merged 1 commit into
mainfrom
upstream/public-grantee-list
Oct 28, 2026
Merged

alamb merged 1 commit into
mainfrom
upstream/public-grantee-list

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

GRANT SELECT ON t TO PUBLIC, reader and REVOKE EXECUTE ON FUNCTION f() FROM PUBLIC, anon failed to parse with Expected: end of statement, found: reader, while the same lists with PUBLIC last parsed. PostgreSQL's grantee list is a comma-separated list of role specifications, any of which may be PUBLIC (https://www.postgresql.org/docs/current/sql-grant.html), and PostgreSQL 18 accepts both statements.

parse_grantees gives an entry that names no grantee type the type of the entry before it, so that TO GROUP a, b reads both as groups. PUBLIC is parsed as one of those types, so the entry after it was read as PUBLIC again and its name was left unconsumed. PUBLIC names a single grantee, so it no longer carries over and the next entry gets no type. MsSql reads PUBLIC as an ordinary name and is unaffected.

This PR applies to all dialects except MsSql

@LucaCappelletti94 LucaCappelletti94 added the enhancement New feature or request label Oct 27, 2026
@codecov-commenter

codecov-commenter commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.44%. Comparing base (a75e736) to head (46ba0ca).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2741   +/-   ##
=======================================
  Coverage   82.44%   82.44%           
=======================================
  Files          42       42           
  Lines       35424    35426    +2     
  Branches    35424    35426    +2     
=======================================
+ Hits        29205    29208    +3     
  Misses       2682     2682           
+ Partials     3537     3536    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/public-grantee-list branch from b410346 to b11a944 Compare October 28, 2026 11:29
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/public-grantee-list branch from b11a944 to 46ba0ca Compare October 28, 2026 21:36
@alamb
alamb added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 7b0ef18 Oct 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants