Skip to content

fix: keep generic fallback references semantic - #2755

Open
fudianchn wants to merge 2 commits into
JSQLParser:masterfrom
fudianchn:fix/keep-feature-fallback-references-semantic
Open

fudianchn wants to merge 2 commits into
JSQLParser:masterfrom
fudianchn:fix/keep-feature-fallback-references-semantic

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

Keep generic feature-analysis fallback conservative without inserting Java statement or container class names into unresolved references.

Why

An unclassified statement currently receives an unresolved reference such as oraclenullstatement, and an empty script receives statements. These names do not identify a function, procedure or dynamic SQL marker for a caller to resolve. The documented feature verdict still needs to remain opaque.

How

Separate the existing opaque feature flags from explicit reference registration. The generic fallback adds only OPAQUE and its four possible effects. Visitors which supply a procedure name or an explicit marker keep registering that reference. Document that an empty reference set does not establish safety.

Root cause

Both single-statement and aggregate analysis pass a Java simple class name to failLoudIfSilent. That helper calls the same opaque(reference) method used for meaningful procedure names and dynamic SQL markers, which adds its argument to the lower-case unresolved set.

Testing

  • The same formatted 14-case regression artifact was run on upstream 6d1ec1df1596d154fff3911452cd6979d46b9751 and the fix. The baseline has 8 assertion failures and 6 passing normal controls; the fix passes all 14. No baseline parser errors are counted as this defect.
  • Fixed targeted coverage includes the 30 original feature-analysis cases: 44 executions, zero failures/errors/skips. Cases cover public getFeatures overloads, empty/single/multiple-item scripts, analyseEach, inert Oracle statements and an Oracle assignment whose unproven function reference is discovered before fallback.
  • Controls verify CALL procedure names, PostgreSQL DO (with the required dialect), unsupported/explain markers, unresolved functions and allow-list behavior, classified SELECT/schema DDL, and the existing stored-routine marker. CALL/unknown/SELECT scripts check reference isolation and subsequent result positions.
  • Two isolated guard mutations are rejected: dropping explicit references fails 6 of 14 cases; dropping the four possible effects fails 9 of 14. The production source is restored byte-for-byte.
  • Final JDK 17 Gradle check passes with 9496 test records (9471 executed, 25 existing skips), zero failures/errors. Maven offline clean verify and Spotless check passes with 9478 records (9453 executed, 25 existing skips), zero failures/errors. The changed-file license check scans all three changed Java files and passes; usage.rst is excluded by upstream license configuration. All 33 existing SQL resource header warnings were compared byte-for-byte with the baseline and are unchanged. Maven Spotless apply, final Gradle Spotless checks and Maven Spotless check agree on the unchanged final four source files.
  • No database execution, Windows/macOS matrix or benchmark result is claimed.

Behavior notes

  • OPAQUE and possible READS_DATA, RETURNS_RESULT_SET, MODIFIES_DATA and MODIFIES_SCHEMA are unchanged. Empty unresolved references do not mean effects are known or safe; callers must inspect the feature verdict.
  • Generic fallback output intentionally loses Java type/container names. Code matching those synthetic strings should use OPAQUE/may instead. Existing explicit function/procedure/DO/unsupported/explain references remain.
  • CreateFunctionalStatement has a separate explicit statement-type marker, such as createfunction; it remains unchanged. This change does not promise that every existing marker is a SQL catalogue name.
  • The aggregate certain-empty fallback criterion and statement result-position lifecycle are unchanged. Unknown children inside an otherwise classified aggregate remain a separate concern. Event/Notify classifications and metadata DDL omissions are outside this change.
  • No public API, parser grammar, dialect setting or AST shape changes.

Verification of the original issue

No existing issue is linked. On upstream 6d1ec1df1596d154fff3911452cd6979d46b9751, new OracleNullStatement().getFeatures() is opaque with unresolved [oraclenullstatement]; StatementFeatureVisitor.analyse(new Statements()) is opaque with unresolved [statements]. Both now retain exactly the same feature flags with an empty reference set. An Oracle assignment to an unproven function retains its function name without adding oracleassignment. Fixed local commit: cd35c83e12a488a1bd6f6c034f5283e2f785e5bd on fix/keep-feature-fallback-references-semantic. Independent owner review and combined validation with PR #2738 and the separate metadata classification 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

Copy link
Copy Markdown
Contributor

This makes sense, thank you for working on it.
Please resolve conflicts first.

This branch has not been deployed

No deployments
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