Update default SQL mode and parser initialization in downstream track…#12610
Update default SQL mode and parser initialization in downstream track…#12610CsongSY wants to merge 1 commit intopingcap:masterfrom
Conversation
…er,Remove NO_AUTO_CREATE_USER in default SQL mode.
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions 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 kubernetes-sigs/prow repository. |
|
[FORMAT CHECKER NOTIFICATION] Notice: To remove the 📖 For more info, you can check the "Contribute Code" section in the development guide. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @CsongSY. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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 kubernetes-sigs/prow repository. |
|
Welcome @CsongSY! |
|
Csong seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Code Review
This pull request updates the downstream tracker in dm/pkg/schema/tracker.go to use a specific hardcoded SQL mode string instead of the default mysql.DefaultSQLMode. A review comment suggests changing the local variable DefaultSQLMode to a constant named defaultSQLMode to adhere to Go naming conventions and improve code quality.
| // initDownStreamTrackerParser init downstream tracker parser by default sql_mode. | ||
| func (dt *downstreamTracker) initDownStreamSQLModeAndParser(tctx *tcontext.Context) error { | ||
| setSQLMode := fmt.Sprintf("SET SESSION SQL_MODE = '%s'", mysql.DefaultSQLMode) | ||
| var DefaultSQLMode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" |
There was a problem hiding this comment.
In Go, local variables should use camelCase rather than PascalCase. Additionally, since this value is a constant string literal used multiple times, it should be defined as a const instead of a var. Please ensure the variable name is updated to defaultSQLMode throughout the function.
| var DefaultSQLMode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" | |
| const defaultSQLMode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" |
References
- Go naming conventions specify that local variables should use camelCase (MixedCaps). (link)
|
Looks like this is related to #8149 |
func (dt *downstreamTracker) initDownStreamSQLModeAndParser(tctx *tcontext.Context) error {
var DefaultSQLMode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
setSQLMode := fmt.Sprintf("SET SESSION SQL_MODE = '%s'", DefaultSQLMode)
_, err := dt.downstreamConn.ExecuteSQL(tctx, nil, []string{setSQLMode})
if err != nil {
return dmterror.ErrSchemaTrackerCannotSetDownstreamSQLMode.Delegate(err, DefaultSQLMode)
}
stmtParser, err := conn.GetParserFromSQLModeStr(DefaultSQLMode)
if err != nil {
return dmterror.ErrSchemaTrackerCannotInitDownstreamParser.Delegate(err, DefaultSQLMode)
}
dt.stmtParser = stmtParser
return nil
}
Update default SQL mode and parser initialization in downstream tracker,Remove NO_AUTO_CREATE_USER in default SQL mode.