Add check whether enums have the same underlying type or not

This commit is contained in:
Dmitry Novik 2021-08-23 17:55:21 +03:00
parent ac2e9a27e6
commit 6dad70a1fb
3 changed files with 15 additions and 1 deletions

View File

@ -501,7 +501,9 @@ namespace
if (!which.isEnum())
return false;
IDataTypeEnum const* enum_type = dynamic_cast<IDataTypeEnum const*>(lhs);
return enum_type->contains(*rhs);
if (!enum_type->contains(*rhs))
return false;
return enum_type->getMaximumSizeOfValueInMemory() == rhs->getMaximumSizeOfValueInMemory();
}
}

View File

@ -0,0 +1,12 @@
drop table if exists enum_alter_issue;
create table enum_alter_issue (a Enum16('one' = 1, 'two' = 2), b Int)
engine = ReplicatedMergeTree('/clickhouse/tables/{database}/test_02012/enum_alter_issue', 'r2')
ORDER BY b;
insert into enum_alter_issue values ('one', 1), ('two', 1);
alter table enum_alter_issue detach partition id 'all';
alter table enum_alter_issue modify column a Enum8('one' = 1, 'two' = 2, 'three' = 3);
insert into enum_alter_issue values ('one', 1), ('two', 1);
alter table enum_alter_issue attach partition id 'all'; -- {serverError TYPE_MISMATCH}
drop table enum_alter_issue;