Fixed segfault in compare operators with Nullable types. #1416 [#CLICKHOUSE-3]

This commit is contained in:
Vitaliy Lyudvichenko 2017-10-27 22:48:11 +03:00 committed by alexey-milovidov
parent 4dd1634772
commit cd5d1d5009
4 changed files with 8 additions and 11 deletions

View File

@ -100,7 +100,7 @@ Block createBlockWithNestedColumns(const Block & block, ColumnNumbers args, size
if (col.type->isNullable())
{
bool is_const = col.column->isConst();
auto const_col = static_cast<const ColumnConst *>(col.column.get());
auto const_col = typeid_cast<const ColumnConst *>(col.column.get());
if (is_const && !const_col->getDataColumn().isNullable())
throw Exception("Column at position " + toString(i + 1) + " with type " + col.type->getName() +

View File

@ -204,17 +204,12 @@ bool defaultImplementationForNulls(
const ColumnWithTypeAndName & source_col = temporary_block.getByPosition(result);
ColumnWithTypeAndName & dest_col = block.getByPosition(result);
if (source_col.column->isConst())
dest_col.column = source_col.column;
else
{
/// Initialize the result column.
ColumnPtr null_map = std::make_shared<ColumnUInt8>(block.rows(), 0);
dest_col.column = std::make_shared<ColumnNullable>(source_col.column, null_map);
/// Initialize the result column.
ColumnPtr null_map = std::make_shared<ColumnUInt8>(block.rows(), 0);
dest_col.column = std::make_shared<ColumnNullable>(source_col.column, null_map);
/// Deduce the null map of the result from the null maps of the nullable columns.
createNullMap(block, args, result);
}
/// Deduce the null map of the result from the null maps of the nullable columns.
createNullMap(block, args, result);
return true;
}

View File

@ -1,2 +1,3 @@
SELECT CAST(1 AS Nullable(UInt8)) AS id WHERE id = CAST(1 AS Nullable(UInt8));
SELECT CAST(1 AS Nullable(UInt8)) AS id WHERE id = 1;
SELECT NULL == CAST(toUInt8(0) AS Nullable(UInt8));