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

*: make drainer translator's SQL_MODE configurable #511

Merged
merged 4 commits into from
Apr 1, 2019
Merged

*: make drainer translator's SQL_MODE configurable #511

merged 4 commits into from
Apr 1, 2019

Conversation

lonng
Copy link
Contributor

@lonng lonng commented Apr 1, 2019

What problem does this PR solve?

relate issue:https://internal.pingcap.net/jira/browse/TOOL-1039
Drainer translator should keep SQL_MODE compatible with upstream.

What is changed and how it works?

Add a config item sql-mode to make SQL_MODE configurable.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

Side effects

N/A

Related changes

  • Need to cherry-pick to the release branch

@lonng
Copy link
Contributor Author

lonng commented Apr 1, 2019

/run-all-tests

drainer/server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@WangXiangUSTC WangXiangUSTC left a comment

Choose a reason for hiding this comment

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

rest LGTM

drainer/config.go Outdated Show resolved Hide resolved
drainer/config.go Outdated Show resolved Hide resolved
@lonng
Copy link
Contributor Author

lonng commented Apr 1, 2019

/run-all-tests

@WangXiangUSTC
Copy link
Contributor

LGTM

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

  • when the downstream is mysql, we need to set sql_mode in drainer/executor/mysql.go too, or will fail to execute at the downstream mysql or tidb?
  • this means later we must support set sql_mode for reparo too, but it's ok to just do the drainer part now at this pr.

drainer/config.go Outdated Show resolved Hide resolved
cmd/drainer/drainer.toml Outdated Show resolved Hide resolved
@july2993
Copy link
Contributor

july2993 commented Apr 1, 2019

/run-all-tests

pkg/sql/sql.go Outdated
dbDSN := fmt.Sprintf("%s:%s@tcp(%s:%d)/?charset=utf8mb4,utf8&multiStatements=true", username, password, host, port)
if len(sqlMode) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

So it's not possible to set an empty SQL mode (which is different from the "default SQL mode" which includes STRICT_TRANS_TABLE and stuff)?

drainer/config.go Outdated Show resolved Hide resolved
@IANTHEREAL
Copy link
Collaborator

except adding some new arguments into functions, LGTM.

I think we can put sql mode into DBconfig, and pass a config argument for translator.SetConfig

@csuzhangxc
Copy link
Member

I think we can put sql mode into DBconfig, and pass a config argument for translator.SetConfig

if downstream is MySQL, put it into DBConfig is fine, but if the downstream is pb, we still need another config item to hold it, right?

Copy link
Collaborator

@IANTHEREAL IANTHEREAL left a comment

Choose a reason for hiding this comment

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

LGTM

@july2993
Copy link
Contributor

july2993 commented Apr 1, 2019

/run-all-tests

@july2993 july2993 merged commit 06e378f into pingcap:master Apr 1, 2019
@july2993 july2993 deleted the lonng/sql-mode branch April 1, 2019 10:18
july2993 pushed a commit that referenced this pull request Apr 1, 2019
If this is setted , will use the same sql-mode to parse DDL statment, and set the same sql-mode at downstream when db-type is mysql.
If this is not setted, it will not set any sql-mode.

(cherry picked from commit 06e378f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants