This repository was archived by the owner on Jul 24, 2024. It is now read-only.
restore: insert IF NOT EXISTS to create table SQL#85
Closed
5kbpers wants to merge 2 commits intopingcap:masterfrom
Closed
restore: insert IF NOT EXISTS to create table SQL#855kbpers wants to merge 2 commits intopingcap:masterfrom
IF NOT EXISTS to create table SQL#855kbpers wants to merge 2 commits intopingcap:masterfrom
Conversation
added 2 commits
December 6, 2019 14:53
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
8140b74 to
47036ca
Compare
IF NOT EXISTs to create table SQLIF NOT EXISTS to create table SQL
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
==========================================
- Coverage 66.4% 66.27% -0.13%
==========================================
Files 22 22
Lines 2542 2556 +14
==========================================
+ Hits 1688 1694 +6
- Misses 625 632 +7
- Partials 229 230 +1
Continue to review full report at Codecov.
|
kennytm
reviewed
Dec 9, 2019
| } | ||
| createSQL := buf.String() | ||
| // Insert `IF NOT EXISTS` statement to skip the created tables | ||
| words := strings.Split(createSQL, " ") |
Collaborator
There was a problem hiding this comment.
Use SplitN and limits n to 3.
| resWords := append([]string{}, words[:2]...) | ||
| resWords = append(resWords, "IF NOT EXISTS") | ||
| resWords = append(resWords, words[2:]...) | ||
| createSQL = strings.Join(resWords, " ") |
Collaborator
There was a problem hiding this comment.
Then just write "create table if not exists " + words[2] here.
| zap.Stringer("table", schema.Name), | ||
| zap.String("SQL", createSQL), | ||
| zap.Error(err)) | ||
| return errors.New("build create table SQL failed") |
Collaborator
There was a problem hiding this comment.
I don't think we need to immediately bail out if the SQL does not start with CREATE TABLE.
Member
|
/run-integration-tests |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: 5kbpers tangminghua@pingcap.com
When we cannot rebuild the CREATE TABLE SQL correctly, users should be able to create the table manually.
This PR inserts
IF NOT EXISTSto skip creating the existed table.Maybe a better way is to check if the table existed before creating it, but that will introduce extra cost.