Merge pull request #9804 from azat/optimize_skip_unused_shards_type_mismatch

Fix SIGSEGV with optimize_skip_unused_shards when type cannot be converted
This commit is contained in:
alexey-milovidov 2020-03-23 02:06:58 +03:00 committed by GitHub
commit 3550f401ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -116,8 +116,10 @@ namespace
if (name == identifier->name)
{
ColumnWithTypeAndName column;
// FIXME: what to do if field is not convertable?
column.column = type->createColumnConst(1, convertFieldToType(literal->value, *type));
Field value = convertFieldToType(literal->value, *type);
if (!literal->value.isNull() && value.isNull())
return {};
column.column = type->createColumnConst(1, value);
column.name = name;
column.type = type;
return {{std::move(column)}};

View File

@ -0,0 +1,14 @@
set optimize_skip_unused_shards=1;
drop table if exists data_02000;
drop table if exists dist_02000;
create table data_02000 (key Int) Engine=Null();
create table dist_02000 as data_02000 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_02000, key);
select * from data_02000 where key = 0xdeadbeafdeadbeaf;
select * from dist_02000 where key = 0xdeadbeafdeadbeaf settings force_optimize_skip_unused_shards=2; -- { serverError 507; }
select * from dist_02000 where key = 0xdeadbeafdeadbeaf;
drop table data_02000;
drop table dist_02000;