Repository navigation
Core SQL test harness: ignore comments in SET statements - #627
Open
puretechteam wants to merge 2 commits into
Open
puretechteam wants to merge 2 commits into
puretechteam wants to merge 2 commits into
Conversation
ParseSetAssignments removed comments only before the SET keyword. A comment between or after the assignments became part of a setting name or value, and a quote in a comment (-- don't ...) hid all the assignments after it. The shim now replaces each comment that is not in a quoted string with a space before it splits the assignments, as clickhouse-client does. Fixes ClickHouse#626
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 723ef67. Configure here.
AI review gate — AI review passedClean review from: Cursor Bugbot. |
RemoveComments and the split loop of ParseSetAssignments did not skip $tag$...$tag$ heredocs, as ScanStatementEnd, FindOutputFormat and TopLevelWords do. A comment marker in a heredoc value removed the rest of the line, and a comma in a heredoc value split the value. Both loops now skip heredocs with HeredocEnd.
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.

Fixes #626.
ParseSetAssignmentsremoved comments only before theSETkeyword. The split loop then saw--,#and/* */comments as text, so:AfterSuccessdid not erase the command-line setting.'in a comment opened a string literal and hid all the assignments after it.dialect).The shim now replaces each comment that is not in a quoted string with one space before it splits the assignments. It uses the comment helpers that
sql_text.cppalready has (SkipQuoted,LineCommentAt,SkipLineComment,SkipBlockComment), so it finds the same comments as the statement splitter.Tests
In
ut/args_ut.cpp:ParseSetAssignments.Comments: the three cases from the issue, plus a comment after the value with no;and a#comment.ParseSetAssignments.CommentMarkersInStrings:#,--and/* */in quoted values stay part of the value.Before the change,
Commentsfails on all 5 assertions with the output in the issue. After the change, all 3ParseSetAssignmentstests pass.CommentMarkersInStringspasses before and after.I ran these tests with MSVC on Windows (only
runner.cpp,sql_text.cppandargs_ut.cpp, because the rest of the shim needs POSIX headers). CI builds the full shim with GCC and Clang. Formatted with the repository.clang-format.Note
Low Risk
Scoped to test harness SET parsing with added unit tests; no production server or auth paths touched.
Overview
SET parsing in the clickhouse test shim now mirrors clickhouse-client by stripping SQL comments from the assignment list before splitting on commas.
A new
RemoveCommentspass replaces--,#, and/* */(outside quoted strings and heredocs) with spaces, reusing the same helpers as the statement splitter. The comma scanner also skips heredoc bodies so commas inside$tag$...$tag$values do not break parsing.Unit tests cover inline and between-assignment comments, comment-like text inside quoted values, and heredoc settings.
Reviewed by Cursor Bugbot for commit 463727e. Bugbot is set up for automated code reviews on this repo. Configure here.