You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[jdbc-v2] ANTLR4 lexer rejects // line comments accepted by the server and the JavaCC grammar #3023
--, # and #! are handled, // is not. Because the lexer also defines SLASH : '/', // comment lexes as two SLASH tokens, so statements the server accepts are reported as syntax errors by both ANTLR4-based parser backends (ANTLR4 and ANTLR4_PARAMS_PARSER), and with ANTLR4_PARAMS_PARSER a ? inside a // comment is counted as a bind parameter.
The JavaCC grammar already accepts it (ClickHouseSqlParser.jj): <SINGLE_LINE_COMMENT: ("--" | "//" | "#" | "#!") (~["\r","\n"])*>.
Steps to reproduce
With ANTLR4 or ANTLR4_PARAMS_PARSER selected as the SQL parser, prepare any statement containing a // line comment, e.g.
SELECT1// comment
, ?
ParsedPreparedStatement.isHasErrors() is true; with ANTLR4_PARAMS_PARSER a ? placed inside the comment is also counted in getArgCount(). An INSERT preceded by a // comment is additionally misclassified (isInsert() == false).
Expected behaviour
// starts a line comment and is skipped, exactly like --, # and #! — matching the server and the JavaCC grammar. A single / (division) and // inside a string literal must keep their current meaning.
Activity
Fix jdbc-v2: accept // line comments in the ANTLR4 lexer