Skip to content

Support query parameters as user/role name in most contexts - #109696

Merged
GrigoryPervakov merged 1 commit into
masterfrom
pervakovg/query-param-user-identifier
Sep 29, 2026
Merged

GrigoryPervakov merged 1 commit into
masterfrom
pervakovg/query-param-user-identifier

Conversation

@GrigoryPervakov

@GrigoryPervakov GrigoryPervakov commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

Closes #109298

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Query parameters can now be used for primary USER and ROLE names in CREATE, ALTER, and DROP, and for role and grantee names in GRANT and REVOKE, e.g. GRANT {role:Identifier} TO {user:Identifier}.


Workflow [PR]
Sync PR [sync-upstream/pr/109696]

Version info

  • Merged into: 26.10.1.1015-master (included in 26.10 and later)

@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [09b1f69]

Summary: ✅


AI Review

Summary

This PR extends query-parameter support across access-management statements by keeping parameterized user/role name subtrees reachable through parsing, cloning, formatting, and attach-definition validation. I re-checked the current diff and all prior review threads against the latest code, and I did not find any remaining correctness or contract gaps in the currently advertised scope.

Final Verdict

✅ No new findings.

LLVM Coverage Report

Measured on commit 09b1f69.

Metric Baseline Current Δ
Lines 87.90% 87.90% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 490/544 (90.07%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jul 7, 2026
Comment thread src/Parsers/Access/ParserGrantQuery.cpp Resolved
@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch from a7f140b to 0e2b136 Compare July 8, 2026 13:36
@CLAassistant

CLAassistant commented Jul 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch from edcfda3 to 5b0311b Compare July 13, 2026 14:19
@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch 3 times, most recently from 79a848c to b1d7681 Compare July 16, 2026 17:16
@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch 2 times, most recently from a9f996c to c78398a Compare July 17, 2026 03:54
@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch from 1ccf533 to d5484a5 Compare August 18, 2026 15:08
@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 09b1f69b1 with master 8bc086b61 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

55 object files changed (+132.11 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Access/AccessEntityIO.cpp.o 97.75 KiB 136.86 KiB +39.12 KiB (+40.02%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

232 translation units recompiled, 1544 s compile time in total, 232 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.05 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +70.0 s (+5%) in total before that adjustment.

Job report

@GrigoryPervakov
GrigoryPervakov marked this pull request as ready for review August 19, 2026 14:28
@GrigoryPervakov

Copy link
Copy Markdown
Member Author

@groeneai investigate if CI failure is relevant and if not has issue or fixing PR

@groeneai

Copy link
Copy Markdown
Collaborator

Not relevant to your change. One red, and it aborts in the previous-release binary, not in yours.

Upgrade check (amd_release) - report

The reported name, Logical error '!part.empty()', is a log-parser artifact: it splices in source comments from an unrelated test file that happened to be running. The real abort in clickhouse-server.err.log is:

Logical error: 'Part patch-4811bd937f1be8e9d5ec5374e149fefa-all_0_0_0_1 doesn't exist'
  MergeTreeData::modifyPartState -> Transaction::commit
  -> ReplicatedMergeTreeSink::commitPart -> ReplicatedMergeTreeSinkPatch::finishDelayed

Two facts put it outside your diff:

  1. It fires in version 26.7.3.19 (official build), git hash c3c4a420478c7e8 = v26.7.3.19-stable, in the pre-upgrade phase. That is the stock previous release the check downloads, so your commits are not in that binary.
  2. Your diff is 36 files under src/Access, src/Parsers/Access and src/Storages/System plus one new stateless test. Nothing in MergeTree, the replicated sink, or lightweight updates.

Root cause, from this run's clickhouse-server.stress.log: 03100_lwu_drop_update_race.sh races UPDATE ... SET c2 = 'xx' against DROP TABLE ... SYNC. The UPDATE interpreter releases its shared table lock before the pipeline that commits the patch part runs, so the DROP takes the exclusive lock and clears data_parts_indexes, and the sink's commit then throws inside a NOEXCEPT_SCOPE:

21:13:15.601915 [146459] {f7a50437} Renaming temporary part tmp_insert_patch-...-all_2_2_0_1 -> patch-...-all_0_0_0_1
21:13:15.602156 [ 84576] {4eec8abd} dropAllData: waiting for locks.
21:13:15.619319 [ 84576] {4eec8abd} dropAllData: done.
21:13:15.619389 [146459] {f7a50437} <Fatal> Logical error: 'Part patch-...-all_0_0_0_1 doesn't exist'

{f7a50437} is the UPDATE, {4eec8abd} the concurrent DROP, both from 03100_lwu_drop_update_race.sh-test_5.

Fixing PR: #114826 ("Hold the table lock across a lightweight UPDATE pipeline"), open, mine. It parks the shared lock in the pipeline's resource holder the way InterpreterInsertQuery already does, so the DROP cannot land mid-commit.

For scope: in the last 30 days this signature fired on 6 pull requests and 0 times on master, always in Upgrade check (amd_release). Nothing to do on your side; a rerun should pass.

@GrigoryPervakov

Copy link
Copy Markdown
Member Author

@pufit can you check it?
Private CI build is trivial, but I don't want to introduce commits there until not sure this branch does not require heavy changes

@pufit

pufit commented Aug 28, 2026

Copy link
Copy Markdown
Member

Found this, probably worth fixing too

SET param_x = 'newname';
CREATE USER u;
ALTER USER u RENAME TO {x:Identifier};
SELECT name FROM system.users;  -- → '{x:Identifier}'  (!! param value ignored, no error)

Otherwise looks good

@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch 2 times, most recently from 8f880be to a917464 Compare September 1, 2026 15:29
@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch 2 times, most recently from 59891b1 to 3881f91 Compare September 3, 2026 15:54
@clickhouse-gh

clickhouse-gh Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 36 queries analysed

This PR lets CREATE/ALTER ROLE, CREATE USER, DROP USER/ROLE and GRANT accept query parameters, and rejects query parameters in stored access entity definitions. It does not touch query planning, aggregation or scans. Six ClickBench GROUP BY queries were slower (Q16 +17.1%, Q32 +17.5%, Q33 +12.6%, Q17 +10.3%, Q34 +8.8%, Q28 +6.5%). Each PR result is still inside master's recent range, so the automatic checks already marked them not_sure. That decision fits both the diff and the data. The slowdown hitting only aggregation queries, with both PR ClickBench runs on the same machine, points to machine variance rather than this change. No action is needed on the performance side.

clickbench

⚠️ 6 inconclusive

Flagged queries (6 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 16 not_sure 542 635 +17.1% <0.0001 aggregation: This is a GROUP BY-heavy SELECT at +17.1%, and 635 ms still falls inside master's recent 525–642.5 ms range. This PR changes only access-control SQL parsing and interpreters, which this query never runs.
⚠️ 17 not_sure 243 268 +10.3% <0.0001 aggregation: A +10.3% change on a GROUP BY SELECT that stays inside master's recent range. None of the changed role, user or grant code runs during this query.
⚠️ 28 not_sure 1054 1123 +6.5% 0.0004 aggregation: This one is +6.5%, and the measurements were very noisy on both sides. It stays within master's recent range and runs no access-control parsing code.
⚠️ 32 not_sure 720 846 +17.5% 0.0002 aggregation: A high-cardinality GROUP BY at +17.5%, still inside master's wide recent range of 705–945.5 ms. The PR does not touch aggregation or the SELECT path.
⚠️ 33 not_sure 1136 1279 +12.6% <0.0001 aggregation: A high-cardinality GROUP BY at +12.6%, inside master's recent range. Nothing in the diff runs during a SELECT.
⚠️ 34 not_sure 1148 1250 +8.8% 0.0012 aggregation: A +8.8% change on a GROUP BY SELECT, inside master's recent range. The diff does not touch the aggregation or scan code this query uses.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: e3c525e2-f3e3-4d32-8e99-ba6118b856d7
  • MIRAI run: 53b745f5-bd80-4562-992b-9261c4809c71
  • PR check IDs:
    • clickbench_2251454_1790611513
    • clickbench_2251467_1790611513
    • clickbench_2251473_1790611513
    • tpch_adapted_1_official_2251480_1790611513
    • tpch_adapted_1_official_2251510_1790611513
    • tpch_adapted_1_official_2252008_1790611536

@clickhouse-gh clickhouse-gh Bot added the comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. label Sep 4, 2026
@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch 2 times, most recently from da68450 to 8e4b82f Compare September 22, 2026 14:15
@GrigoryPervakov
GrigoryPervakov force-pushed the pervakovg/query-param-user-identifier branch from 8e4b82f to 09b1f69 Compare September 28, 2026 13:44
@GrigoryPervakov
GrigoryPervakov added this pull request to the merge queue Sep 29, 2026
Merged via the queue into master with commit 35c44d6 Sep 29, 2026
149 checks passed
@GrigoryPervakov
GrigoryPervakov deleted the pervakovg/query-param-user-identifier branch September 29, 2026 15:48
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 29, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 10, 2026
The load-time check `checkAccessEntityHasNoQueryParameters` uses
`analyzeReceiveQueryParams`, which now also visits row policy filters and
masking policy expressions. A row policy stored by an older version with an
unsubstituted parameter in its filter (`USING k = {x:UInt64}`) was then
rejected while loading the access storage:

- on a normal restart every query of every user failed with
  INCORRECT_ACCESS_ENTITY_DEFINITION, because the row policy cache reads all
  policies;
- on a rebuild of the lists (`need_rebuild_lists.mark`, SYSTEM RELOAD USERS)
  the policy was skipped and dropped from the lists, so the rows it hid
  became readable.

Skip policy definitions in that check, as before: such a policy loads again
and reading its table fails with UNKNOWN_QUERY_PARAMETER.

Found by the AI review of ClickHouse#122688 after the merge with ClickHouse#109696.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Identifier query parameters work with CREATE USER but fail with CREATE ROLE

5 participants