Skip to content

Core SQL test harness: ignore comments in SET statements - #627

Open
puretechteam wants to merge 2 commits into
ClickHouse:masterfrom
puretechteam:fix/set-comments-626
Open

puretechteam wants to merge 2 commits into
ClickHouse:masterfrom
puretechteam:fix/set-comments-626

Conversation

@puretechteam

@puretechteam puretechteam commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #626.

ParseSetAssignments removed comments only before the SET keyword. The split loop then saw --, # and /* */ comments as text, so:

  1. A comment before a setting name became part of the name, and AfterSuccess did not erase the command-line setting.
  2. A ' in a comment opened a string literal and hid all the assignments after it.
  3. A comment after a value became part of the value (for example 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.cpp already 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, Comments fails on all 5 assertions with the output in the issue. After the change, all 3 ParseSetAssignments tests pass. CommentMarkersInStrings passes before and after.

I ran these tests with MSVC on Windows (only runner.cpp, sql_text.cpp and args_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 RemoveComments pass 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.

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
@puretechteam
puretechteam requested review from a team and slabko as code owners November 23, 2026 14:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 723ef67. Configure here.

Comment thread tests/clickhouse-test-runner/runner.cpp Resolved
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

AI review gate — AI review passed

Clean 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core SQL test harness: ParseSetAssignments does not skip comments inside SET

1 participant