Backport #70354 to 24.9: Fix MODIFY COLUMN MODIFY SETTINGS crash for special columns

This commit is contained in:
robot-clickhouse 2024-10-05 08:08:03 +00:00
parent 4336ee367c
commit ce59b6f09e
2 changed files with 10 additions and 1 deletions

View File

@ -908,7 +908,15 @@ void checkSpecialColumn(const std::string_view column_meta_name, const AlterComm
{ {
if (command.type == AlterCommand::MODIFY_COLUMN) if (command.type == AlterCommand::MODIFY_COLUMN)
{ {
if (!typeid_cast<const TMustHaveDataType *>(command.data_type.get())) if (!command.data_type)
{
throw Exception(
ErrorCodes::ALTER_OF_COLUMN_IS_FORBIDDEN,
"Trying to modify settings for column {} ({}) ",
column_meta_name,
command.column_name);
}
else if (!typeid_cast<const TMustHaveDataType *>(command.data_type.get()))
{ {
throw Exception( throw Exception(
ErrorCodes::ALTER_OF_COLUMN_IS_FORBIDDEN, ErrorCodes::ALTER_OF_COLUMN_IS_FORBIDDEN,

View File

@ -21,6 +21,7 @@ CREATE TABLE collapsing (key Int64, sign Int8) ENGINE = CollapsingMergeTree(sign
ALTER TABLE collapsing MODIFY COLUMN sign String; -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN } ALTER TABLE collapsing MODIFY COLUMN sign String; -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN }
ALTER TABLE collapsing DROP COLUMN sign; -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN } ALTER TABLE collapsing DROP COLUMN sign; -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN }
ALTER TABLE collapsing RENAME COLUMN sign TO sign2; -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN } ALTER TABLE collapsing RENAME COLUMN sign TO sign2; -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN }
ALTER TABLE collapsing MODIFY COLUMN sign MODIFY SETTING max_compress_block_size = 123456; -- { serverError ALTER_OF_COLUMN_IS_FORBIDDEN }
CREATE TABLE versioned_collapsing_wrong (key Int64, version UInt8, sign Int8) ENGINE = VersionedCollapsingMergeTree(sign, sign) ORDER BY key; -- { serverError BAD_ARGUMENTS } CREATE TABLE versioned_collapsing_wrong (key Int64, version UInt8, sign Int8) ENGINE = VersionedCollapsingMergeTree(sign, sign) ORDER BY key; -- { serverError BAD_ARGUMENTS }