Repository navigation
Disable functions in readonly for inserts - #44290
Merged
nikitamikhaylov merged 4 commits intoJan 3, 2023
Merged
Conversation
Implementation: * Added a new parameter to ITableFunction::execute to check if query is insert query. * Used the new parameter in InterpreterInsertQuery::getTable function when calling ITableFunction::execute . Testing: * Added test case for INSERT in 02473_functions_in_readonly_mode.sh.
SmitaRKulkarni
marked this pull request as draft
December 15, 2022 18:52
SmitaRKulkarni
marked this pull request as ready for review
December 19, 2022 07:42
Member
|
AST Fuzzer (debug) - OOM while executing this query |
| $CLICKHOUSE_CLIENT --query="SELECT * from format('TSV', '123')" | ||
|
|
||
| $CLICKHOUSE_CLIENT --readonly=1 --query="SELECT * from numbers(1)" | ||
| $CLICKHOUSE_CLIENT --readonly=1 --query="SELECT * from format('TSV', '123')" 2>&1 | grep -Fq "Cannot execute query in readonly mode. (READONLY)" && echo 'ERROR' || echo 'OK' |
Member
There was a problem hiding this comment.
@SmitaRKulkarni Why can't we execute this query in readonly mode?
Member
Author
There was a problem hiding this comment.
Only certain functions are allowed in readonly mode (format is not one of them) : #42708
This is an existing test. I used the same test file, changed it's extension to .sh and appended new insert tests
nikitamikhaylov
approved these changes
Dec 29, 2022
jkartseva
pushed a commit
to lazerg/ClickHouse
that referenced
this pull request
Nov 19, 2026
…eadonly mode `readonly` and `allow_ddl` are enforced in `ContextAccess::checkAccessImplHelper` by a deny-list of requested access types. Three statements that change persistent state were missing from it: - `ALTER DATABASE ... MODIFY COMMENT` / `MODIFY SETTING` request the children of `ALTER_DATABASE`, which `table_ddl` did not contain, so they ran at `readonly = 1`, `readonly = 2`, over HTTP GET and with `allow_ddl = 0`. `ALTER_DATABASE` is now part of `table_ddl`, like `ALTER_TABLE` and `ALTER_VIEW`. - `KILL TRANSACTION` requests `KILL_TRANSACTION`, which was not in `not_readonly_flags` (`KILL_QUERY` is), so a read-only session could roll back another user's transaction. - `INSERT INTO FUNCTION` never requests `INSERT`; its only gated flag is `CREATE_TEMPORARY_TABLE` (forced for inserts by ClickHouse#44290), which `readonly = 2` allows on purpose for session temporary tables. So at `readonly = 2`, which is what HTTP GET runs with, `file()` wrote and overwrote files and `url()` sent the POST. The source `WRITE` flag is not added to the deny-list because it is also requested by `BACKUP` destinations (documented as not restricted by `readonly`), by `SELECT` from a `DatabaseS3` table and by `file()` reads with `rename_files_after_processing`, and a filtered `WRITE` grant does not reach the gate at all. Instead `InterpreterInsertQuery::getTable` refuses a table function insert under any `readonly`, with the gate's error text, before anything is resolved or written. Every table function insert (synchronous, asynchronous, parallel replicas) goes through it. The English documentation of these settings is updated, including two stale sentences (named collection management and `UNDROP TABLE` have been gated since ClickHouse#130952 and ClickHouse#131892). Related: ClickHouse#132330 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Disable functions in readonly for inserts
Implementation:
Testing: