-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
planner: fix wrong PointGet / TableDual plan reused in plan cache #23238
Conversation
@@ -479,7 +479,4 @@ func (s *testPrepareSerialSuite) TestPointGetUserVarPlanCache(c *C) { | |||
tk.MustQuery("execute stmt using @a").Check(testkit.Rows( | |||
"2 4 2 2", | |||
)) | |||
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows( | |||
"1", | |||
)) |
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.
Sadly, this is the side effect of this PR, we may have false negative decision about "cache it or not", unless we track the whole range calculation procedure to know if any user variable is related to the final ranges. That would be trivial and easy to be broken by new code.
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.
Can we change the test results instead of deleting these tests?
Because now we explicitly don't want to cache these plans to assure correctness.
/run-check_dev_2 |
/run-all-tests |
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.
In (ds *DataSource).accessPathsForConds
, which is for building partial paths for index merge, there're also logics like "if we have point get or empty range, remove other paths". Seems we should also set OptimDependOnMutableConst
to true
there?
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.
/lgtm
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: b4466b7
|
/run-all-tests |
@eurekaka do we need cherry-pick to release branches? |
cherry pick to release-5.0 in PR #24043 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
What problem does this PR solve?
Issue Number: close #23187
close #23144
close #23304
close #23290
Problem Summary:
Planner cannot find a plan for a query while it indeed can.
What is changed and how it works?
What's Changed:
DeriveStats
and only keep the TableDual / PointGet path, we mark this plan as not cacheable;How it Works:
These plans have strong dependency on the param values, i.e, if the values change, those plans may lead to wrong query results.
Related changes
N/A
Check List
Tests
Side effects
prepare stmt from 'select * from t1, t2 where t1.a > 9 and t1.a < 0 and t2.a > ? and t1.b = t2.b'
cannot be cached then, but it is safe actually.Release note