fix core dump when compile expression

This commit is contained in:
liuneng 2023-06-21 20:20:37 +08:00
parent bbd70932e2
commit e650a6094a
3 changed files with 9 additions and 2 deletions

View File

@ -123,9 +123,11 @@ llvm::Value * nativeCast(llvm::IRBuilderBase & b, const DataTypePtr & from_type,
}
else if (to_type->isNullable())
{
auto * from_native_type = toNativeType(b, from_type);
auto * to_native_type = toNativeType(b, to_type);
auto * inner = nativeCast(b, from_type, value, removeNullable(to_type));
return b.CreateInsertValue(llvm::Constant::getNullValue(from_native_type), inner, {0});
auto * res_ptr = b.CreateAlloca(to_native_type);
auto * res_value = b.CreateLoad(to_native_type, res_ptr);
return b.CreateInsertValue(res_value, inner, {0});
}
else
{

View File

@ -0,0 +1,4 @@
CREATE TABLE test (col1 Nullable(DOUBLE), col2 Nullable(DOUBLE), col3 DOUBLE) ENGINE=Memory;
insert into test values(1.0 , 2.0, 3.0);
select multiIf(col1 > 2, col2/col3, 4.0) from test SETTINGS min_count_to_compile_expression=0;