Skip to content

fix: parse PostgreSQL DROP for object types of several words - #2884

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/postgresql-drop-multiword-types-20261031
Oct 31, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/postgresql-drop-multiword-types-20261031

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

DROP ACCESS METHOD heptree and DROP PROCEDURAL LANGUAGE plsample parsed, but with ACCESS or PROCEDURAL as the object type and METHOD or LANGUAGE as the name, and failed with IF EXISTS. DROP OPERATOR CLASS … USING btree, DROP OPERATOR FAMILY … USING btree and DROP TEXT SEARCH CONFIGURATION | DICTIONARY | PARSER | TEMPLATE failed. pg_dump --clean --if-exists writes all of them, so a dump with these objects failed as a script at its first DROP TEXT SEARCH.

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 the same objects. Name lists, IF EXISTS and CASCADE or RESTRICT work as for the other types, and getType() returns the words separated by spaces. getAccessMethod() keeps the index access method of an operator class or family, which requires USING and one name, and isProcedural() keeps the PROCEDURAL spelling. This follows DROP FOREIGN DATA WRAPPER (#2872).

Public method signatures are retained. getObjectType() reports LANGUAGE for DROP LANGUAGE, where it reported OTHER. DROP OPERATOR name (type, type), DROP CAST and DROP TRANSFORM need 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:

  • DropObjectTypeTest adds 11 statements. Each is checked against toString() 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 and PROCEDURAL spelling, the type words used as names, and 9 rejected forms. On master dd03d6ff1, 8 of the 11 fail and the other 3 have the object type OTHER.
  • A pg_dump --clean --if-exists script from PostgreSQL 18.6, with these objects and with the psql meta-commands removed, fails on master at DROP TEXT SEARCH CONFIGURATION. It parses as 72 statements with this change.
  • PostgreSQL 18.6 accepts all 11 statements and rejects the 9 rejected forms with syntax errors.
  • Java 17 Gradle check: 12,343 tests, 0 failures, 25 skipped. Grammar ambiguity, formatting (Spotless ratchet against upstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass.

AI assistance: prepared with Claude Code.

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]>
@manticore-projects
manticore-projects merged commit 5adf217 into JSQLParser:master Oct 31, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants