You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
clickhouse-client (v1): named-parameter scan is heredoc-unaware — :name inside $$...$$ is extracted as a parameter #3037
com.clickhouse.client.ClickHouseParameterizedQuery (module clickhouse-client, v1 stack) extracts named parameters (:name, :name(Type)) by scanning the SQL. The scan skips quoted strings and -- / /* */ comments, but it has no notion of a heredoc (dollar-quoted) string literal — $$...$$ or $tag$...$tag$. A :name inside a heredoc is therefore extracted as a parameter, and the heredoc's text is rewritten when parameters are substituted.
This affects both entry points of the class: the instance path (ClickHouseParameterizedQuery.of(...) / parse(), used by ClickHouseRequest.getPreparedQuery(), the v1 JDBC driver when namedParameter=true, and clickhouse-r2dbc) and the static ClickHouseParameterizedQuery.apply(sql, params) path.
This is the named-parameter sibling of #3035 (which is about ? placeholders in clickhouse-jdbc's JdbcParameterizedQuery).
Through the v1 JDBC driver with namedParameter=true:
PreparedStatementps = conn.prepareStatement("select $$a:b$$ as s, :n(String) as n");
ps.getParameterMetaData().getParameterCount(); // expected 1, actual 2
Further symptoms, all caused by the same blind spot:
select $$it's$$, :n fails with IllegalArgumentException: Missing quote: ' — the ' inside the heredoc starts a quoted-string scan.
select $$-- :b$$, :n loses the real :n parameter entirely (the -- inside the heredoc starts a line comment).
Substitution corrupts the literal: select $$a:b$$, :n with n=X becomes select $$aNULL$$, X.
Expected behaviour
A heredoc is an opaque string literal: its content is never scanned for parameters and is passed through unchanged. select $$a:b$$, :n has exactly one parameter (n).
A dollar sign that does not open a heredoc must keep its current meaning — $ is a valid identifier character, so a $ following a word character continues an identifier (a$x$), and a $ with no matching closing tag does not open a heredoc.
Activity
chernser commentedon Aug 18, 2026
V1 - wont fix because requires parser refactor - will be fixed in V2.