Skip to content

Commit 4c576de

Browse files
XuHuaiyuti-srebot
authored andcommitted
cherry pick pingcap#21042 to release-4.0
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
1 parent c05d221 commit 4c576de

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
@@ -1452,3 +1452,13 @@ func (s *testIntegrationSuite) TestPartitionUnionWithPPruningColumn(c *C) {
14521452
"3290 LE1327_r5"))
14531453

14541454
}
1455+
1456+
func (s *testIntegrationSuite) TestIssue10448(c *C) {
1457+
tk := testkit.NewTestKit(c, s.store)
1458+
tk.MustExec("use test")
1459+
tk.MustExec("drop table if exists t;")
1460+
1461+
tk.MustExec("create table t(pk int(11) primary key)")
1462+
tk.MustExec("insert into t values(1),(2),(3)")
1463+
tk.MustQuery("select a from (select pk as a from t) t1 where a = 18446744073709551615").Check(testkit.Rows())
1464+
}

0 commit comments

Comments
 (0)