-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
executor: fix point get -1 return max.uInt64 value #10113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) { | |
core.PreparedPlanCacheMaxMemory.Store(math.MaxUint64) | ||
tk.MustExec("use test") | ||
tk.MustExec("drop table if exists t") | ||
tk.MustExec("create table t(a int primary key, b int, c int, key idx_bc(b,c))") | ||
tk.MustExec("create table t(a bigint unsigned primary key, b int, c int, key idx_bc(b,c))") | ||
tk.MustExec("insert into t values(1, 1, 1), (2, 2, 2), (3, 3, 3)") | ||
tk.MustQuery("explain select * from t where a = 1").Check(testkit.Rows( | ||
"Point_Get_1 1.00 root table:t, handle:1", | ||
|
@@ -68,6 +68,11 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) { | |
tk.MustQuery("explain delete from t where a = 1").Check(testkit.Rows( | ||
"Point_Get_1 1.00 root table:t, handle:1", | ||
)) | ||
tk.MustQuery("explain select a from t where a = -1").Check(testkit.Rows( | ||
"TableDual_5 0.00 root rows:0")) | ||
tk.MustExec(`prepare stmt0 from "select a from t where a = ?"`) | ||
tk.MustExec("set @p0 = -1") | ||
tk.MustQuery("execute stmt0 using @p0").Check(testkit.Rows()) | ||
metrics.ResettablePlanCacheCounterFortTest = true | ||
metrics.PlanCacheCounter.Reset() | ||
counter := metrics.PlanCacheCounter.WithLabelValues("prepare") | ||
|
@@ -137,4 +142,13 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) { | |
counter.Write(pb) | ||
hit = pb.GetCounter().GetValue() | ||
c.Check(hit, Equals, float64(2)) | ||
tk.MustExec("insert into t (a, b, c) values (18446744073709551615, 4, 4)") | ||
tk.MustExec("set @p1=-1") | ||
tk.MustExec("set @p2=1") | ||
tk.MustExec(`prepare stmt7 from "select a from t where a = ?"`) | ||
tk.MustQuery("execute stmt7 using @p1").Check(testkit.Rows()) | ||
tk.MustQuery("execute stmt7 using @p2").Check(testkit.Rows("1")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case cannot test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eurekaka oh...... this logic is magic...
In my test this can use point-get in two executes, because prepare use
so for this case:
maybe luck is just fine
will ok for both use point-get plan, but there are another question, we keep param as string datum and try to cast it to int64, so will got a overflow question, it seems not easy to fix so it take another issue in here #10111. 🤣 it's very stranger -1 + int64 cannot use plan cache, and prepare and normal query use different plan.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the root cause of these problems is that we are using int64 to store the handle in PointGet, while it can be unsigned. |
||
counter.Write(pb) | ||
hit = pb.GetCounter().GetValue() | ||
c.Check(hit, Equals, float64(3)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this make
PointGetExecutor
's Next return no result, we cannot use tabledual, this just like tabedual, and no need add more flag- -