@@ -54,7 +54,7 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) {
54
54
core .PreparedPlanCacheMaxMemory .Store (math .MaxUint64 )
55
55
tk .MustExec ("use test" )
56
56
tk .MustExec ("drop table if exists t" )
57
- tk .MustExec ("create table t(a int primary key, b int, c int, key idx_bc(b,c))" )
57
+ tk .MustExec ("create table t(a bigint unsigned primary key, b int, c int, key idx_bc(b,c))" )
58
58
tk .MustExec ("insert into t values(1, 1, 1), (2, 2, 2), (3, 3, 3)" )
59
59
tk .MustQuery ("explain select * from t where a = 1" ).Check (testkit .Rows (
60
60
"Point_Get_1 1.00 root table:t, handle:1" ,
@@ -68,6 +68,11 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) {
68
68
tk .MustQuery ("explain delete from t where a = 1" ).Check (testkit .Rows (
69
69
"Point_Get_1 1.00 root table:t, handle:1" ,
70
70
))
71
+ tk .MustQuery ("explain select a from t where a = -1" ).Check (testkit .Rows (
72
+ "TableDual_5 0.00 root rows:0" ))
73
+ tk .MustExec (`prepare stmt0 from "select a from t where a = ?"` )
74
+ tk .MustExec ("set @p0 = -1" )
75
+ tk .MustQuery ("execute stmt0 using @p0" ).Check (testkit .Rows ())
71
76
metrics .ResettablePlanCacheCounterFortTest = true
72
77
metrics .PlanCacheCounter .Reset ()
73
78
counter := metrics .PlanCacheCounter .WithLabelValues ("prepare" )
@@ -137,4 +142,13 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) {
137
142
counter .Write (pb )
138
143
hit = pb .GetCounter ().GetValue ()
139
144
c .Check (hit , Equals , float64 (2 ))
145
+ tk .MustExec ("insert into t (a, b, c) values (18446744073709551615, 4, 4)" )
146
+ tk .MustExec ("set @p1=-1" )
147
+ tk .MustExec ("set @p2=1" )
148
+ tk .MustExec (`prepare stmt7 from "select a from t where a = ?"` )
149
+ tk .MustQuery ("execute stmt7 using @p1" ).Check (testkit .Rows ())
150
+ tk .MustQuery ("execute stmt7 using @p2" ).Check (testkit .Rows ("1" ))
151
+ counter .Write (pb )
152
+ hit = pb .GetCounter ().GetValue ()
153
+ c .Check (hit , Equals , float64 (3 ))
140
154
}
0 commit comments