Repository navigation
feat: parse PostgreSQL DROP FOREIGN DATA WRAPPER and DROP USER MAPPING - #2872
Merged
manticore-projects merged 1 commit intoOct 29, 2026
Conversation
CREATE and ALTER of foreign-data wrappers and user mappings parsed, as did DROP SERVER, but DROP FOREIGN DATA WRAPPER and DROP USER MAPPING failed. pg_dump --clean --if-exists writes both, so such a dump could not be parsed as a script. DROP FOREIGN DATA WRAPPER is a Drop with the new object type FOREIGN_DATA_WRAPPER, so name lists, IF EXISTS and CASCADE or RESTRICT work as for DROP SERVER. A user mapping has no name of its own, so the new DropUserMapping keeps the user and the server like CreateUserMapping and AlterUserMapping. DROP USER for a user named mapping is unchanged. Signed-off-by: minleejae <mmj9808@gmail.com>
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.
CREATEandALTERof foreign-data wrappers and user mappings parse, and so doesDROP SERVER, butDROP FOREIGN DATA WRAPPERandDROP USER MAPPINGfailed.pg_dump --clean --if-existswrites both, for exampleDROP USER MAPPING IF EXISTS FOR public SERVER dsandDROP FOREIGN DATA WRAPPER IF EXISTS dw, so such a dump failed as a script at the first user mapping.DROP FOREIGN DATA WRAPPERis now aDropwith the new object typeFOREIGN_DATA_WRAPPER, so name lists,IF EXISTSandCASCADE/RESTRICTwork as forDROP SERVER. A user mapping has no name of its own andDROP USER MAPPINGtakes noCASCADE, so it does not fitDrop. The newDropUserMappingkeeps the user and the server asCreateUserMappingandAlterUserMappingdo. The statement visitors, the deparser, the validator (asFeature.drop, likeDropPolicy) andTablesNamesFinder(no tables) handle it.DROP USER mapping, which drops a user namedmapping, still parses asDROP USER.Public method signatures are retained.
StatementVisitorgains default methods forDropUserMapping.Syntax reference: PostgreSQL 18 DROP FOREIGN DATA WRAPPER, DROP USER MAPPING.
Validation:
PostgreSqlForeignDataObjectsTestadds 7 statements. Each is checked for round trip throughtoString()and the deparser, for script boundaries, for having no tables, and against DDL and SELECT validation. Further tests check the object type, the mapping key and theDROP USER mappingcase, plus 3 rejected forms. All 7 statements fail on masterc84ad0ebc, with and without the PostgreSQL dialect.pg_dump --clean --if-existsscript from PostgreSQL 18.6, with foreign-data wrappers, servers and user mappings and with the psql meta-commands removed, fails at its firstDROP USER MAPPINGon master. It parses as 30 statements with this change.check: 12,276 tests, 0 failures, 25 skipped. Grammar ambiguity, formatting (Spotless ratchet againstupstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass.CCJSqlParser(JaCoCo instrumentation of CCJSqlParser is approaching the constant-pool limit #2866): 808 entries on master, 711 with this change.AI assistance: prepared with Claude Code.