Skip to content

Commit

Permalink
changed the way we calculate dependencies for ExtractedSubqueries
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Oct 12, 2021
1 parent 41541b0 commit 2483b11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
9 changes: 0 additions & 9 deletions go/vt/vtgate/planbuilder/abstract/querygraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,6 @@ func (qg *QueryGraph) addJoinPredicates(ts semantics.TableSet, expr sqlparser.Ex

func (qg *QueryGraph) collectPredicate(predicate sqlparser.Expr, semTable *semantics.SemTable) error {
deps := semTable.RecursiveDeps(predicate)
extracted, ok := predicate.(*sqlparser.ExtractedSubquery)
if ok {
// we don't want to look at the subquery dependencies
if extracted.OtherSide == nil {
deps = semantics.SingleTableSet(0)
} else {
deps = semTable.RecursiveDeps(extracted.OtherSide)
}
}
switch deps.NumberOfTables() {
case 0:
qg.addNoDepsPredicate(predicate)
Expand Down
11 changes: 8 additions & 3 deletions go/vt/vtgate/semantics/semantic_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,15 @@ func (d ExprDependencies) Dependencies(expr sqlparser.Expr) (deps TableSet) {
return true, nil
}

set, found := d[expr]
if found {
deps.MergeInPlace(set)
if extracted, ok := expr.(*sqlparser.ExtractedSubquery); ok {
if extracted.OtherSide != nil {
set := d.Dependencies(extracted.OtherSide)
deps.MergeInPlace(set)
}
return false, nil
}
set, found := d[expr]
deps.MergeInPlace(set)

// if we found a cached value, there is no need to continue down to visit children
return !found, nil
Expand Down

0 comments on commit 2483b11

Please sign in to comment.