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
9 changes: 9 additions & 0 deletions enginetest/queries/join_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,15 @@ LATERAL (
{1, 2, 1, 2, 0, 3, 1, 1, 0, 111},
},
},
{
Query: `select * from ab ab1 join lateral (select * from ab ab2 join lateral (select col < ab1.b from ab ab3 join three_pk where pk1 = ab1.a and pk2 = ab2.a and pk3 = ab3.a) inner2) inner3;`,
Expected: []sql.Row{
{0, 3, 0, 3, false},
{0, 3, 1, 2, false},
{1, 2, 0, 3, false},
{1, 2, 1, 2, false},
},
},
{
Query: `select * from ab ab1 where exists (select * from ab ab2 where exists (select * from three_pk where pk1 = ab1.a and pk2 = ab2.a));`,
Expected: []sql.Row{
Expand Down
6 changes: 4 additions & 2 deletions sql/analyzer/fix_exec_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,10 @@ func (s *idxScope) finalizeSelf(n sql.Node) (sql.Node, error) {
if len(s.parentScopes) == 0 {
return n, nil
}
// TODO: combine scopes?
scopeLen := len(s.parentScopes[0].columns)
scopeLen := 0
for _, parentScope := range s.parentScopes {
scopeLen += len(parentScope.columns)
}
if scopeLen == 0 {
return n, nil
}
Expand Down