Skip to content

Commit e90aac7

Browse files
authored
plannr: build empty range for overflow predicate (#21042)
1 parent 83ceede commit e90aac7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

expression/builtin_compare.go

+12
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,18 @@ func (c *compareFunctionClass) refineArgsByUnsignedFlag(ctx sessionctx.Context,
13711371
if err != nil || isNull || v > 0 {
13721372
return args
13731373
}
1374+
if mysql.HasUnsignedFlag(con.RetType.Flag) && !mysql.HasUnsignedFlag(col.RetType.Flag) {
1375+
op := c.op
1376+
if i == 1 {
1377+
op = symmetricOp[c.op]
1378+
}
1379+
if op == opcode.EQ || op == opcode.NullEQ {
1380+
if _, err := types.ConvertUintToInt(uint64(v), types.IntergerSignedUpperBound(col.RetType.Tp), col.RetType.Tp); err != nil {
1381+
args[i], args[1-i] = NewOne(), NewZero()
1382+
return args
1383+
}
1384+
}
1385+
}
13741386
if mysql.HasUnsignedFlag(col.RetType.Flag) && mysql.HasNotNullFlag(col.RetType.Flag) && !mysql.HasUnsignedFlag(con.RetType.Flag) {
13751387
op := c.op
13761388
if i == 1 {

planner/core/integration_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -1822,3 +1822,13 @@ func (s *testIntegrationSuite) TestPartitionUnionWithPPruningColumn(c *C) {
18221822
"3290 LE1327_r5"))
18231823

18241824
}
1825+
1826+
func (s *testIntegrationSuite) TestIssue10448(c *C) {
1827+
tk := testkit.NewTestKit(c, s.store)
1828+
tk.MustExec("use test")
1829+
tk.MustExec("drop table if exists t;")
1830+
1831+
tk.MustExec("create table t(pk int(11) primary key)")
1832+
tk.MustExec("insert into t values(1),(2),(3)")
1833+
tk.MustQuery("select a from (select pk as a from t) t1 where a = 18446744073709551615").Check(testkit.Rows())
1834+
}

0 commit comments

Comments
 (0)