mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Don't allow to drop or rename version column
This commit is contained in:
parent
420f2958e2
commit
891fce3275
@ -1490,8 +1490,10 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
|
||||
getPartitionIDFromQuery(command.partition, global_context);
|
||||
}
|
||||
|
||||
if (command.column_name == merging_params.version_column)
|
||||
{
|
||||
/// Some type changes for version column is allowed despite it's a part of sorting key
|
||||
if (command.type == AlterCommand::MODIFY_COLUMN && command.column_name == merging_params.version_column)
|
||||
if (command.type == AlterCommand::MODIFY_COLUMN)
|
||||
{
|
||||
const IDataType * new_type = command.data_type.get();
|
||||
const IDataType * old_type = old_types[command.column_name];
|
||||
@ -1501,6 +1503,19 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
|
||||
/// No other checks required
|
||||
continue;
|
||||
}
|
||||
else if (command.type == AlterCommand::DROP_COLUMN)
|
||||
{
|
||||
throw Exception(
|
||||
"Trying to ALTER DROP version " + backQuoteIfNeed(command.column_name) + " column",
|
||||
ErrorCodes::ALTER_OF_COLUMN_IS_FORBIDDEN);
|
||||
}
|
||||
else if (command.type == AlterCommand::RENAME_COLUMN)
|
||||
{
|
||||
throw Exception(
|
||||
"Trying to ALTER RENAME version " + backQuoteIfNeed(command.column_name) + " column",
|
||||
ErrorCodes::ALTER_OF_COLUMN_IS_FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
if (command.type == AlterCommand::MODIFY_ORDER_BY && !is_custom_partitioned)
|
||||
{
|
||||
|
@ -0,0 +1 @@
|
||||
1 1 1
|
23
tests/queries/0_stateless/01714_alter_drop_version.sql
Normal file
23
tests/queries/0_stateless/01714_alter_drop_version.sql
Normal file
@ -0,0 +1,23 @@
|
||||
DROP TABLE IF EXISTS alter_drop_version;
|
||||
|
||||
CREATE TABLE alter_drop_version
|
||||
(
|
||||
`key` UInt64,
|
||||
`value` String,
|
||||
`ver` Int8
|
||||
)
|
||||
ENGINE = ReplacingMergeTree(ver)
|
||||
ORDER BY key;
|
||||
|
||||
INSERT INTO alter_drop_version VALUES (1, '1', 1);
|
||||
|
||||
ALTER TABLE alter_drop_version DROP COLUMN ver; --{serverError 524}
|
||||
ALTER TABLE alter_drop_version RENAME COLUMN ver TO rev; --{serverError 524}
|
||||
|
||||
DETACH TABLE alter_drop_version;
|
||||
|
||||
ATTACH TABLE alter_drop_version;
|
||||
|
||||
SELECT * FROM alter_drop_version;
|
||||
|
||||
DROP TABLE IF EXISTS alter_drop_version;
|
Loading…
Reference in New Issue
Block a user