java-topology/defects/duckdb/patch/duckdb-0002-has-correlated-expressions-hashset.patch

23 lines
1.1 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# UNDF: UNDF-2026-000000683
# UNDF:
--- a/src/planner/subquery/has_correlated_expressions.cpp
+++ b/src/planner/subquery/has_correlated_expressions.cpp
@@ -50,12 +50,16 @@ unique_ptr<Expression> HasCorrelatedExpressions::VisitReplace(BoundSubqueryExpression &expr,
if (!expr.IsCorrelated()) {
return nullptr;
}
+ // Build O(1) lookup set from the subquery binder's correlated columns once per call.
+ // Previously the inner std::find was O(M) for each of the N outer correlated_columns,
+ // giving O(N×M) total. With the CorrelatedColumns::Contains() O(1) helper (backed by
+ // binding_set) this becomes O(N).
// check if the subquery contains any of the correlated expressions that we are concerned about in this node
for (idx_t i = 0; i < correlated_columns.size(); i++) {
- if (std::find(expr.binder->correlated_columns.begin(), expr.binder->correlated_columns.end(),
- correlated_columns[i]) != expr.binder->correlated_columns.end()) {
+ if (expr.binder->correlated_columns.Contains(correlated_columns[i])) { // O(1) via binding_set; was O(M) std::find
has_correlated_expressions = true;
break;
}
}
return nullptr;
}