mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Fix possible nullptr in HashJoin::correctNullability
This commit is contained in:
parent
0162632275
commit
312586df97
@ -178,7 +178,7 @@ namespace JoinStuff
|
||||
}
|
||||
}
|
||||
|
||||
static ColumnWithTypeAndName correctNullability(ColumnWithTypeAndName && column, bool nullable)
|
||||
static void correctNullabilityInplace(ColumnWithTypeAndName & column, bool nullable)
|
||||
{
|
||||
if (nullable)
|
||||
{
|
||||
@ -193,11 +193,9 @@ static ColumnWithTypeAndName correctNullability(ColumnWithTypeAndName && column,
|
||||
|
||||
JoinCommon::removeColumnNullability(column);
|
||||
}
|
||||
|
||||
return std::move(column);
|
||||
}
|
||||
|
||||
static ColumnWithTypeAndName correctNullability(ColumnWithTypeAndName && column, bool nullable, const ColumnUInt8 & negative_null_map)
|
||||
static void correctNullabilityInplace(ColumnWithTypeAndName & column, bool nullable, const ColumnUInt8 & negative_null_map)
|
||||
{
|
||||
if (nullable)
|
||||
{
|
||||
@ -211,8 +209,6 @@ static ColumnWithTypeAndName correctNullability(ColumnWithTypeAndName && column,
|
||||
}
|
||||
else
|
||||
JoinCommon::removeColumnNullability(column);
|
||||
|
||||
return std::move(column);
|
||||
}
|
||||
|
||||
HashJoin::HashJoin(std::shared_ptr<TableJoin> table_join_, const Block & right_sample_block_, bool any_take_last_row_)
|
||||
@ -1475,7 +1471,7 @@ void HashJoin::joinBlockImpl(
|
||||
ColumnWithTypeAndName right_col(col.column, col.type, right_col_name);
|
||||
if (right_col.type->lowCardinality() != right_key.type->lowCardinality())
|
||||
JoinCommon::changeLowCardinalityInplace(right_col);
|
||||
right_col = correctNullability(std::move(right_col), is_nullable);
|
||||
correctNullabilityInplace(right_col, is_nullable);
|
||||
block.insert(std::move(right_col));
|
||||
}
|
||||
}
|
||||
@ -1509,7 +1505,7 @@ void HashJoin::joinBlockImpl(
|
||||
ColumnWithTypeAndName right_col(thin_column, col.type, right_col_name);
|
||||
if (right_col.type->lowCardinality() != right_key.type->lowCardinality())
|
||||
JoinCommon::changeLowCardinalityInplace(right_col);
|
||||
right_col = correctNullability(std::move(right_col), is_nullable, null_map_filter);
|
||||
correctNullabilityInplace(right_col, is_nullable, null_map_filter);
|
||||
block.insert(std::move(right_col));
|
||||
|
||||
if constexpr (jf.need_replication)
|
||||
@ -2020,7 +2016,8 @@ BlocksList HashJoin::releaseJoinedBlocks()
|
||||
for (size_t i = 0; i < positions.size(); ++i)
|
||||
{
|
||||
auto & column = saved_block.getByPosition(positions[i]);
|
||||
restored_block.insert(correctNullability(std::move(column), is_nullable[i]));
|
||||
correctNullabilityInplace(column, is_nullable[i]);
|
||||
restored_block.insert(column);
|
||||
}
|
||||
restored_blocks.emplace_back(std::move(restored_block));
|
||||
}
|
||||
@ -2028,7 +2025,6 @@ BlocksList HashJoin::releaseJoinedBlocks()
|
||||
return restored_blocks;
|
||||
}
|
||||
|
||||
|
||||
const ColumnWithTypeAndName & HashJoin::rightAsofKeyColumn() const
|
||||
{
|
||||
/// It should be nullable when right side is nullable
|
||||
|
@ -0,0 +1 @@
|
||||
1 \N 1 \N
|
@ -0,0 +1,4 @@
|
||||
SELECT * FROM (SELECT 1 AS id, '' AS test) AS a
|
||||
LEFT JOIN (SELECT test, 1 AS id, NULL AS test) AS b ON b.id = a.id
|
||||
SETTINGS join_algorithm = 'auto', max_rows_in_join = 1, allow_experimental_analyzer = 1
|
||||
;
|
Loading…
Reference in New Issue
Block a user