Skip to content

Commit

Permalink
semantics: Fix missing union pop from scoper (#14401)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink authored Oct 31, 2023
1 parent 45180f4 commit ae2c8ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions go/vt/vtgate/semantics/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@ func TestOrderByBindingTable(t *testing.T) {
}, {
"select a.id from t1 as a union (select uid from t2, t union (select name from t) order by 1) order by id",
MergeTableSets(TS0, TS1, TS3),
}, {
"select * from (SELECT c1, c2 FROM a UNION SELECT c1, c2 FROM b) AS u ORDER BY u.c1",
MergeTableSets(TS0, TS1),
}}
for _, tc := range tcases {
t.Run(tc.sql, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/semantics/scoper.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (s *scoper) up(cursor *sqlparser.Cursor) error {
if isParentSelectStatement(cursor) {
s.popScope()
}
case *sqlparser.Select, sqlparser.GroupBy, *sqlparser.Update, *sqlparser.Delete, *sqlparser.Insert:
case *sqlparser.Select, sqlparser.GroupBy, *sqlparser.Update, *sqlparser.Delete, *sqlparser.Insert, *sqlparser.Union:
id := EmptyTableSet()
for _, tableInfo := range s.currentScope().tables {
set := tableInfo.getTableSet(s.org)
Expand Down

0 comments on commit ae2c8ba

Please sign in to comment.