-
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
core_test: add cases that local temporary table works well for cte #27174
core_test: add cases that local temporary table works well for cte #27174
Conversation
[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. |
# Conflicts: # planner/core/integration_test.go
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.
MySQL:
mysql> drop table t1;
Query OK, 0 rows affected (0.02 sec)
mysql> create temporary table t1 (i int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 values (5),(4),(1),(2),(3);
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> with cte as (select * from t1) select * from cte;
+------+
| i |
+------+
| 5 |
| 4 |
| 1 |
| 2 |
| 3 |
+------+
5 rows in set (0.00 sec)
…y_table' into forbid_CTE_on_the_local_temporary_table
/rebuild |
/rebuild |
planner/core/logical_plan_builder.go
Outdated
b.cteToTblIDMapper[cteName] = append(b.cteToTblIDMapper[cteName], tblIds...) | ||
} | ||
} else { | ||
if tblIds, ok := b.cteToTblIDMapper[tn.Name.L]; ok { |
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.
it seems like this line is duplicated with 3846, could we simplify the 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.
done
planner/core/logical_plan_builder.go
Outdated
return nil, infoschema.ErrTableNotExists.GenWithStack("Table which ID = %d does not exist.", tblID) | ||
} | ||
errMsg := fmt.Sprintf(errno.MySQLErrName[errno.ErrCantReopenTable].Raw, tb.Meta().Name.L) | ||
return nil, ErrInternal.GenWithStack(errMsg) |
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.
how about return nil, ErrInternal.GenWithStack(errno.MySQLErrName[errno.ErrCantReopenTable].Raw,tb.Meta().Name.L)
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.
done
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 usage should be:
- define a global error object in this package, maybe error.go
errCantReopenTable = dbterror.ClassTypes.NewStdErr(errno.ErrCantReopenTable, mysql.MySQLErrName[errno.ErrCantReopenTable])
- and then use
errCantReopenTable.GenWithStackByArgs(tblName)
here
In this way, you can get the correct error code 1137, instead of 1815
The title is misleading, it is not "Forbid cte on the local temporary table". It should be "Forbade refer temporary table more than once in one statement" |
@zhaoxugang You can just put a |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: b5ebd02
|
|
I think it's caused by #27405 The test has a goroutine:
The old version will always be blocked because So the pr #27405 made some change:
The chan will not be blocked any more, but unfortunately, this line in the goroutine function will alway fail:
So the test failed. (If we invoked cancel for a context, the best behavior is return an error. I don't know why it doesn't) But the test failed in my laptop for another reason:
I think it is because #27405 added goleak to detected leaks but sometimes the goroutine did not exist so quickly. But It is still strange that the context cancel function is called very early, but in my own environment, it fails as a leak for most cases. So I found that: after we call cancel, the goroutine is still blocked in this line:
And this line is blocked by:
So I know that To avoid this error, we just need to remove |
@zhaoxugang: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: close #25951
Problem Summary:
What is changed and how it works?
Proposal: xxx
What's Changed:
How it Works:
Check List
Tests
Side effects
Documentation
Release note