Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions enginetest/queries/query_plans.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions sql/analyzer/apply_indexes_from_outer_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ import (
// apply, effectively, an indexed join between two tables, one of which is defined in the outer scope. This is similar
// to the process in the join analyzer.
func applyIndexesFromOuterScope(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope, sel RuleSelector, qFlags *sql.QueryFlags) (sql.Node, transform.TreeIdentity, error) {
if scope.IsEmpty() {
return n, transform.SameTree, nil
}

// this isn't good enough: we need to consider aliases defined in the outer scope as well for this analysis
tableAliases, err := getTableAliases(n, scope)
if err != nil {
Expand Down Expand Up @@ -281,6 +277,11 @@ func tablesInScope(scope *plan.Scope) []string {
tables[col.Source] = true
}
}
for _, table := range scope.JoinSiblings() {
for name, _ := range getTablesByName(table) {
tables[name] = true
}
}
var tableSlice []string
for table := range tables {
tableSlice = append(tableSlice, table)
Expand Down
6 changes: 6 additions & 0 deletions sql/plan/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,15 @@ func (s *Scope) InInsertSource() bool {
}

func (s *Scope) JoinSiblings() []sql.Node {
if s == nil {
return nil
}
return s.joinSiblings
}

func (s *Scope) Correlated() sql.ColSet {
if s == nil {
return sql.ColSet{}
}
return s.corr
}