-
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 CTE bug when used with Apply #31256
Conversation
Signed-off-by: guo-shaoge <shaoge1994@163.com>
[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 submitting an approval review. |
/cc @wjhuang2016 |
/run-unit-test |
@@ -1392,7 +1392,7 @@ func (s *testPrepareSerialSuite) TestCTE4PlanCache(c *C) { | |||
tk.MustExec("set @a=1, @b=2, @c=3, @d=4, @e=5, @f=0;") | |||
|
|||
tk.MustQuery("execute stmt using @f, @a, @f").Check(testkit.Rows("1")) | |||
tk.MustQuery("execute stmt using @a, @b, @a").Check(testkit.Rows("1")) | |||
tk.MustQuery("execute stmt using @a, @b, @a").Sort().Check(testkit.Rows("1", "2")) | |||
tk.MustQuery("select @@last_plan_from_cache;").Check(testkit.Rows("0")) |
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.
The correct result is '1 2':
drop table if exists t1;
create table t1(a int);
insert into t1 values(1);
insert into t1 values(2);
SELECT * FROM t1 dt WHERE EXISTS(WITH RECURSIVE qn AS (SELECT a*1 AS b UNION ALL SELECT b+2 FROM qn WHERE b=1) SELECT * FROM qn WHERE b=a);
/run-unit-test |
Signed-off-by: guo-shaoge <shaoge1994@163.com>
/cc @qw4990 |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/314c19890a462879de9e66bcdbc5bae97bf5f6de |
/run-check_dev_2 |
/run-mysql-test |
/run-mysql-test |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 6fea0fe
|
/run-check_dev_2 |
/run-unit-test |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.1 in PR #31380 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.2 in PR #31381 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.3 in PR #31382 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.4 in PR #31383 |
What problem does this PR solve?
Issue Number: close #31255
Problem Summary: No handling for Apply.
What is changed and how it works?
Add
IsInApply
inCTEClass
to indicates whether CTE is the inner plan of Apply. If it is,CTEExec.resTbl
andCTEExec.iterInTbl
will be reset for each outer row of Apply.Check List
Tests
Side effects
Documentation
Release note