mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Fix infinite loop in dictGetHierarchy if id chain looped
This commit is contained in:
parent
7937903d56
commit
6ca798a357
@ -138,6 +138,11 @@ void CacheDictionary::isInImpl(
|
||||
out[out_idx] = 1;
|
||||
}
|
||||
/// Found intermediate parent, add this value to search at next loop iteration
|
||||
else if (children[new_children_idx] == parents[parents_idx])
|
||||
{
|
||||
// Loop detected
|
||||
out[out_idx] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
children[new_children_idx] = parents[parents_idx];
|
||||
|
@ -1431,9 +1431,16 @@ private:
|
||||
if (0 == id)
|
||||
continue;
|
||||
|
||||
|
||||
auto & hierarchy = hierarchies[i];
|
||||
|
||||
//Checking for loop
|
||||
if (std::find(std::begin(hierarchy), std::end(hierarchy), id) != std::end(hierarchy))
|
||||
continue;
|
||||
|
||||
all_zeroes = false;
|
||||
/// place id at it's corresponding place
|
||||
hierarchies[i].push_back(id);
|
||||
hierarchy.push_back(id);
|
||||
|
||||
++total_count;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user