Repository navigation
fix: lex // as a line comment only for H2 and Snowflake - #2957
Merged
manticore-projects merged 1 commit intoNov 24, 2026
Merged
manticore-projects merged 1 commit into
manticore-projects merged 1 commit into
Conversation
LINE_COMMENT matched // in every dialect, but only H2 and Snowflake have // comments. Everywhere else //* is a division followed by a block comment, so SELECT 6 //*x*/ 2, (SELECT max(pw) FROM secrets) parsed as SELECT 6 while MySQL, MariaDB, PostgreSQL, SQL Server and SQLite run the subquery. // comments are now a lexer switch like # comments (Feature.allowDoubleSlashLineComments, withDoubleSlashLineComments), turned on by the H2 and SNOWFLAKE presets.
Contributor
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LINE_COMMENTmatches//under every dialect and without one, but only H2 and Snowflake have//comments. Everywhere else//*is a division followed by a block comment, soSELECT 6 //*x*/ 2, (SELECT max(pw) FROM secrets)parses asSELECT 6andTablesNamesFinderfinds no table, while MySQL 9.7, MariaDB, PostgreSQL 16, SQL Server and SQLite all return the subquery (H2 2.3 returns6, like the current parse).SELECT 1 //**/ 1; DROP TABLE usersparses as a singleSELECT 1withmayModifyData() == false, and PostgreSQL drops the table.//comments are now a lexer switch like#comments:Feature.allowDoubleSlashLineComments/withDoubleSlashLineComments(), turned on by theH2andSNOWFLAKEpresets and implemented with the same token-start rewrite inSimpleCharStreamthat#uses. With the switch off,//*lexes as/and a block comment; no per-dialect rule goes into the lexer.// commentis now a syntax error, as it is on the servers without//comments.testParseStatementIssue1250(where//support came from) andLeadingCommentsTestopt in for that reason.The default-path assertions of the new
testDoubleSlashLineCommentsFeaturefail on master and the whole test passes after;./gradlew check(16645 tests, grammar ambiguity, Spotless, Checkstyle, PMD, SpotBugs) andmvn verifypass locally.