Repository navigation
fix: parse PostgreSQL DROP for object types of several words - #2884
Merged
manticore-projects merged 1 commit intoOct 31, 2026
Conversation
DROP ACCESS METHOD and DROP PROCEDURAL LANGUAGE parsed with ACCESS or PROCEDURAL as the object type and METHOD or LANGUAGE as the name, and failed with IF EXISTS. DROP OPERATOR CLASS and FAMILY ... USING and the four DROP TEXT SEARCH statements failed. pg_dump --clean writes all of them, so such a dump could not be parsed as a script. Drop.ObjectType gains ACCESS_METHOD, LANGUAGE, OPERATOR_CLASS, OPERATOR_FAMILY and TEXT_SEARCH_CONFIGURATION, _DICTIONARY, _PARSER and _TEMPLATE, read with the words COMMENT ON uses for them. The index access method of an operator class or family is kept in getAccessMethod(), and isProcedural() keeps the PROCEDURAL spelling. Signed-off-by: minleejae <[email protected]>
Contributor
|
Thank you! |
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.
DROP ACCESS METHOD heptreeandDROP PROCEDURAL LANGUAGE plsampleparsed, but withACCESSorPROCEDURALas the object type andMETHODorLANGUAGEas the name, and failed withIF EXISTS.DROP OPERATOR CLASS … USING btree,DROP OPERATOR FAMILY … USING btreeandDROP TEXT SEARCH CONFIGURATION | DICTIONARY | PARSER | TEMPLATEfailed.pg_dump --clean --if-existswrites all of them, so a dump with these objects failed as a script at its firstDROP TEXT SEARCH.Drop.ObjectTypegainsACCESS_METHOD,LANGUAGE,OPERATOR_CLASS,OPERATOR_FAMILYandTEXT_SEARCH_CONFIGURATION,_DICTIONARY,_PARSERand_TEMPLATE, read with the wordsCOMMENT ONuses for the same objects. Name lists,IF EXISTSandCASCADEorRESTRICTwork as for the other types, andgetType()returns the words separated by spaces.getAccessMethod()keeps the index access method of an operator class or family, which requiresUSINGand one name, andisProcedural()keeps thePROCEDURALspelling. This followsDROP FOREIGN DATA WRAPPER(#2872).Public method signatures are retained.
getObjectType()reportsLANGUAGEforDROP LANGUAGE, where it reportedOTHER.DROP OPERATOR name (type, type),DROP CASTandDROP TRANSFORMneed their own target models and are not part of this change.Syntax reference: PostgreSQL 18 DROP ACCESS METHOD, DROP LANGUAGE, DROP OPERATOR CLASS, DROP OPERATOR FAMILY, DROP TEXT SEARCH CONFIGURATION, DICTIONARY, PARSER, TEMPLATE.
Validation:
DropObjectTypeTestadds 11 statements. Each is checked againsttoString()and the deparser, parsed again, parsed with and without the PostgreSQL dialect and inside a script, and has no tables. Further tests check the object types, names, access method andPROCEDURALspelling, the type words used as names, and 9 rejected forms. On masterdd03d6ff1, 8 of the 11 fail and the other 3 have the object typeOTHER.pg_dump --clean --if-existsscript from PostgreSQL 18.6, with these objects and with the psql meta-commands removed, fails on master atDROP TEXT SEARCH CONFIGURATION. It parses as 72 statements with this change.check: 12,343 tests, 0 failures, 25 skipped. Grammar ambiguity, formatting (Spotless ratchet againstupstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass.AI assistance: prepared with Claude Code.