Repository navigation
Core SQL test harness: ignore comments in SET statements - #627
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.
|
@polyglotAI-bot - can you review this PR, and check why the CI is failing |
|
The PR corrects comment handling in Final verdict✅ Approve Automated static review (no build or test run) by Polyglot AI (gpt-6-astra) of |
polyglotAI-bot
left a comment
There was a problem hiding this comment.
Review of 463727e posted: see the summary comment and the inline threads.

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.