Skip to content
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

*: add TestLocalTemporaryTableInfoSchema to store local temporary table schemas #25518

Merged
merged 14 commits into from
Jun 30, 2021

Conversation

lcwangchao
Copy link
Collaborator

@lcwangchao lcwangchao commented Jun 17, 2021

What problem does this PR solve?

see #24169

add TestLocalTemporaryTableInfoSchema to store local temporary table schemas

What is changed and how it works?

Introduce TestLocalTemporaryTableInfoSchema to store store local temporary table schemas

Related changes

  • N/A

Check List

Tests

  • Unit test

Side effects

  • N/A

Release note

  • No release note

@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 17, 2021
@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Jun 17, 2021
Comment on lines 418 to 431
type LocalTemporaryTable struct {
table.Table
Schema *model.DBInfo
}

type localTempSchemaTables struct {
tables map[string]*LocalTemporaryTable
}

// localTemporaryTableInfoSchema implements LocalTemporaryTableInfoSchema
type localTemporaryTableInfoSchema struct {
schemaMap map[string]*localTempSchemaTables
idx2table map[int64]*LocalTemporaryTable
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reasons why not reuse infoSchema and schemaTables?

Copy link
Collaborator Author

@lcwangchao lcwangchao Jun 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we drop a database and then create a now one with a same name in a single session, it can happens that two temporary tables belong to different databases but with the same name. Though it works well when using schemaTables because db information for local temporary table is not very useful, but it is clear to present the real situation to store a dbinfo in each table.

Another reason why not using infoSchema is that it is immutable and has many method we do not need (we also need to add some methods such as AddTable or RemoveTable), it more simple to define a new structure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define another LocalTemporaryTableInfoSchema interface is unnecessary.
It's easy to override the InfoSchema interface providing a different implementation.

https://github.com/pingcap/tidb/pull/22440/files#diff-a40af26d74c0e0d741ec31becd7338558785033cf251e8ef1c61d1eed7a4ed31R8

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiancaiamao I'm ok to remove interface LocalTemporaryTableInfoSchema and override InfoSchema. But because session use function GetInfoSchema to get a final infoschema instead of just getting it from TxnCtx, I should rethink how to store it in the sessionvars

@lcwangchao lcwangchao mentioned this pull request Jun 18, 2021
89 tasks
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 30, 2021
@tiancaiamao
Copy link
Contributor

It's more complex than necessary but it lack something...
Well, let's get it merged and I will revise it in the next PR.

@tiancaiamao
Copy link
Contributor

#25851

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • djshow832
  • tiancaiamao

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 30, 2021
@tiancaiamao
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: bb4ddb0

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 30, 2021
@ti-chi-bot
Copy link
Member

@lcwangchao: 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.

@ti-chi-bot ti-chi-bot merged commit e13fe35 into pingcap:master Jun 30, 2021
@lcwangchao lcwangchao deleted the localtempinfoschema branch June 30, 2021 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants