terrymanu commented on issue #39032: URL: https://github.com/apache/shardingsphere/issues/39032#issuecomment-5004536071
Hi @ZhuCanle, thanks for reporting this. This is a duplicate of [#35277](https://github.com/apache/shardingsphere/pull/35277), which fixed the same `MySQLStatementVisitor#getOriginalText` failure when the optional `matchSearchModifier` is absent. The issue uses ShardingSphere-JDBC 5.5.2, while #35277 was merged as [6edee9b](https://github.com/apache/shardingsphere/commit/6edee9b3a2c949f20958e1033754124c3ee174d9) and included in 5.5.3. Please verify the SQL with ShardingSphere 5.5.3. If it still fails there, please provide the new stack trace so we can check for a different path; otherwise, I suggest labeling this as `type: duplicate`, `in: SQL parse`, and `db: MySQL`, then closing it as duplicate. The reply above is based on the analysis below; the detailed reasoning is kept here for reference and follow-up contributors. ### Problem Understanding - **Issue:** ShardingSphere-JDBC 5.5.2 throws a `NullPointerException` when MySQL `MATCH(...) AGAINST(...)` omits the search-mode modifier. - **Topology:** JDBC; governance mode and registry configuration are not provided and do not affect this SQL parser path. - **OBS-1:** [#39032](https://github.com/apache/shardingsphere/issues/39032) provides the version, SQL, and stack trace. The failure occurs at `MySQLStatementVisitor.java:2036`, called from `visitMatchExpression` at line 1305. - **OBS-2:** In tag 5.5.2, `parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4:1216` declares `matchSearchModifier?`, while `MySQLStatementVisitor.java:1305` passes that optional context to `getOriginalText`; `MySQLStatementVisitor.java:2036` then dereferences it without checking for absence. - **Observed Evidence:** `OBS-1`, `OBS-2` ### Root Cause - **Observation:** Omitting the modifier makes `ctx.matchSearchModifier()` absent, but the 5.5.2 visitor treats it as mandatory (`OBS-2`). - **OBS-3:** [#35277](https://github.com/apache/shardingsphere/pull/35277) changed the same helper to return an empty string for an absent context and added the MySQL parser case `SELECT * FROM t_order WHERE MATCH(phone) AGAINST('15111111111')`. - **OBS-4:** Merge commit `6edee9b3a2c949f20958e1033754124c3ee174d9` is contained in tag 5.5.3 but not tag 5.5.2. Tag 5.5.3 retains the fix at `parser/sql/engine/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/engine/mysql/visitor/statement/MySQLStatementVisitor.java:2182`. - **Inference:** The missing modifier—not `CONCAT(...)`—causes the reported NPE (`INF-1`, based on `OBS-1` and `OBS-2`). - **Counterexample Check:** The historical regression case uses a literal while #39032 uses `CONCAT(...)`, but both reach the same optional-modifier call after `ctx.expr()` is visited. The issue also confirms that the same `CONCAT(...)` expression works when a modifier is present (`INF-2`, based on `OBS-1`–`OBS-3`). - **Confidence:** High ### Problem Analysis - **Issue Type:** Duplicate - **Evidence:** #35277 fixed the same class, method, trigger condition, and exception path before #39032 was opened (`OBS-1`–`OBS-4`, `INF-1`, `INF-2`). - **Version Boundary:** The failure is expected in the reported 5.5.2 code because that release predates the fix; 5.5.3 contains it (`OBS-1`, `OBS-4`). - **OBS-5:** The existing repository labels `type: duplicate`, `in: SQL parse`, and `db: MySQL` match the classification and module ownership. - **Label Recommendation:** `type: duplicate`, `in: SQL parse`, `db: MySQL` ### Problem Conclusion - **Evidence Confidence:** High (`OBS-1`–`OBS-5`, `INF-1`, `INF-2`) - **Impact Scope:** MySQL SQL parser, specifically `MATCH ... AGAINST` without a modifier on 5.5.2 (`OBS-1`, `OBS-2`) - **Topology:** JDBC; Standalone/Cluster is not relevant to this parser failure (`OBS-1`) - **Issue Type:** Duplicate (`OBS-3`, `OBS-4`, `INF-1`) - **Duplicate Of:** #35277 (`OBS-3`, `INF-1`) - **Fix PR:** #35277 (`OBS-3`) - **Merged In:** `6edee9b3a2c949f20958e1033754124c3ee174d9`, milestone/tag 5.5.3 (`OBS-3`, `OBS-4`) - **Recommended Labels:** `type: duplicate`, `in: SQL parse`, `db: MySQL` (`OBS-5`) - **Next Action:** Ask the author to verify with 5.5.3; close as duplicate unless the same failure is reproducible on a version containing the fix (`OBS-1`, `OBS-4`) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
