Repository navigation
Cherry pick #133420 to 26.10: Require READ and WRITE ON FILE to create a table as filesystem(...) - #133692
Conversation
Since #129605 a table created as a table function needs `TABLE ENGINE` on the function's engine when that engine has a source, the same grant as `ENGINE = <engine>`. `filesystem` has no registered engine: it declares its source only through `ITableFunction::getSourceAccessObject()` (FILE), so the `StorageFactory` lookup missed and nothing was required. With an explicit column list the structure is not inferred, so the READ check of the inference never ran, and the table function was executed only for writing (`WRITE ON FILE`). `ON CLUSTER` and `Replicated` databases build the table with full access, so there no FILE grant was needed at all. `StorageFilesystem` reads with the global context, so a later `SELECT` checks only the table's grant: a user with `CREATE TABLE` and `WRITE ON FILE` (or nothing, via `ON CLUSTER`) could read every file under `user_files`. `getSourceEngineOfTableFunction` becomes `getRequiredAccessOfTableFunction` and returns the required element: `TABLE ENGINE` on a registered source engine (unchanged), nothing for a registered engine without a source (unchanged), and unfiltered `READ` and `WRITE` on the source a function declares when it has no engine. Those are the grants that imply `TABLE ENGINE` on a source engine, and the element `ATTACH ... FROM '<path>'` already requires. Both call sites, the local/ON CLUSTER/Replicated initiator in `getRequiredAccess` and the inherited function of `CREATE TABLE copy AS src` (also short `ATTACH` and local `RESTORE`), use it. `filesystem` is the only table function that overrides `getSourceAccessObject`. Behaviour change: a short `ATTACH` or local `RESTORE` of a table created as `filesystem(...)` now needs `READ` and `WRITE ON FILE`, as such a `File` table needs `TABLE ENGINE ON File`. Server startup and replicas are not affected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove an inline comment that repeated the function's doc comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…em-file-grants Require `READ` and `WRITE ON FILE` to create a table as `filesystem(...)`
Resolve the conflict in src/TableFunctions/ITableFunction.h: 26.10 keeps the protected isClusterFunction() next to the getSourceAccessObject() declaration that #133420 moves to the public section. 26.10 has a third caller of getSourceEngineOfTableFunction, the ON CLUSTER check of a definition inherited by CREATE TABLE copy AS src, added by the 26.10 backport of #129605 (#133147). Switch it to getRequiredAccessOfTableFunction like the other two callers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The only conflict is context: in 26.10 also has a third caller of On a 26.10 debug build of the resolved tree, I cannot push to |
Original pull-request #133420
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