Repository navigation
Execute Alter Commands in Order of Declaration - #100288
Conversation
|
Workflow [PR], commit [3bc6891] Summary: ✅ AI ReviewSummaryThis PR refactors Missing context
Findings💡 Nits
ClickHouse Rules
Final Verdict
|
…ickHouse into force_alter_commands_order
| return; | ||
|
|
||
| if (segments.size() != 1) | ||
| throw Exception(ErrorCodes::QUERY_IS_PROHIBITED, |
There was a problem hiding this comment.
This refactor changes the error code for replicated-database mixed ALTER segments from NOT_IMPLEMENTED (old behavior) to QUERY_IS_PROHIBITED.
That is externally visible and can break clients/tests that key off stable error codes. Unless this semantic change is intentional and documented, please keep NOT_IMPLEMENTED here to preserve backward compatibility.
| @@ -6,31 +6,16 @@ | |||
| -- succeed together or fail together. | |||
| -- The fix rejects UPDATE + RENAME on the same column early to ensure atomicity. | |||
There was a problem hiding this comment.
The test comment at the top still says this fix "rejects UPDATE + RENAME on the same column early" and enforces atomicity, but the updated query/reference below now allow that pattern and validate partial execution order (1\t1, renamed column c1).
Please update the test description to match the current expected behavior, otherwise this test is misleading for future maintainers.
LLVM Coverage Report
Changed lines: 75.11% (169/225) · Uncovered code |
After the refactor in PR ClickHouse#100288, the `allow_statistics` enforcement was moved to `MutationsInterpreter::prepare()`. However, `ADD STATISTICS` and `DROP STATISTICS` are routed as `AlterCommands`, not `MutationCommands`, so they never reached the new check. Re-add the check in `AlterCommands::validate()` so that all three ALTER STATISTICS commands respect `allow_statistics=0`. Closes ClickHouse#101082
|
Hi @Michicosun @azat — this PR appears to contain a backward incompatible change but is categorized as Why: PR changes the execution order of mixed ALTER commands from 'always alter before mutation regardless of declaration order' to 'declaration order'. Existing user queries like Suggested category: Could you check if the changelog category should be updated? This helps users know what to expect when upgrading. Ignore this if the change is intentionally non-breaking. |
|
Hi @Michicosun @azat — while reviewing this PR I found the following:
Could you review the test PR and add the |
|
This should fail This should not (For table |
|
@azat You're absolutely right — I just verified this on the running server: CREATE TABLE t (ts DateTime('UTC'), data String) ENGINE = MergeTree ORDER BY ts;
-- This fails (error 80: Cannot MATERIALIZE TTL as there is no TTL set)
ALTER TABLE t MATERIALIZE TTL, MODIFY TTL ts + INTERVAL 30 DAY;
-- This works correctly
ALTER TABLE t MODIFY TTL ts + INTERVAL 30 DAY, MATERIALIZE TTL;The "declaration order" semantics from this PR are actually the correct behavior — My original backward-compatibility concern was based on a misunderstanding — I was thinking the old behavior silently reordered commands to "make them work," but that would have masked logical errors. The PR's behavior (execute in declaration order) gives users correct, predictable semantics. Withdrawing that concern. Thanks for the correction. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
This patch fixes the execution of the alter command by forbidding command reordering.
Better fix for #96022
Version info
26.4.1.361