Skip to content

feat: support additional PostgreSQL COMMENT targets - #2639

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-comment-targets
Open

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-comment-targets

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

PostgreSQL COMMENT ON INDEX idx IS 'description' and seven other catalog target kinds currently fail to parse. This adds structured support for INDEX, SCHEMA, SEQUENCE, DOMAIN, TYPE, MATERIALIZED VIEW, FUNCTION, and CONSTRAINT, including constraints owned by a table or domain.

CommentTarget preserves object names and constraint ownership, and reuses RoutineReference for function signatures, argument modes, names, and types. The existing table/column/view accessors remain available. Comment rendering is shared with the statement deparser, visitors can traverse explicit relations and literals, and table discovery avoids treating indexes, types, domains, sequences, or functions as tables. A dedicated validator exposes target-specific capabilities.

Regression coverage includes quoted dotted identifiers, qualified and Unicode names, optional function signatures, ON DOMAIN versus a table named domain, comment removal, tagged dollar strings, AST round trips, and custom visitor/deparser behavior. Unambiguous target syntax works without a dialect preset; tagged dollar strings retain their existing PostgreSQL/explicit-option requirement.

Validation

  • ./gradlew spotlessApply check --max-workers=2 --no-daemon with the formatting ratchet pinned to base 6312f9e5: 6,994 tests, zero failures/errors, 25 skipped; formatting, PMD and SpotBugs passed.
  • EXPORT_TEST_TO_FILE=False mvn -B clean verify: 6,976 tests, zero failures/errors, 25 skipped.
  • PostgreSQL 18.6 differential audit: all 228 valid cases passed parsing, AST checks, both rendering paths, and execution with the expected stored comment; 11 malformed cases were rejected by both PostgreSQL and the parser. JSqlParser 5.4 rejected all 228 valid cases.
  • Merged locally with fix: preserve PostgreSQL quoted names, numeric scales and comment literals #2638 without conflicts: 7,069 Gradle tests, zero failures/errors, 25 skipped. All 237 valid cases from the earlier audit now pass, alongside all 228 valid cases in this audit. Numeric range validation remains outside the parser's scope.

This follows up on the eight unsupported COMMENT targets identified during #2638's audit. It is based directly on master and can merge independently of #2638. Other PostgreSQL COMMENT target kinds are outside this change.

Reference: PostgreSQL 18 COMMENT syntax.

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.

1 participant