Skip to content
Snippets Groups Projects
Commit 277d570e authored by Arseniy Volynets's avatar Arseniy Volynets :boy_tone5:
Browse files

fix: wrong hash calculation of plan subtree

- We didn't traverse output during subtree
traversal when calculating hash. Some nodes
(Motion, Projection) store non-trivial
information, which allows to distinguish
different plans. We came across this by
collision between two different queries:
```
SELECT w.n FROM t JOIN w ON t.n = w.n
LIMIT 3

SELECT id, count(*) FROM t
GROUP BY id
HAVING id > 2
LIMIT 3
```
These plan happened to have subtrees that match
exactly except for output of projection, that
we didn't traverse.

- fix this by traversing subtree fully
parent 07574e00
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -1834,7 +1834,7 @@ impl Plan {
/// # Errors
/// - serialization error (to binary)
pub fn pattern_id(&self, top_id: NodeId) -> Result<SmolStr, SbroadError> {
let mut dfs = PostOrder::with_capacity(|x| self.subtree_iter(x, false), self.nodes.len());
let mut dfs = PostOrder::with_capacity(|x| self.subtree_iter(x, true), self.nodes.len());
dfs.populate_nodes(top_id);
let nodes = dfs.take_nodes();
let mut plan_nodes: Vec<Node> = Vec::with_capacity(nodes.len());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment