mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #64957 from ClickHouse/pufit/fix-alter-query-clone
Fix alter query clone with SQL security
This commit is contained in:
commit
762c91a073
@ -60,6 +60,8 @@ ASTPtr ASTAlterCommand::clone() const
|
||||
res->settings_resets = res->children.emplace_back(settings_resets->clone()).get();
|
||||
if (select)
|
||||
res->select = res->children.emplace_back(select->clone()).get();
|
||||
if (sql_security)
|
||||
res->sql_security = res->children.emplace_back(sql_security->clone()).get();
|
||||
if (rename_to)
|
||||
res->rename_to = res->children.emplace_back(rename_to->clone()).get();
|
||||
|
||||
@ -522,6 +524,7 @@ void ASTAlterCommand::forEachPointerToChild(std::function<void(void**)> f)
|
||||
f(reinterpret_cast<void **>(&settings_changes));
|
||||
f(reinterpret_cast<void **>(&settings_resets));
|
||||
f(reinterpret_cast<void **>(&select));
|
||||
f(reinterpret_cast<void **>(&sql_security));
|
||||
f(reinterpret_cast<void **>(&rename_to));
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ namespace DB
|
||||
|
||||
void ASTSQLSecurity::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||
{
|
||||
if (!type.has_value())
|
||||
if (!type)
|
||||
return;
|
||||
|
||||
if (definer || is_definer_current_user)
|
||||
|
@ -35,5 +35,8 @@ OK
|
||||
2 2
|
||||
6 6
|
||||
9 9
|
||||
===== TestInsertChain =====
|
||||
1000
|
||||
1000
|
||||
===== TestOnCluster =====
|
||||
1
|
||||
|
@ -260,6 +260,8 @@ EOF
|
||||
|
||||
${CLICKHOUSE_CLIENT} --user $user2 --query "SELECT * FROM $db.test_mv_row_2"
|
||||
|
||||
echo "===== TestInsertChain ====="
|
||||
|
||||
${CLICKHOUSE_CLIENT} --multiquery <<EOF
|
||||
CREATE TABLE $db.session_events(
|
||||
clientId UUID,
|
||||
@ -299,4 +301,16 @@ ${CLICKHOUSE_CLIENT} --user $user3 --query "INSERT INTO $db.session_events SELEC
|
||||
${CLICKHOUSE_CLIENT} --user $user3 --query "SELECT count(*) FROM session_events"
|
||||
${CLICKHOUSE_CLIENT} --query "SELECT count(*) FROM materialized_events"
|
||||
|
||||
echo "===== TestOnCluster ====="
|
||||
${CLICKHOUSE_CLIENT} --multiquery <<EOF
|
||||
|
||||
CREATE TABLE $db.test_cluster ON CLUSTER test_shard_localhost (a String) Engine = MergeTree() ORDER BY a FORMAT Null;
|
||||
CREATE TABLE $db.test_cluster_2 ON CLUSTER test_shard_localhost (a String) Engine = MergeTree() ORDER BY a FORMAT Null;
|
||||
CREATE MATERIALIZED VIEW $db.cluster_mv ON CLUSTER test_shard_localhost TO $db.test_cluster_2 AS SELECT * FROM $db.test_cluster FORMAT Null;
|
||||
ALTER TABLE $db.cluster_mv ON CLUSTER test_shard_localhost MODIFY DEFINER = $user3 FORMAT Null;
|
||||
EOF
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query "SHOW CREATE TABLE $db.cluster_mv" | grep -c "DEFINER = $user3"
|
||||
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS $user1, $user2, $user3";
|
||||
|
Loading…
Reference in New Issue
Block a user