Repository navigation
fix: return UnsupportedStatement for CREATE forms that no rule models - #2864
Merged
manticore-projects merged 1 commit intoOct 28, 2026
Conversation
CREATE falls back to UnsupportedStatement only when no earlier alternative claims the statement. CREATE TABLE and CREATE INDEX accept any leading words as modifiers, so PostgreSQL statements such as CREATE LANGUAGE, CREATE OPERATOR CLASS, CREATE DEFAULT CONVERSION or CREATE TRANSFORM entered one of them and failed before the fallback, and parseStatements failed for the whole script. Take the fallback first when the statement contains none of TABLE, INDEX, VIEW and POLICY, which every remaining alternative needs, so statements that parse today keep their result. The fallback also keeps OR REPLACE, which Create() reads before choosing an alternative. Signed-off-by: minleejae <mmj9808@gmail.com>
Contributor
|
Good one!!! Especially those DDLs come in all kind a variations vendor lock-ins, so having strong fallback is most welcome here. |
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.
CREATEfalls back toUnsupportedStatementfor forms it does not model, but only when no earlier alternative claims the statement.CREATE TABLEandCREATE INDEXaccept any leading words as modifiers, so PostgreSQL statements such asCREATE LANGUAGE plperl,CREATE OPERATOR CLASS …,CREATE DEFAULT CONVERSION …orCREATE TRANSFORM …entered one of them and failed before reaching the fallback. WithparseStatements, one such statement made the whole script fail. Forms whose object keyword is a reserved token, such asCREATE AGGREGATEorCREATE CAST, already fell back.Create()now takes the fallback first when the statement contains none ofTABLE,INDEX,VIEWandPOLICY, which every remaining alternative needs. Statements that parse today keep their result. The fallback also keepsOR REPLACE, whichCreate()reads before choosing an alternative;CREATE OR REPLACE AGGREGATE …used to render without it.Statements that failed this way now return
UnsupportedStatementinstead of throwing, as other unmodelledCREATEforms do. One existing test changes for this reason:CREATE DEFINER = x EVENT …, whoseDEFINERthe EVENT rule does not read yet, now falls back instead of failing. Public method signatures are retained.Syntax reference: PostgreSQL 18 SQL commands.
Validation:
UnsupportedStatementTestadds 7 PostgreSQLCREATEforms, parsed with and without the PostgreSQL dialect, and a script in whichCREATE LANGUAGEsits betweenCREATE TABLEandCREATE INDEX. All 8 fail on master5d07ba424.check: 12,225 tests, 0 failures, 25 skipped; grammar ambiguity, formatting (Spotless ratchet againstupstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass. JaCoCo instrumentation headroom ofCCJSqlParser: 967 entries on master, 932 with this change.AI assistance: prepared with Claude Code.