Skip to content

Commit 3181e61

Browse files
committed
rm union flag
1 parent 7d69398 commit 3181e61

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

sql/analyzer/costed_index_scan.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ func indexSearchableLookup(ctx *sql.Context, n sql.Node, rt sql.TableNode, looku
114114
ret = plan.NewFilter(newFilter, ret)
115115
}
116116

117-
if fds != nil && fds.HasMax1Row() && !qFlags.JoinIsSet() && !qFlags.SubqueryIsSet() && !qFlags.IsSet(sql.QFlagUnion) && lookup.Ranges.Len() == 1 {
118-
// Index lookup without join/subquery/union scope returns
117+
if fds != nil && fds.HasMax1Row() && !qFlags.JoinIsSet() && !qFlags.SubqueryIsSet() && lookup.Ranges.Len() == 1 {
118+
// Strict index lookup without a join or subquery scope will return
119119
// at most one row. We could also use some sort of scope counting
120120
// to check for single scope.
121121
qFlags.Set(sql.QFlagMax1Row)

sql/analyzer/resolve_unions.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ func resolveUnions(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope,
4141
subqueryCtx, cancelFunc := ctx.NewSubContext()
4242
defer cancelFunc()
4343

44-
// Prevent max1Row optimization in union branches
45-
qFlags.Set(sql.QFlagUnion)
46-
4744
left, _, err := a.analyzeThroughBatch(subqueryCtx, u.Left(), scope, "default-rules", sel, qFlags)
4845
if err != nil {
4946
return nil, transform.SameTree, err
@@ -82,9 +79,6 @@ func finalizeUnions(ctx *sql.Context, a *Analyzer, n sql.Node, scope *plan.Scope
8279
subqueryCtx, cancelFunc := ctx.NewSubContext()
8380
defer cancelFunc()
8481

85-
// Prevent max1Row optimization in union branches
86-
qFlags.Set(sql.QFlagUnion)
87-
8882
scope.SetJoin(false)
8983
// TODO we could detect tree modifications here, skip rebuilding
9084
left, _, err := a.analyzeStartingAtBatch(subqueryCtx, u.Left(), scope, "default-rules", NewFinalizeUnionSel(sel), qFlags)

sql/query_flags.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const (
4141
QFlagLimit
4242
QFlagInterval
4343
QFlagAnyAgg
44-
QFlagUnion
4544

4645
// QFlagMax1Row indicates that a query can only return at most one row
4746
QFlagMax1Row

0 commit comments

Comments
 (0)