Skip to content

Commit

Permalink
expression: remove useless HandleOverflowOnSelection (#50279)
Browse files Browse the repository at this point in the history
close #50278
  • Loading branch information
lcwangchao authored Jan 11, 2024
1 parent 62d4039 commit 22d2f6d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 22 deletions.
17 changes: 1 addition & 16 deletions pkg/expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,6 @@ func ExprNotNull(expr Expression) bool {
return mysql.HasNotNullFlag(expr.GetType().GetFlag())
}

// HandleOverflowOnSelection handles Overflow errors when evaluating selection filters.
// We should ignore overflow errors when evaluating selection conditions:
//
// INSERT INTO t VALUES ("999999999999999999");
// SELECT * FROM t WHERE v;
func HandleOverflowOnSelection(sc *stmtctx.StatementContext, val int64, err error) (int64, error) {
if sc.InSelectStmt && err != nil && types.ErrOverflow.Equal(err) {
return -1, nil
}
return val, err
}

// EvalBool evaluates expression list to a boolean value. The first returned value
// indicates bool result of the expression list, the second returned value indicates
// whether the result of the expression list is null, it can only be true when the
Expand All @@ -275,10 +263,7 @@ func EvalBool(ctx EvalContext, exprList CNFExprs, row chunk.Row) (bool, bool, er

i, err := data.ToBool(ctx.GetSessionVars().StmtCtx.TypeCtx())
if err != nil {
i, err = HandleOverflowOnSelection(ctx.GetSessionVars().StmtCtx, i, err)
if err != nil {
return false, false, err
}
return false, false, err
}
if i == 0 {
return false, false, nil
Expand Down
1 change: 0 additions & 1 deletion pkg/store/mockstore/mockcopr/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ func evalBool(exprs []expression.Expression, row []types.Datum, ctx sessionctx.C
}

isBool, err := data.ToBool(ctx.GetSessionVars().StmtCtx.TypeCtx())
isBool, err = expression.HandleOverflowOnSelection(ctx.GetSessionVars().StmtCtx, isBool, err)
if err != nil {
return false, errors.Trace(err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/store/mockstore/unistore/cophandler/closure_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ func (e *closureExecutor) processSelection(needCollectDetail bool) (gotRow bool,
gotRow = false
} else {
isTrue, err := d.ToBool(e.sctx.GetSessionVars().StmtCtx.TypeCtx())
isTrue, err = expression.HandleOverflowOnSelection(e.sctx.GetSessionVars().StmtCtx, isTrue, err)
if err != nil {
return false, errors.Trace(err)
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/store/mockstore/unistore/cophandler/mpp_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,10 +1143,6 @@ func (e *selExec) next() (*chunk.Chunk, error) {
if err != nil {
return nil, errors.Trace(err)
}
isBool, err = expression.HandleOverflowOnSelection(e.sctx.GetSessionVars().StmtCtx, isBool, err)
if err != nil {
return nil, errors.Trace(err)
}
passCheck = isBool != 0
}
if !passCheck {
Expand Down

0 comments on commit 22d2f6d

Please sign in to comment.