sql: pluralize the object type in abbreviated grants - #38438
Merged
sjwiesman merged 1 commit intoAug 24, 2026
Conversation
`AbbreviatedGrantStatement` and `AbbreviatedRevokeStatement` pluralized an object type by appending `S`, so a rule naming a network policy rendered as `ON NETWORK POLICYS`, which the grammar spells `ON POLICIES` and will not parse. Route both through `write_grant_object_type_plural`, the helper the surrounding grant statements already use.
SangJunBak
approved these changes
Aug 24, 2026
SangJunBak
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Thanks for the fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The grammar spells the plural of a network policy as the single keyword
POLICIES, and the parser maps it straight toObjectType::NetworkPolicy.Rendering went the other way through the singular display,
NETWORK POLICY,with a bare
Sappended:So a statement parsed from
ON POLICIESredisplays asON NETWORK POLICYS,which is wrong twice over. The plural grammar does not use the word
NETWORKatall, and
POLICYdoes not pluralize toPOLICYS. The result does not reparse,which breaks the display/parse round trip the parser is supposed to hold.
Every other object type escapes this because its singular display is already the
plural stem and English only needs the
S:TABLEtoTABLES,SCHEMAtoSCHEMAS,CLUSTERtoCLUSTERS.NETWORK POLICYis the one irregular spellingin the set.
This same defect was already found and fixed once, for the
GRANT ... ON ALL POLICIES IN SCHEMA ...form. That fix iswrite_grant_object_type_plural, andtest_grant_revoke_all_policies_roundtripsis its regression test, filed off a
parse_display_roundtripfuzz crash onGRANT CREATE ON ALL POLICIES TO j. The helper landed with three callers, allinside
GrantTargetSpecification. The two abbreviated statement formatters werenever routed through it, and the
acltestdata has noPOLICIEScase, so thesecond instance survived.
What this does
Points
AbbreviatedGrantStatementandAbbreviatedRevokeStatementat the helperthat already handles this, two lines each. No new logic.
Where the bad text is observable
Statement logging records two SQL columns, and they are computed differently.
sqlkeeps the raw text as the user typed it unlessStatementKind::is_sensitivecovers the statement, so for anALTER DEFAULT PRIVILEGESit is untouched.redacted_sqlis rendered from theAST unconditionally:
So every such statement is stored with the mis-pluralized text, reachable as:
and through everything built on it:
mz_sql_text_redacted,mz_recent_sql_text,mz_recent_activity_log, andmz_recent_activity_log_redacted.This matters most for
mz_monitor_redactedconsumers, since the redacted columnis the only SQL text they can read, and for these statements it hands them
something that will not reparse. Anyone replaying or diffing redacted history
gets a syntax error rather than the statement that ran.
The planner is unaffected.
sql::plan::statement::aclreads the AST and neverreformats it, so execution has always been correct. Only the rendered text is
wrong.
Tests
Added
test_alter_default_privileges_policies_roundtripsinsrc/sql-parser/tests/sqlparser_common.rs, mirroring the sibling test for theON ALL POLICIESform. It asserts both the grant and the revoke direction renderON POLICIES, neverPOLICYS, and round-trip throughassert_display_roundtrips. Reverting the change makes it fail withON NETWORK POLICYS.Release notes
This release will fix the SQL text recorded for
ALTER DEFAULT PRIVILEGES ... ON POLICIESstatements in statement logging, which was stored in theredacted_sqlcolumn as the unparseable
ON NETWORK POLICYS.🤖 Generated with Claude Code