Fixing an extra FORMAT JSON in the query when attempting to insert a record#262
Closed
AlexandrFiner wants to merge 1 commit into
Closed
Fixing an extra FORMAT JSON in the query when attempting to insert a record#262AlexandrFiner wants to merge 1 commit into
FORMAT JSON in the query when attempting to insert a record#262AlexandrFiner wants to merge 1 commit into
Conversation
… using a regular expression
Contributor
|
I was working on something like this patch as a stab at getting this compatible with all possible statements. But I'm not convinced yet that this is the way to go or not. There are also compatibility issues with clickhouse 21 with my patch. |
isublimity
added a commit
that referenced
this pull request
Jun 10, 2026
… JSON Distributed DDL (... ON CLUSTER ...) returns a per-host status result set. Previously the client appended "FORMAT JSON" to the SQL text, which caused three problems: - CREATE USER / GRANT / ALTER ON CLUSTER failed with SYNTAX_ERROR because ClickHouse does not accept a FORMAT clause on those statements (#241) - After the FORMAT-keyword inversion, CREATE/ALTER ON CLUSTER results came back unformatted and Statement parsing threw "Can`t find meta" (#263) - A bare "ON CLUSTER" substring inside INSERT data (e.g. 'REGION CLUSTER') was treated as the keyword, breaking the insert (#262) Now prepareWrite() requests JSON output via the default_format=JSON query setting (leaving the SQL untouched) and tags the request so the Statement parses it. Detection uses \b word boundaries to match the real keyword only. Testing: - new tests/ClickHouse26/OnClusterTest.php (CREATE/ALTER/CREATE USER ON CLUSTER), skips gracefully without a Keeper/ZooKeeper backend - embedded ClickHouse Keeper config for the test env so the single-node `default` cluster can run distributed DDL (docker-compose + CI) - testInsertWithOnClusterInData on both CH21 and CH26 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Спасибо за разбор и тест-кейс с Закрываю в пользу единого фикса в master (a2783e6, релиз 1.26.610), который покрывает этот случай вместе с #241 и #263. Корень всех трёх проблем — дописывание
Ваш тест |
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.
Summary
ON CLUSTER, an extraFORMAT JSONis added, which breaks the queryProblem
ON CLUSTERin a query does not take into account that it may be part of the dataSolution
stripos()check is used as a first-level filter to detect the presence of ON CLUSTER in the SQL string.preg_match()is only executed when the substring is present, providing a strict validation of the ON CLUSTER keyword.ON CLUSTERonly as a SQL keyword, ignoring occurrences inside string literals.