Repository navigation
fix(clickhouse): write values too long for the URL into the statement - #3781
Merged
Merged
Conversation
Values stay param_ URL items within the server's 128 KiB field and 1 MiB URL limits, every URL item is percent-encoded (a + arrived as a space), and a body over max_query_size raises it for that request.
datlechin
enabled auto-merge (squash)
October 22, 2026 11:22
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
param_URL items while each is at most 131,072 bytes percent-encoded and the items fit 1 MiB less 4 KiB, the limits the server enforced. Past that, every value of the statement is written into it and travels in the POST body: a plain literal, as the server substitutes a String parameter, andCAST('…' AS String)inside INSERT data, where a plain literal goes to the column parser (a braced UUID was stored as another UUID).max_query_size, read fromsystem.settings, carriesmax_query_sizesized to it when the profile lets the user set it. Covers grid saves, imports and their key probes, object copy, MCP inserts, data sync, compare lookups and the iOS row editor.+alone and the server decoded it as a space, soa+bwas stored asa b, and a database nameda+bwas looked up asa b.?scanner skips--and/* */comments and$$/$tag$bodies, asSQLParameterExtractordoes, so an apostrophe or?in a comment no longer breaks a parameterized query.escapeStringLiteralwalks scalars and drops MySQL's\Z, which ClickHouse reads as a backslash and a Z.C:\newarrived with a newline and a value ending in\'closed the literal.escapedParameterValuewalks Unicode scalars. A quote with a combining mark after it was one Character no case matched, so it went out unescaped and ended the literal (data sync on every engine, the default binder Trino uses). Body change only, no ABI change.apple/scripts/probes/check-clickhouse-long-values.shchecks the server facts this rests on.Test plan
ClickHouseParameterBindingTests: long values written in, the URL budget in encoded bytes and item names, INSERT data cast and nowhere else, escapes, comments and dollar quotes.ClickHouseRequestTests:max_query_sizeagainst the user's limit, readonly user and constraint max; a stubbed 200 KB INSERT and 300 KB UPDATE send noparam_item;+percent-encoded.ClickHouseServerProfileTests,SQLWriteBatchBudgetTests,CompareSQLLiteralTextTests,EscapedParameterValueTests,SqlStandardEscapeTests.ALTER TABLE … UPDATEfails at 262,144 and runs withmax_query_size; plain literals (WHERE, UPDATE) and casts (INSERT, one and two rows) match String parameters on 24 column types; column type corpusclickhouseholds.ClickHouseOnIOSTestsPluginBackedDriverTestsRowWriteRoutingTests, abi, lint.Fixes #3777