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
6 changes: 6 additions & 0 deletions enginetest/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -8655,6 +8655,12 @@ from typestable`,
{3, "third row"},
},
},
{
Query: "select * from (select 'k' as k) sq join bigtable on t = k join xy where x between n and n;",
Expected: []sql.Row{
{"k", "k", 1, 1, 0},
},
},
}

var KeylessQueries = []QueryTest{
Expand Down
48 changes: 48 additions & 0 deletions enginetest/queries/query_plans.go

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

23 changes: 23 additions & 0 deletions enginetest/queries/script_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -4880,6 +4880,29 @@ CREATE TABLE tab3 (
},
},
},
{
Name: "subquery with range heap join",
SetUpScript: []string{
"create table a (i int primary key, start int, end int, name varchar(32));",
"insert into a values (1, 603000, 605001, 'test');",
"create table b (i int primary key);",
"insert into b values (600000), (605000), (608000);",
},
Assertions: []ScriptTestAssertion{
{
Query: "select a.i from (select 'test' as name) sq join a on sq.name = a.name join b on b.i between a.start and a.end;",
Expected: []sql.Row{
{1},
},
},
{
Query: "select * from (select 'test' as name, 1 as x, 2 as y, 3 as z) sq join a on sq.name = a.name join b on b.i between a.start and a.end;",
Expected: []sql.Row{
{"test", 1, 2, 3, 1, 603000, 605001, "test", 605000},
},
},
},
},
}

var SpatialScriptTests = []ScriptTest{
Expand Down
3 changes: 1 addition & 2 deletions sql/analyzer/fix_exec_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,8 @@ func (s *idxScope) visitSelf(n sql.Node) error {
s.expressions = append(s.expressions, fixExprToScope(e, scopes...))
}
case *plan.RangeHeap:
siblingScope := s.lateralScopes[len(s.lateralScopes)-1]
// value indexes other side of join
newValue := fixExprToScope(n.ValueColumnGf, siblingScope)
newValue := fixExprToScope(n.ValueColumnGf, s.lateralScopes...)
// min/are this child
newMin := fixExprToScope(n.MinColumnGf, s.childScopes...)
newMax := fixExprToScope(n.MaxColumnGf, s.childScopes...)
Expand Down