Skip to content

Commit 7254e73

Browse files
committed
update
Signed-off-by: Weizhen Wang <[email protected]>
1 parent 0ac6d80 commit 7254e73

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

pkg/expression/util.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,3 +2162,16 @@ func binaryDurationWithMS(pos int, paramValues []byte,
21622162
pos += 4
21632163
return pos, fmt.Sprintf("%s.%06d", dur, microSecond)
21642164
}
2165+
2166+
// IsConstFalse is used to check whether the expression is a constant false expression.
2167+
func IsConstFalse(expr Expression) bool {
2168+
if e, ok := expr.(*ScalarFunction); ok {
2169+
switch e.FuncName.L {
2170+
case ast.LT, ast.LE, ast.GT, ast.GE, ast.EQ, ast.NE:
2171+
if constExpr, ok := e.GetArgs()[1].(*Constant); ok && constExpr.Value.IsNull() && constExpr.DeferredExpr == nil {
2172+
return true
2173+
}
2174+
}
2175+
}
2176+
return false
2177+
}

pkg/planner/core/operator/logicalop/expression_util.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,13 @@ package logicalop
1616

1717
import (
1818
"github.com/pingcap/tidb/pkg/expression"
19-
"github.com/pingcap/tidb/pkg/parser/ast"
2019
"github.com/pingcap/tidb/pkg/planner/core/base"
2120
)
2221

23-
// isConstFalse is used to check whether the expression is a constant false expression.
24-
func isConstFalse(expr expression.Expression) bool {
25-
if e, ok := expr.(*expression.ScalarFunction); ok {
26-
switch e.FuncName.L {
27-
case ast.LT, ast.LE, ast.GT, ast.GE, ast.EQ, ast.NE:
28-
if constExpr, ok := e.GetArgs()[1].(*expression.Constant); ok && constExpr.Value.IsNull() && constExpr.DeferredExpr == nil {
29-
return true
30-
}
31-
}
32-
}
33-
return false
34-
}
35-
3622
// Conds2TableDual builds a LogicalTableDual if cond is constant false or null.
3723
func Conds2TableDual(p base.LogicalPlan, conds []expression.Expression) base.LogicalPlan {
3824
for _, cond := range conds {
39-
if isConstFalse(cond) {
25+
if expression.IsConstFalse(cond) {
4026
if expression.MaybeOverOptimized4PlanCache(p.SCtx().GetExprCtx(), conds) {
4127
return nil
4228
}

0 commit comments

Comments
 (0)