Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#40312
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
qw4990 authored and ti-chi-bot committed Jan 18, 2023
1 parent 77cea7a commit 1537fe4
Show file tree
Hide file tree
Showing 2 changed files with 467 additions and 0 deletions.
7 changes: 7 additions & 0 deletions planner/core/expression_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,7 @@ func (er *expressionRewriter) inToExpression(lLen int, not bool, tp *types.Field
if c, ok := args[i].(*expression.Constant); ok {
var isExceptional bool
if expression.MaybeOverOptimized4PlanCache(er.sctx, []expression.Expression{c}) {
<<<<<<< HEAD
if c.GetType().EvalType() == types.ETString {
// To keep the result be compatible with MySQL, refine `int non-constant <cmp> str constant`
// here and skip this refine operation in all other cases for safety.
Expand All @@ -1495,6 +1496,12 @@ func (er *expressionRewriter) inToExpression(lLen int, not bool, tp *types.Field
}
} else if er.sctx.GetSessionVars().StmtCtx.SkipPlanCache {
// We should remove the mutable constant for correctness, because its value may be changed.
=======
if c.GetType().EvalType() == types.ETInt {
continue // no need to refine it
}
er.sctx.GetSessionVars().StmtCtx.SetSkipPlanCache(errors.Errorf("skip plan-cache: '%v' may be converted to INT", c.String()))
>>>>>>> be112dc31d (planner: skip plan-cache for prepared queries with `INT in (Decimals...)` (#40312))
expression.RemoveMutableConst(er.sctx, []expression.Expression{c})
}
args[i], isExceptional = expression.RefineComparedConstant(er.sctx, *leftFt, c, opcode.EQ)
Expand Down
Loading

0 comments on commit 1537fe4

Please sign in to comment.