-
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
dumpling: supports foreign key limitations #39914
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
95ed3ec
support foreign key for dumpling
lichunzhu e4d3302
Merge branch 'master' into dumplingSupportForeign
lichunzhu 1f5178b
fix tests
lichunzhu 1fd55f8
Merge branch 'dumplingSupportForeign' of https://github.com/lichunzhu…
lichunzhu bbf71f0
fix lint
lichunzhu 93e3af1
fix ut
lichunzhu b62cb11
Merge branch 'master' into dumplingSupportForeign
lichunzhu 35dacf1
Merge branch 'master' into dumplingSupportForeign
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `escape` VALUES | ||
('''', '"'), | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `t` VALUES | ||
(''), | ||
|
1 change: 1 addition & 0 deletions
1
dumpling/tests/naughty_strings/expect/naughty_strings.escape.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `escape` VALUES | ||
('\'','\"'), | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `t` VALUES | ||
(''), | ||
|
1 change: 1 addition & 0 deletions
1
dumpling/tests/placement_policy/result/x-placement-policy-create.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
/*T![placement] CREATE PLACEMENT POLICY `x` PRIMARY_REGION="cn-east-1" REGIONS="cn-east-1,cn-east" */; |
1 change: 1 addition & 0 deletions
1
dumpling/tests/placement_policy/result/x1-placement-policy-create.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
/*T![placement] CREATE PLACEMENT POLICY `x1` FOLLOWERS=4 */; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `pk_case_0` VALUES | ||
(0,10), | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `pk_case_1` VALUES | ||
(0,10), | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `pk_case_2` VALUES | ||
(0,10), | ||
|
This file contains 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
1 change: 1 addition & 0 deletions
1
dumpling/tests/quote/data/quote-database-schema-create-mysql57.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
CREATE DATABASE `quo``te/database` /*!40100 DEFAULT CHARACTER SET latin1 */; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
CREATE DATABASE `quo``te/database` /*!40100 DEFAULT CHARACTER SET latin1 */ /*!80016 DEFAULT ENCRYPTION='N' */; |
1 change: 1 addition & 0 deletions
1
dumpling/tests/quote/data/quote-database.quote-table-schema-mysql57.sql
This file contains 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
1 change: 1 addition & 0 deletions
1
dumpling/tests/quote/data/quote-database.quote-table-schema.sql
This file contains 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
1 change: 1 addition & 0 deletions
1
dumpling/tests/quote/data/quote-database.quote-table.000000000-mysql57.sql
This file contains 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
1 change: 1 addition & 0 deletions
1
dumpling/tests/quote/data/quote-database.quote-table.000000000.sql
This file contains 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
1 change: 1 addition & 0 deletions
1
dumpling/tests/sequences/data/sequences.s-schema-sequence-expect.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; | ||
SELECT SETVAL(`s`,1001); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
CREATE DATABASE `views` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */ /*!80016 DEFAULT ENCRYPTION='N' */; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
CREATE TABLE `v`( | ||
`a` int, | ||
|
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.
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.
Are these comments for dump files or queries?
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.
seems they are written to dump files. These comments take effects when importing not dumping, so we should not using upstream database to decide comments
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.
These comments are used for dumped data files. They are used for scenes that we directly restore sqls back through MySQL cmd.
For import tools, they need to re-decide the used comments. These changes are copied from mydumper https://github.com/mydumper/mydumper/blob/e4d05b1a76b7a529d24c43a4d043790f355c5085/src/mydumper_jobs.c#L290. I don't think export tools adding this comment is conflicted with import tools.
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.
need an integration test with lightning later to check we can handle mariadb case😂
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.
https://github.com/pingcap/tiflow/blob/099da1e08f1310c2366093f2c314a51e0cde772b/dm/loader/loader.go#L1218
DM loader may not be able to handle
SET FOREIGN_KEY_CHECKS=0;
, not sure what's the behaviour for lightningThere 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 think Lightning shouldn't read these comments😂 It should add its own comments according to downstream database.
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.
tidb/br/pkg/lightning/restore/tidb_test.go
Line 179 in 66a2e96
Seems lightning will handle these comments.
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 think DM loader's handle is correct. Loader should execute foreign key handlement itself when it finds its downstream is TiDB. See https://github.com/mydumper/mydumper/blob/e4d05b1a76b7a529d24c43a4d043790f355c5085/src/myloader.c#L388