-
Notifications
You must be signed in to change notification settings - Fork 283
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
syncer(dm): fix different output format for operate-schema get #5824
Conversation
[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. |
/cc @dsdashun @lance6716 |
/run-leak-test |
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## master #5824 +/- ##
================================================
+ Coverage 56.0768% 56.6908% +0.6140%
================================================
Files 535 676 +141
Lines 70143 79018 +8875
================================================
+ Hits 39334 44796 +5462
- Misses 27078 30022 +2944
- Partials 3731 4200 +469 |
dm/syncer/schema.go
Outdated
@@ -76,7 +77,9 @@ func (s *Syncer) OperateSchema(ctx context.Context, req *pb.OperateWorkerSchemaR | |||
s.tctx.L().Info("table schema is not in checkpoint, fetch from downstream", | |||
zap.String("table", sourceTable.String())) | |||
targetTable := s.route(sourceTable) | |||
return dbconn.GetTableCreateSQL(s.tctx.WithContext(ctx), s.downstreamTrackConn, targetTable.String()) | |||
result, err2 := dbconn.GetTableCreateSQL(s.tctx.WithContext(ctx), s.downstreamTrackConn, targetTable.String()) | |||
result = strings.ReplaceAll(result, fmt.Sprintf("CREATE TABLE `%s`", targetTable.Name), fmt.Sprintf("CREATE TABLE `%s`", sourceTable.Name)) |
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.
we can replace the first occurrence, not all occurrence., in case user has writen the "CREATE TABLE ``" pattern in column comments
And use quotes.QuoteName
to correctly escape the `
in table name.
syncer.checkpoint.(*RemoteCheckPoint).points = make(map[string]map[string]*binlogPoint) | ||
|
||
mock.ExpectQuery("SHOW CREATE TABLE " + "`test_1`.`t_2`").WillReturnRows( | ||
sqlmock.NewRows([]string{"Table", "Create Table"}). |
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.
this mock is not the same output format as a real MySQL/TiDB. We should make sure the test is valid.
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.
LGTM
@dsdashun: 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. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: eafcd74
|
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #5884. |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #5885. |
In response to a cherrypick label: new pull request created: #5886. |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #5887. |
/cherry-pick-release-5.4 |
/cherry-pick release-5.4 |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ForwardStar: new pull request created: #6031. 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. |
What problem does this PR solve?
Issue Number: close #5688
What is changed and how it works?
If the checkpoint doesn't exist and the schema is retrieved from the downstream, replace the downstream table name with the requested upstream table name
Delete all
\n
in the SQL results for the operate-schema resultCheck List
Tests
Questions
Will it cause performance regression or break compatibility? No.
Do you need to update user documentation, design documentation or monitoring documentation? No.
Release note