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

ticdc/owner: Fix ddl special comment syntax error (#3845) #4415

Closed

Conversation

sdojjy
Copy link
Member

@sdojjy sdojjy commented Jan 19, 2022

This is an automated cherry-pick of #3845

What problem does this PR solve?

close https://github.com/pingcap/ticdc/issues/3755

What is changed and how it works?

not use regex to parse and add special TiDB comments, If a DDL already has special comment like /*!90000 SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=3 */, it wil translate that DDL to /*!90000 /*T! SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=3 */ */, TiDB will throw a syntax error.
this PR use the TiDB SQL parser to parse the SQL and the Restore it with format.RestoreStringSingleQuotes|format.RestoreNameBackQuotes|format.RestoreKeyWordUppercase|format.RestoreTiDBSpecialComment flag

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to update key monitor metrics in both TiCDC document and official document

Release note

Fix syntax error if DDL has a special comment.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • amyangfei

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 release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/cherry-pick-not-approved size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 19, 2022
@sdojjy
Copy link
Member Author

sdojjy commented Jan 20, 2022

/run-unit-test

@codecov-commenter
Copy link

Codecov Report

Merging #4415 (f904620) into release-5.1 (8957631) will increase coverage by 0.1010%.
The diff coverage is 64.7058%.

@@                 Coverage Diff                 @@
##           release-5.1      #4415        +/-   ##
===================================================
+ Coverage      62.1198%   62.2209%   +0.1010%     
===================================================
  Files              161        161                
  Lines            16869      16885        +16     
===================================================
+ Hits             10479      10506        +27     
+ Misses            5491       5475        -16     
- Partials           899        904         +5     

@nongfushanquan nongfushanquan added affects-5.1 cherry-pick-approved Cherry pick PR approved by release team. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. and removed do-not-merge/cherry-pick-not-approved labels Jan 20, 2022
@amyangfei amyangfei added type/cherry-pick-for-release-5.1 This PR is cherry-picked to release-5.1 from a source PR. and removed needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. labels Jan 20, 2022
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 20, 2022
Comment on lines +25 to +26
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/parser/format"
Copy link
Member

Choose a reason for hiding this comment

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

Can we use pingcap/parser?

@overvenus
Copy link
Member

/hold

Since pingcap/parser does not support RestoreTiDBSpecialComment yet, we should be careful for using tidb/parser, as it may have side effect init().

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 20, 2022
@overvenus overvenus closed this Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.1 cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/LGT1 Indicates that a PR has LGTM 1. type/cherry-pick-for-release-5.1 This PR is cherry-picked to release-5.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants