{"record":{"id":"e045a6b9a7980113","repo":"apache/shardingsphere","slug":"42000-e045a6","errorCode":"42000","errorMessage":"You have an error in your SQL syntax: %s","messagePattern":"You have an error in your SQL syntax: (.+?)","errorType":"exception","errorClass":"SQLParsingException","httpStatus":null,"severity":"error","filePath":"parser/sql/engine/core/src/main/java/org/apache/shardingsphere/sql/parser/engine/core/database/parser/SQLParserErrorListener.java","lineNumber":47,"sourceCode":" */\n@NoArgsConstructor(access = AccessLevel.PRIVATE)\npublic final class SQLParserErrorListener extends BaseErrorListener {\n    \n    private static final SQLParserErrorListener INSTANCE = new SQLParserErrorListener();\n    \n    /**\n     * Get instance.\n     *\n     * @return instance\n     */\n    public static SQLParserErrorListener getInstance() {\n        return INSTANCE;\n    }\n    \n    @Override\n    public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line, final int charPositionInLine,\n                            final String message, final RecognitionException e) {\n        throw new SQLParsingException(message, offendingSymbol, line);\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":50,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/parser/sql/engine/core/src/main/java/org/apache/shardingsphere/sql/parser/engine/core/database/parser/SQLParserErrorListener.java#L29-L50","documentation":"Thrown by SQLParserErrorListener.syntaxError, the singleton ANTLR error listener registered during the LL (full) parse phase in SQLParserExecutor.twoPhaseParse. When ANTLR reports any syntax error in LL mode, the listener converts it directly into SQLParsingException carrying the offending symbol and line, so the failure surfaces with precise position info (message, offendingSymbol, line) rather than the raw SQL text.","triggerScenarios":"A statement that fails fast SLL parsing (ParseCancellationException) and then, after reset to PredictionMode.LL with the default listeners removed and this listener added, still contains a syntax error — ANTLR calls syntaxError and the exception is thrown immediately. Typical for truly malformed SQL in any supported dialect.","commonSituations":"User-submitted SQL with typos; ORM-generated SQL that uses syntax the dialect grammar does not yet support; SQL from a newer database version than the grammar files; escaped/unescaped quote mismatches; SQL containing database-specific hints the grammar rejects.","solutions":["Use the exception's offending symbol and line fields to locate the exact broken token","Run the same SQL directly against the target database to confirm whether the database or only ShardingSphere's grammar rejects it","If the database accepts it, check for a fixed grammar in a newer ShardingSphere release and upgrade","Simplify the SQL (remove hints/comments/special clauses) to isolate the unsupported construct","Report the statement to the ShardingSphere issue tracker if the dialect genuinely supports it"],"exampleFix":"// before\nString sql = \"SELECT * FORM t\"; // FORM typo\nsqlParserExecutor.parse(sql); // SQLParsingException, offendingSymbol=FORM, line=1\n\n// after\nString sql = \"SELECT * FROM t\";\nsqlParserExecutor.parse(sql);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    ParseASTNode ast = executor.parse(sql);\n} catch (SQLParsingException e) {\n    // e carries offendingSymbol + line: log them for precise user feedback\n    log.warn(\"Syntax error near line {}: {}\", e.getLine(), e.getOffendingToken());\n}","preventionTips":["Validate user SQL against the real database or a linter before parsing through ShardingSphere","Strip database-specific hints/comments that the grammar may reject","Track grammar fixes in release notes and keep the parser version aligned with your DB version"],"tags":["sql-parser","antlr","syntax","error-listener","dialect"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}