mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Merge pull request #43635 from Avogar/fix-fuzz
Fix possible use-of-unitialized value after executing expressions after sorting
This commit is contained in:
commit
606d2ea9b3
@ -1537,12 +1537,39 @@ ActionsDAG::SplitResult ActionsDAG::splitActionsBeforeArrayJoin(const NameSet &
|
||||
return res;
|
||||
}
|
||||
|
||||
ActionsDAG::NodeRawConstPtrs ActionsDAG::getParents(const Node * target) const
|
||||
{
|
||||
NodeRawConstPtrs parents;
|
||||
for (const auto & node : getNodes())
|
||||
{
|
||||
for (const auto & child : node.children)
|
||||
{
|
||||
if (child == target)
|
||||
{
|
||||
parents.push_back(&node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return parents;
|
||||
}
|
||||
|
||||
ActionsDAG::SplitResult ActionsDAG::splitActionsBySortingDescription(const NameSet & sort_columns) const
|
||||
{
|
||||
std::unordered_set<const Node *> split_nodes;
|
||||
for (const auto & sort_column : sort_columns)
|
||||
if (const auto * node = tryFindInOutputs(sort_column))
|
||||
{
|
||||
split_nodes.insert(node);
|
||||
/// Sorting can materialize const columns, so if we have const expression used in sorting,
|
||||
/// we should also add all it's parents, otherwise, we can break the header
|
||||
/// (function can expect const column, but will get materialized).
|
||||
if (node->column && isColumnConst(*node->column))
|
||||
{
|
||||
auto parents = getParents(node);
|
||||
split_nodes.insert(parents.begin(), parents.end());
|
||||
}
|
||||
}
|
||||
else
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Sorting column {} wasn't found in the ActionsDAG's outputs. DAG:\n{}",
|
||||
|
@ -343,6 +343,8 @@ public:
|
||||
const ContextPtr & context);
|
||||
|
||||
private:
|
||||
NodeRawConstPtrs getParents(const Node * target) const;
|
||||
|
||||
Node & addNode(Node node);
|
||||
|
||||
#if USE_EMBEDDED_COMPILER
|
||||
|
@ -0,0 +1,6 @@
|
||||
10000000001
|
||||
10000000002
|
||||
100000000010000000000
|
||||
100000000010000000000
|
||||
14
|
||||
15
|
@ -0,0 +1,9 @@
|
||||
set allow_suspicious_low_cardinality_types=1;
|
||||
drop table if exists test;
|
||||
create table test (x LowCardinality(Int32)) engine=Memory;
|
||||
insert into test select 1;
|
||||
insert into test select 2;
|
||||
select x + 1e10 from test order by 1e10, x;
|
||||
select x + (1e10 + 1e20) from test order by (1e10 + 1e20), x;
|
||||
select x + (pow(2, 2) + pow(3, 2)) from test order by (pow(2,2) + pow(3, 2)), x;
|
||||
drop table test;
|
Loading…
Reference in New Issue
Block a user