Skip to content

Commit 6da1462

Browse files
committed
cleanup
1 parent 71df67c commit 6da1462

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

sql/memo/memo.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,20 @@ func (m *Memo) ApplyHint(hint Hint) {
528528
m.SetJoinOrder(hint.Args)
529529
case HintTypeJoinFixedOrder:
530530
case HintTypeNoMergeJoin:
531-
m.SetBlockOp(plan.JoinTypeMerge)
532-
m.SetBlockOp(plan.JoinTypeSemiMerge)
533-
m.SetBlockOp(plan.JoinTypeAntiMerge)
534-
m.SetBlockOp(plan.JoinTypeLeftOuterMerge)
531+
m.SetBlockOp(func(n RelExpr) bool {
532+
switch n := n.(type) {
533+
case JoinRel:
534+
jp := n.JoinPrivate()
535+
if !jp.Left.Best.Group().HintOk || !jp.Right.Best.Group().HintOk {
536+
// equiv closures can generate child plans that bypass hints
537+
return false
538+
}
539+
if jp.Op.IsMerge() {
540+
return false
541+
}
542+
}
543+
return true
544+
})
535545
case HintTypeInnerJoin, HintTypeMergeJoin, HintTypeLookupJoin, HintTypeHashJoin, HintTypeSemiJoin, HintTypeAntiJoin, HintTypeLeftOuterLookupJoin:
536546
m.SetJoinOp(hint.Typ, hint.Args[0], hint.Args[1])
537547
case HintTypeLeftDeep:
@@ -558,8 +568,8 @@ func (m *Memo) SetJoinOrder(tables []string) {
558568
}
559569
}
560570

561-
func (m *Memo) SetBlockOp(op plan.JoinType) {
562-
m.hints.block = append(m.hints.block, joinBlockHint{op: op})
571+
func (m *Memo) SetBlockOp(cb func(n RelExpr) bool) {
572+
m.hints.block = append(m.hints.block, joinBlockHint{cb: cb})
563573
}
564574

565575
func (m *Memo) SetJoinOp(op HintType, left, right string) {

sql/memo/select_hints.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,11 @@ func (o joinOpHint) typeMatches(n RelExpr) bool {
373373
}
374374

375375
type joinBlockHint struct {
376-
op plan.JoinType
376+
cb func(n RelExpr) bool
377377
}
378378

379379
func (o joinBlockHint) isOk(n RelExpr) bool {
380-
switch n := n.(type) {
381-
case JoinRel:
382-
jp := n.JoinPrivate()
383-
if !jp.Left.Best.Group().HintOk || !jp.Right.Best.Group().HintOk {
384-
// equiv closures can generate child plans that bypass hints
385-
return false
386-
}
387-
return !(jp.Op == o.op)
388-
}
389-
return true
380+
return o.cb(n)
390381
}
391382

392383
// joinHints wraps a collection of join hints. The memo

0 commit comments

Comments
 (0)