-
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: Solve the problem that the parent query condition is pushed incorrectly when the setvar function is evaluated in the subquery.(#11622) #11624
Conversation
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
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.
I tested this case on my computer with MySQL 8.0
, and it returns an empty set.
I'm so sorry for sql written incorrectly. I have modified sql in issue. PTAL @qw4990 |
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.
@lovewin99 Please help fix the failed CI.
Codecov Report
@@ Coverage Diff @@
## master #11624 +/- ##
===========================================
Coverage 81.4629% 81.4629%
===========================================
Files 447 447
Lines 96191 96191
===========================================
Hits 78360 78360
Misses 12286 12286
Partials 5545 5545 |
/run-all-tests |
@eurekaka All tests passed |
@@ -53,6 +53,27 @@ func HasGetSetVarFunc(expr Expression) bool { | |||
return false | |||
} | |||
|
|||
// HasAssignSetVarFunc checks whether an expression contains SetVar function and assign a value | |||
func HasAssignSetVarFunc(expr Expression) bool { |
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 check looks pretty ad-hoc, I prefer to push no condition down to Projection's child completely if p.Exprs
contains SetVar
or GetVar
, because there seems like many hidden corner cases which would return wrong results. @zz-jason How do you think?
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.
If p.Exprs contains setvar and getvar and does not push down all the conditions, then many normal pushdowns will be ignored, which can have a large impact on performance in many cases. I think this kind of check just a subset of reject all pushdowns, which helps narrow down the problem without expanding the problem. @eurekaka @zz-jason How do you think?
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
PTAL @qw4990 |
@lovewin99 Please help resolve the conflict, thanks. |
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
/run-all-tests |
@lovewin99 We may need to cherry pick this one to release-3.1, release-3.0, release-2.1 |
…incorrectly when the setvar function is evaluated in the subquery.(pingcap#11624)
…incorrectly when the setvar function is evaluated in the subquery.(pingcap#11624)
…incorrectly when the setvar function is evaluated in the subquery.(pingcap#11624)
What problem does this PR solve?
fix issue: #11622 when the setvar function is evaluated in the subquery, the parent query condition is pushed down wrongly.
Check List
Tests