-
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
*: support create a local temporary table #25851
Conversation
err := domain.GetDomain(e.ctx).DDL().CreateTable(e.ctx, s) | ||
return err | ||
} | ||
|
||
func (e *DDLExec) createSessionTemporaryTable(s *ast.CreateTableStmt) error { |
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.
Is it better to modify the method ddl.CreateTableWithInfo
, it can reduce many dup codes like alloc table id, generate table info, etc...
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.
Local temporary table is not a normal table, it doesn't need to do the DDL schema change and store table info.
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 checked the function ddl.CreateTable, ddl.CreateTableWithInfo, most codes can be reused here. We can just return if local temporary if founded before creating table in tikv. Current modification is easy to lost some checks. For example,
create temporary table if not exists will still return error because you didn't check IfNotExists in statement
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.
Check the table options will be done in some other PR.
That will add up to a lot of work, and (more importantly) the tests should also be included.
if !ok { | ||
return infoschema.ErrDatabaseNotExists.GenWithStackByArgs(s.Table.Schema.O) | ||
} | ||
tbInfo, err := ddl.BuildTableInfoWithCheck(e.ctx, s, dbInfo.Charset, dbInfo.Collate) |
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.
Does BuildTableInfoWithCheck support create table like ...
?
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'm not sure, create table like ...
will be handle in some other PR, this one focus on creating a table.
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning 1105 local TEMPORARY TABLE is not supported yet, TEMPORARY will be parsed but ignored")) | ||
|
||
// Create local temporary table. | ||
tk.MustExec("set @@tidb_enable_noop_functions = 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.
Why we still need to set tidb_enable_noop_functions=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.
I don't want to touch more places than necessary. For example, in this pr I just want to add the create local temporary table.
If a remove this switch, I need to update some of the tests, I prefer to do it in another PR.
[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. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: a2e4a4b
|
@tiancaiamao: 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 #xxx
Problem Summary:
What is changed and how it works?
What's Changed:
createSessionTemporaryTable()
function that avoid the real DDL.How it Works:
create temporary table will add the table to the session variable (see changes in executor/ddl.go)
then
GetInfoSchema()
will used a overrideInfoSchema
combined the realInfoSchema
with the local temporary tables.Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Release note