Repository navigation
Generic: Reject unsupported prefix modifiers across CREATE statements - #3063
Open
lei-jia-xing wants to merge 1 commit into
Open
lei-jia-xing wants to merge 1 commit into
lei-jia-xing wants to merge 1 commit into
Conversation
lei-jia-xing
force-pushed
the
parse-create-modifiers
branch
from
November 29, 2026 03:19
cd4dadc to
291585e
Compare
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.
Closes #3054. Follow-up to #3040.
Previously,
Parser::parse_createparsed prefix modifiers upfront and only checkedhas_modifierin three arms (USER MAPPING,FOREIGN TABLE,FOREIGN DATA WRAPPER), so other targets silently dropped unsupported modifiers (e.g.CREATE TEMP POLICY p ON t USING (true);round-tripped asCREATE POLICY p ON t USING (true), which PostgreSQL rejects per https://www.postgresql.org/docs/17/sql-createpolicy.html).This PR replaces
has_modifierwithCreateModifiers::ensure_empty(target):CREATEbranch consumes only the modifiers its AST preserves and rejects any remaining modifier with"<TARGET> does not accept this modifier"at that modifier's location.Dialect::supports_create_or_alter_function(enabled onMsSqlDialect) ensures non-MSSQLFUNCTIONbranches rejectOR ALTERinstead of dropping it.LOCAL/GLOBALare parsed once viaparse_one_of_keywordssoCREATE LOCAL GLOBAL TABLEfails instead of droppingLOCAL.Note for reviewers on error message unification:
UNLOGGEDuniformly alongside other modifiers replaces the pre-has_modifierpeek_keywords(&[UNLOGGED, TABLE])workaround from PostgreSQLUNLOGGEDTable Support andALTER TABLE ... SET LOGGED|UNLOGGED#2251, soCREATE UNLOGGED VIEWnow reports"CREATE VIEW does not accept this modifier"instead of"Expected: an object type after CREATE, found: UNLOGGED".else if or_replacearm unifiesOR REPLACErejections on targets likeFOREIGN TABLEto"CREATE FOREIGN TABLE does not accept this modifier"(matchingUSER MAPPING), and unknown targets afterOR REPLACEto"Expected: an object type after CREATE".AI assistance was used to implement the refactor and tests.