mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Better test and correct access rights
This commit is contained in:
parent
4902346f86
commit
763669f3dc
@ -274,7 +274,17 @@ private:
|
||||
comment_column->aliases.push_back("ALTER COMMENT COLUMN");
|
||||
auto clear_column = std::make_unique<Node>("CLEAR COLUMN", next_flag++, COLUMN);
|
||||
clear_column->aliases.push_back("ALTER CLEAR COLUMN");
|
||||
auto alter_column = std::make_unique<Node>("ALTER COLUMN", std::move(add_column), std::move(modify_column), std::move(drop_column), std::move(comment_column), std::move(clear_column));
|
||||
auto rename_column = std::make_unique<Node>("RENAME COLUMN", next_flag++, COLUMN);
|
||||
rename_column->aliases.push_back("ALTER RENAME COLUMN");
|
||||
|
||||
auto alter_column = std::make_unique<Node>(
|
||||
"ALTER COLUMN",
|
||||
std::move(add_column),
|
||||
std::move(modify_column),
|
||||
std::move(drop_column),
|
||||
std::move(comment_column),
|
||||
std::move(clear_column),
|
||||
std::move(rename_column));
|
||||
|
||||
auto alter_order_by = std::make_unique<Node>("ALTER ORDER BY", next_flag++, TABLE);
|
||||
alter_order_by->aliases.push_back("MODIFY ORDER BY");
|
||||
|
@ -30,6 +30,7 @@ enum class AccessType
|
||||
MODIFY_COLUMN,
|
||||
COMMENT_COLUMN,
|
||||
CLEAR_COLUMN,
|
||||
RENAME_COLUMN,
|
||||
ALTER_COLUMN, /// allow to execute ALTER {ADD|DROP|MODIFY...} COLUMN
|
||||
|
||||
ALTER_ORDER_BY,
|
||||
@ -197,6 +198,7 @@ namespace impl
|
||||
ACCESS_TYPE_TO_KEYWORD_CASE(MODIFY_COLUMN);
|
||||
ACCESS_TYPE_TO_KEYWORD_CASE(COMMENT_COLUMN);
|
||||
ACCESS_TYPE_TO_KEYWORD_CASE(CLEAR_COLUMN);
|
||||
ACCESS_TYPE_TO_KEYWORD_CASE(RENAME_COLUMN);
|
||||
ACCESS_TYPE_TO_KEYWORD_CASE(ALTER_COLUMN);
|
||||
|
||||
ACCESS_TYPE_TO_KEYWORD_CASE(ALTER_ORDER_BY);
|
||||
|
@ -282,6 +282,7 @@ AccessRightsElements InterpreterAlterQuery::getRequiredAccessForCommand(const AS
|
||||
}
|
||||
case ASTAlterCommand::RENAME_COLUMN:
|
||||
{
|
||||
required_access.emplace_back(AccessType::RENAME_COLUMN, database, table, column_name());
|
||||
break;
|
||||
}
|
||||
case ASTAlterCommand::NO_TYPE: break;
|
||||
|
@ -4,3 +4,5 @@ CREATE TABLE default.table_for_rename_replicated (`date` Date, `key` UInt64, `re
|
||||
1
|
||||
date key renamed_value1 value2 value3
|
||||
2019-10-02 1 1 1 1
|
||||
date key renamed_value1 value2 value3
|
||||
2019-10-02 1 1 1 1
|
||||
|
52
tests/queries/0_stateless/01213_alter_rename_column_zookeeper.sh
Executable file
52
tests/queries/0_stateless/01213_alter_rename_column_zookeeper.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS table_for_rename_replicated"
|
||||
|
||||
$CLICKHOUSE_CLIENT -n --query "
|
||||
CREATE TABLE table_for_rename_replicated
|
||||
(
|
||||
date Date,
|
||||
key UInt64,
|
||||
value1 String,
|
||||
value2 String,
|
||||
value3 String
|
||||
)
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/table_for_rename_replicated', '1')
|
||||
PARTITION BY date
|
||||
ORDER BY key;
|
||||
"
|
||||
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "INSERT INTO table_for_rename_replicated SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number), toString(number) from numbers(9);"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SELECT value1 FROM table_for_rename_replicated WHERE key = 1;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SYSTEM STOP MERGES;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SHOW CREATE TABLE table_for_rename_replicated;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "ALTER TABLE table_for_rename_replicated RENAME COLUMN value1 to renamed_value1" --replication_alter_partitions_sync=0
|
||||
|
||||
|
||||
while [[ -z $($CLICKHOUSE_CLIENT --query "SELECT name FROM system.columns WHERE name = 'renamed_value1' and table = 'table_for_rename_replicated'" 2>/dev/null) ]]; do
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
# RENAME on fly works
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SHOW CREATE TABLE table_for_rename_replicated;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SELECT renamed_value1 FROM table_for_rename_replicated WHERE key = 1;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SELECT * FROM table_for_rename_replicated WHERE key = 1 FORMAT TSVWithNames;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SYSTEM START MERGES;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SYSTEM SYNC REPLICA table_for_rename_replicated;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "SELECT * FROM table_for_rename_replicated WHERE key = 1 FORMAT TSVWithNames;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query "DROP TABLE IF EXISTS table_for_rename_replicated;"
|
@ -1,37 +0,0 @@
|
||||
DROP TABLE IF EXISTS table_for_rename_replicated;
|
||||
|
||||
|
||||
CREATE TABLE table_for_rename_replicated
|
||||
(
|
||||
date Date,
|
||||
key UInt64,
|
||||
value1 String,
|
||||
value2 String,
|
||||
value3 String
|
||||
)
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/table_for_rename_replicated', '1')
|
||||
PARTITION BY date
|
||||
ORDER BY key;
|
||||
|
||||
|
||||
INSERT INTO table_for_rename_replicated SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number), toString(number) from numbers(9);
|
||||
|
||||
SELECT value1 FROM table_for_rename_replicated WHERE key = 1;
|
||||
|
||||
SYSTEM STOP MERGES;
|
||||
|
||||
SHOW CREATE TABLE table_for_rename_replicated;
|
||||
|
||||
ALTER TABLE table_for_rename_replicated RENAME COLUMN value1 to renamed_value1 SETTINGS replication_alter_partitions_sync = 0;
|
||||
|
||||
SELECT sleep(2) FORMAT Null;
|
||||
|
||||
SHOW CREATE TABLE table_for_rename_replicated;
|
||||
|
||||
SELECT renamed_value1 FROM table_for_rename_replicated WHERE key = 1;
|
||||
|
||||
SELECT * FROM table_for_rename_replicated WHERE key = 1 FORMAT TSVWithNames;
|
||||
|
||||
SYSTEM START MERGES;
|
||||
|
||||
DROP TABLE IF EXISTS table_for_rename_replicated;
|
Loading…
Reference in New Issue
Block a user