Merge pull request #70405 from ClickHouse/backport/24.8/70354

Backport #70354 to 24.8: Fix `MODIFY COLUMN MODIFY SETTINGS` crash for special columns
This commit is contained in:
robot-ch-test-poll1 2024-10-05 13:32:07 +04:00 committed by GitHub
commit 577a82cc32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -884,7 +884,15 @@ void checkSpecialColumn(const std::string_view column_meta_name, const AlterComm
{
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(
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 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 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 }