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

ddl: Drop a local temporary table #26063

Merged
merged 21 commits into from
Jul 20, 2021

Conversation

Howie59
Copy link
Contributor

@Howie59 Howie59 commented Jul 8, 2021

What problem does this PR solve?

Issue Number: see #24169

What is changed and how it works?

Proposal: Temporary Table

Check List

Tests

  • Unit test

Release note

  • No release note

@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 8, 2021
@github-actions github-actions bot added sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels Jul 8, 2021
executor/ddl.go Outdated Show resolved Hide resolved
ddl/db_integration_test.go Outdated Show resolved Hide resolved
@lcwangchao lcwangchao mentioned this pull request Jul 9, 2021
89 tasks
ddl/db_integration_test.go Outdated Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 13, 2021
executor/ddl.go Outdated Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 13, 2021
…nto drop-local-temp-table

# Conflicts:
#	ddl/db_integration_test.go
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 13, 2021
executor/ddl.go Outdated
}
}
// if all tables are local temporary, directly drop those tables.
if len(s.Tables) == existsNum {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if some are temporary tables while some are not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would be handled in dropTableObject, normal table would exec origin logic, local temp table handled singlely

Copy link
Contributor

Choose a reason for hiding this comment

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

How about drop all the temp tables here, and dropTableObject only drop normal tables?
It seems hard to keep the atomic of the drop statement, so the tables can be reordered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but if table not exists, it should rollback. and the local temp tables should not drop

executor/ddl.go Outdated
}
}

if obt == tableObject && len(localTempTableList) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This part is duplicate with DDLExec.Next, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if all tables are local temp table, it could be dropped directly, but if tables are consists of local temp and normal tables, it should check whether table exists, then drop it

executor/ddl.go Outdated
}
}
// if all tables are local temporary, directly drop those tables.
if len(s.Tables) == existsNum {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about drop all the temp tables here, and dropTableObject only drop normal tables?
It seems hard to keep the atomic of the drop statement, so the tables can be reordered.

@@ -2927,3 +2927,79 @@ func (s *testIntegrationSuite3) TestAvoidCreateViewOnLocalTemporaryTable(c *C) {
tk.MustExec("create view vv as select * from v0")
checkCreateView()
}

func (s *testIntegrationSuite3) TestDropTemporaryTable(c *C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Try this: drop table normal_table, temp_table;
Where the normal_table doesn't exist, which leads to rollback.
I assume it's both OK that temp_table exists or not.

executor/ddl.go Show resolved Hide resolved
executor/ddl.go Show resolved Hide resolved
session/session.go Outdated Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
executor/ddl.go Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
ddl/db_integration_test.go Outdated Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
executor/ddl.go Outdated Show resolved Hide resolved
@Howie59
Copy link
Contributor Author

Howie59 commented Jul 20, 2021

/run-check_dev_2

@ti-chi-bot
Copy link
Member

@lcwangchao: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

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 added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 20, 2021
@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 Jul 20, 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: ccdd722

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 20, 2021
@ti-chi-bot ti-chi-bot merged commit dc8d0fd into pingcap:master Jul 20, 2021
@Howie59 Howie59 deleted the drop-local-temp-table branch July 20, 2021 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/L Denotes a PR that changes 100-499 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.

5 participants