mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #40850 from canhld94/ch_canh_fix_set
Fix tryGetPreparedSet crash when same set expression built from different column(s)
This commit is contained in:
commit
fdcced8962
@ -403,7 +403,13 @@ void Set::checkColumnsNumber(size_t num_key_columns) const
|
||||
|
||||
bool Set::areTypesEqual(size_t set_type_idx, const DataTypePtr & other_type) const
|
||||
{
|
||||
return removeNullable(recursiveRemoveLowCardinality(data_types[set_type_idx]))->equals(*removeNullable(recursiveRemoveLowCardinality(other_type)));
|
||||
/// Out-of-bound access can happen when same set expression built with different columns.
|
||||
/// Caller may call this method to make sure that the set is indeed the one they want
|
||||
/// without awaring data_types.size().
|
||||
if (set_type_idx >= data_types.size())
|
||||
return false;
|
||||
return removeNullable(recursiveRemoveLowCardinality(data_types[set_type_idx]))
|
||||
->equals(*removeNullable(recursiveRemoveLowCardinality(other_type)));
|
||||
}
|
||||
|
||||
void Set::checkTypesEqual(size_t set_type_idx, const DataTypePtr & other_type) const
|
||||
|
@ -297,8 +297,10 @@ public:
|
||||
assert(indexes_mapping.size() == data_types.size());
|
||||
|
||||
for (size_t i = 0; i < indexes_mapping.size(); ++i)
|
||||
{
|
||||
if (!candidate_set->areTypesEqual(indexes_mapping[i].tuple_index, data_types[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,3 @@
|
||||
CREATE TABLE set_crash (key1 Int32, id1 Int64, c1 Int64) ENGINE = MergeTree PARTITION BY id1 ORDER BY key1;
|
||||
INSERT INTO set_crash VALUES (-1, 1, 0);
|
||||
SELECT 1 in (-1, 1) FROM set_crash WHERE (key1, id1) in (-1, 1);
|
Loading…
Reference in New Issue
Block a user