Skip to content

fix: classify metadata DDL schema effects - #2754

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
fudianchn:fix/classify-metadata-ddl-features
Oct 2, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
fudianchn:fix/classify-metadata-ddl-features

Conversation

@fudianchn

Copy link
Copy Markdown
Contributor

AI disclosure: this change was prepared with AI coding agents, reviewed and revised line by line by me.

What

Classify eight parsed metadata DDL types as MODIFIES_SCHEMA: ALTER COLLATION, ALTER DATABASE, ALTER SCHEMA, ALTER STATISTICS, ALTER TABLE/INDEX ALL IN TABLESPACE, ALTER/CREATE TEXT SEARCH CONFIGURATION and CREATE USER.

Why

These statements currently reach the unknown-statement fallback. Their feature analysis reports OPAQUE with all four possible data, schema and query effects, despite the visitor already using schema-only classification for other metadata definitions.

How

Add eight visitor overrides that return the existing schemaOnly() analysis. Add real SQL regression cases across direct, string, predicate-aware, script-union and per-statement analysis, with following executed SQL and conservative fallback controls.

Root cause

The eight statement types inherit adapter behavior without a corresponding feature visitor classification. Analysis therefore receives no classification and conservatively applies the unknown-statement fallback.

Testing

  • On master 6d1ec1df1596d154fff3911452cd6979d46b9751, the 36-case regression has 32 expected classification failures and four passing controls. All SQL samples parse; failures compare MODIFIES_SCHEMA against OPAQUE.
  • The fix passes all 36 new cases and 30 existing feature visitor cases, including nested suites. Sixteen metadata examples each cover multiple entry points; another sixteen exercise mixed scripts with an executed SELECT f(id) FROM t, preserving its data reads, result rows and unresolved function reference.
  • Three isolated mutations are rejected: removing the eight classifications causes 32 failures; treating schema-only definitions as data modifications causes 35 failures; treating the opaque fallback as schema-only causes one guard failure. Final sources are restored.
  • Final identical-source JDK 17 Gradle check passes: 9,518 cases, zero failures/errors and 25 skipped. Maven clean verify spotless:check passes: 9,500 cases, zero failures/errors and 25 skipped. Gradle grammar, Checkstyle, PMD, SpotBugs main/JMH, coverage and Spotless tasks pass; SpotBugs test is skipped by the upstream configuration. The separate strict changed-file license check scans both changed Java files and passes. The full-tree Maven license step reports 33 header extraction warnings for unchanged resource files; these are outside this patch.
  • No database-server execution, Windows/macOS matrix or feature-analysis benchmark was run.

Behavior notes

The parser, AST models and adapters are unchanged. Unknown statements and explicit unsupported syntax remain conservative. Stored definitions retain the visitor's existing classification; following executed SQL is still analyzed separately.

This change does not duplicate PR #2738's twelve other DDL classifications. CREATE/ALTER EVENT and NOTIFY remain outside this patch because their lifecycle or effect taxonomy needs a separate design decision. Generic fallback diagnostic markers are also outside this patch.

Verification of the original issue

No existing issue is linked. The independent failures were reproduced on upstream master 6d1ec1df1596d154fff3911452cd6979d46b9751 and checked against PR #2738 head 7f8bb7fb24401a4940ff89d36aefa8e224603c08. All eight types still use the conservative fallback on both versions. The local fix now reports only the certain schema effect for SQL such as:

ALTER COLLATION c REFRESH VERSION;
ALTER DATABASE d READ ONLY = 0;
CREATE TEXT SEARCH CONFIGURATION c (COPY = pg_catalog.simple);
CREATE USER u;

Locally verified fixed commit: 335cbcd727eaaf683f759f5a3a976b7e1f07e879 on fix/classify-metadata-ddl-features. Independent owner review and the combined validation with PR #2738 and the separate fallback fix pass.

Signed-off-by: 付典 <fudianchn@gmail.com>
@fudianchn
fudianchn marked this pull request as ready for review October 2, 2026 11:34
@manticore-projects
manticore-projects merged commit f63ace3 into JSQLParser:master Oct 2, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you very much for improving this.

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