Skip to content
Open
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
16 changes: 0 additions & 16 deletions pkg/planner/core/exhaust_physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,11 +1107,6 @@ func buildIndexJoinInner2TableScan(
lastColMng = indexJoinResult.lastColManager
}
joins = make([]base.PhysicalPlan, 0, 3)
failpoint.Inject("MockOnlyEnableIndexHashJoin", func(val failpoint.Value) {
if val.(bool) && !p.SCtx().GetSessionVars().InRestrictedSQL {
failpoint.Return(constructIndexHashJoin(p, prop, outerIdx, innerTask, nil, keyOff2IdxOff, path, lastColMng))
}
})
joins = append(joins, constructIndexJoin(p, prop, outerIdx, innerTask, ranges, keyOff2IdxOff, path, lastColMng, true)...)
// We can reuse the `innerTask` here since index nested loop hash join
// do not need the inner child to promise the order.
Expand Down Expand Up @@ -1148,11 +1143,6 @@ func buildIndexJoinInner2IndexScan(
joins = make([]base.PhysicalPlan, 0, 3)
rangeInfo, maxOneRow := indexJoinPathGetRangeInfoAndMaxOneRow(p.SCtx(), outerJoinKeys, indexJoinResult)
innerTask := constructInnerIndexScanTask(p, prop, wrapper, indexJoinResult.chosenPath, indexJoinResult.chosenRanges.Range(), indexJoinResult.chosenRemained, indexJoinResult.idxOff2KeyOff, rangeInfo, false, false, avgInnerRowCnt, maxOneRow)
failpoint.Inject("MockOnlyEnableIndexHashJoin", func(val failpoint.Value) {
if val.(bool) && !p.SCtx().GetSessionVars().InRestrictedSQL && innerTask != nil {
failpoint.Return(constructIndexHashJoin(p, prop, outerIdx, innerTask, indexJoinResult.chosenRanges, keyOff2IdxOff, indexJoinResult.chosenPath, indexJoinResult.lastColManager))
}
})
if innerTask != nil {
joins = append(joins, constructIndexJoin(p, prop, outerIdx, innerTask, indexJoinResult.chosenRanges, keyOff2IdxOff, indexJoinResult.chosenPath, indexJoinResult.lastColManager, true)...)
// We can reuse the `innerTask` here since index nested loop hash join
Expand Down Expand Up @@ -2667,12 +2657,6 @@ func tryToGetMppHashJoin(super base.LogicalPlan, prop *property.PhysicalProperty
// If the hint is not figured, we will pick all candidates.
func exhaustPhysicalPlans4LogicalJoin(super base.LogicalPlan, prop *property.PhysicalProperty) ([]base.PhysicalPlan, bool, error) {
ge, p := base.GetGEAndLogicalOp[*logicalop.LogicalJoin](super)
failpoint.Inject("MockOnlyEnableIndexHashJoin", func(val failpoint.Value) {
if val.(bool) && !p.SCtx().GetSessionVars().InRestrictedSQL {
indexJoins, _ := tryToGetIndexJoin(p, prop)
failpoint.Return(indexJoins, true, nil)
}
})

if !isJoinHintSupportedInMPPMode(p.PreferJoinType) {
if hasMPPJoinHints(p.PreferJoinType) {
Expand Down
74 changes: 33 additions & 41 deletions pkg/util/ranger/detacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,51 +129,43 @@ func getPotentialEqOrInColOffset(sctx *rangerctx.RangerContext, expr expression.
}
return offset
case ast.EQ, ast.NullEQ, ast.LE, ast.GE, ast.LT, ast.GT:
if c, ok := f.GetArgs()[0].(*expression.Column); ok {
if c.RetType.EvalType() == types.ETString && !collate.CompatibleCollate(c.RetType.GetCollate(), collation) {
return -1
}
if (f.FuncName.L == ast.LT || f.FuncName.L == ast.GT) && c.RetType.EvalType() != types.ETInt {
var constVal *expression.Constant
c, ok := f.GetArgs()[0].(*expression.Column)
idxConst := 1
if !ok {
idxConst = 0
if c, ok = f.GetArgs()[1].(*expression.Column); !ok {
return -1
}
if constVal, ok := f.GetArgs()[1].(*expression.Constant); ok {
val, err := constVal.Eval(evalCtx, chunk.Row{})
intest.AssertFunc(func() bool {
if sctx.ExprCtx.ConnectionID() == 0 {
return sctx.RegardNULLAsPoint
}
return true
})
if err != nil || (!sctx.RegardNULLAsPoint && val.IsNull()) || (f.FuncName.L == ast.NullEQ && val.IsNull()) {
// treat col<=>null as range scan instead of point get to avoid incorrect results
// when nullable unique index has multiple matches for filter x is null
return -1
}
for i, col := range cols {
// When cols are a generated expression col, compare them in terms of virtual expr.
if col.EqualByExprAndID(evalCtx, c) {
return i
}
}
}
}
if c, ok := f.GetArgs()[1].(*expression.Column); ok {
if c.RetType.EvalType() == types.ETString && !collate.CompatibleCollate(c.RetType.GetCollate(), collation) {
return -1
}
if (f.FuncName.L == ast.LT || f.FuncName.L == ast.GT) && c.RetType.EvalType() != types.ETInt {
return -1

if c.RetType.EvalType() == types.ETString && !collate.CompatibleCollate(c.RetType.GetCollate(), collation) {
return -1
}
if (f.FuncName.L == ast.LT || f.FuncName.L == ast.GT) && c.RetType.EvalType() != types.ETInt {
return -1
}

if constVal, ok = f.GetArgs()[idxConst].(*expression.Constant); !ok {
return -1
}

val, err := constVal.Eval(evalCtx, chunk.Row{})
intest.AssertFunc(func() bool {
if sctx.ExprCtx.ConnectionID() == 0 {
return sctx.RegardNULLAsPoint
}
if constVal, ok := f.GetArgs()[0].(*expression.Constant); ok {
val, err := constVal.Eval(evalCtx, chunk.Row{})
if err != nil || (!sctx.RegardNULLAsPoint && val.IsNull()) {
return -1
}
for i, col := range cols {
if col.EqualColumn(c) {
return i
}
}
return true
})
if err != nil || (!sctx.RegardNULLAsPoint && val.IsNull()) || (f.FuncName.L == ast.NullEQ && val.IsNull()) {
// treat col<=>null as range scan instead of point get to avoid incorrect results
// when nullable unique index has multiple matches for filter x is null
return -1
}
for i, col := range cols {
// When cols are a generated expression col, compare them in terms of virtual expr.
if col.EqualByExprAndID(evalCtx, c) {
return i
}
}
case ast.In:
Expand Down
Loading