Repository navigation
Cherry pick #128995 to 26.8: Check the TABLE ENGINE grant before ATTACH ... AS [NOT] REPLICATED converts a table - #132637
Merged
robot-ch-test-poll3 merged 5 commits intoNov 18, 2026
Conversation
…PLICATED` A user with only `CREATE TABLE` runs `ATTACH TABLE ... AS REPLICATED` and `ATTACH TABLE ... AS NOT REPLICATED` on detached tables. Each query is refused for the missing `TABLE ENGINE` grant on the engine the table would be converted to, and a later plain `ATTACH TABLE` must load every table with the engine it had before. With the grant on the converted engine, the conversion succeeds in both directions and keeps the data. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…CATED` changes anything A short `ATTACH` carries no engine, so `getRequiredAccess` requires only `CREATE TABLE`. The `TABLE ENGINE` grant on the converted engine was checked only after `convertMergeTreeTableIfPossible` had rewritten the stored metadata of the detached table and, for `AS REPLICATED`, removed the transaction metadata files of its parts. A refused query still changed the engine that a later plain `ATTACH TABLE` used. Check that the converted engine exists and that the grant on it is held before any of these changes. The converted name comes from the new `DatabaseOrdinary::getConvertedMergeTreeEngineName`, which `setMergeTreeEngine` uses as well, so the checked name and the stored one are the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the conversion precondition A grant such as `TABLE ENGINE ON *` covers an engine name that is not registered, so the registered-engine check before the `TABLE ENGINE` check is what keeps a conversion from writing a definition that cannot be attached; say so in the comment. `DatabaseOrdinary::getConvertedMergeTreeEngineName` now asserts that the name it strips starts with `Replicated`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-grant Check the `TABLE ENGINE` grant before `ATTACH ... AS [NOT] REPLICATED` converts a table
Keep the release branch side and apply only the fix of #128995: check the `TABLE ENGINE` grant on the converted engine in `convertMergeTreeTableIfPossible` before the side effects of `ATTACH ... AS [NOT] REPLICATED`. The master-only code next to the fix is not carried over: `isTableReadonlyAsReplicated` (#119224) and the `temporary_uuid` / `ordinary_znode_info` handling of `Ordinary` databases, none of which exist on 26.8, where the conversion supports `Atomic` only. Because of that the test is tagged `no-ordinary-database`, as `03169_attach_as_replicated`.
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.
Original pull-request #128995
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job