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

check, diff: auto discover ansi-quotes #381

Merged
merged 12 commits into from
Aug 25, 2020

Conversation

lance6716
Copy link
Collaborator

@lance6716 lance6716 commented Aug 12, 2020

What problem does this PR solve?

auto discover ansi-quotes so don't need to set it in config, part of pingcap/dm#878

What is changed and how it works?

for processing db (new connection) related query results, get ansi-quotes from global variable for this db.
(may need to get session variable for connection related query results, not found yet)

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch

pkg/utils/util.go Outdated Show resolved Hide resolved
@lance6716 lance6716 changed the title check: auto discover ansi-quotes check, diff: auto discover ansi-quotes Aug 12, 2020
@lance6716
Copy link
Collaborator Author

PTAL @csuzhangxc @GMHDBJD

@@ -72,8 +72,6 @@ type DBConfig struct {
Schema string `toml:"schema" json:"schema"`

Snapshot string `toml:"snapshot" json:"snapshot"`

SQLMode string `toml:"sql-mode" json:"sql-mode"`
Copy link
Member

Choose a reason for hiding this comment

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

Do other places still need this (sql_mode may including others rather than ANSI_QUOTES)?

But we may remove it now and add it back if needed later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess other places don't require this SQLMode otherwise it won't compile. and in #280 this field is used for parser only

@lance6716
Copy link
Collaborator Author

/run-all-tests

@lance6716
Copy link
Collaborator Author

/run-all-tests

@lance6716
Copy link
Collaborator Author

/run-integration-tests

@lance6716
Copy link
Collaborator Author

/run-all-tests

@lance6716
Copy link
Collaborator Author

very strange that integration test could pass on my Ubuntu 🤔

@lance6716
Copy link
Collaborator Author

lance6716 commented Aug 21, 2020

I could confirm integration test can pass on my Ubuntu
image

and seems CI fails on Error 9002: TiKV server timeout

PTAL @csuzhangxc @GMHDBJD

@GMHDBJD
Copy link
Contributor

GMHDBJD commented Aug 21, 2020

/run-all-tests

@lance6716
Copy link
Collaborator Author

/run-integration-tests

@lance6716
Copy link
Collaborator Author

mysteriously CI pass, PTAL @csuzhangxc @GMHDBJD


// GetSQLMode returns sql_mode.
func GetSQLMode(db *sql.DB) (tmysql.SQLMode, error) {
sqlMode, err := GetGlobalVariable(db, "sql_mode")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be session variable because now we support session config for db?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in 3dccc00

Comment on lines 162 to 176
ansiQuotes, err := dbutil.HasAnsiQuotesMode(c.db)
if err != nil {
return []*incompatibilityOption{
{
state: StateFailure,
errMessage: err.Error(),
},
}
}

sqlMode := ""
if c.enableANSIQuotes {
if ansiQuotes {
sqlMode = "ANSI_QUOTES"
}
parser2, err := dbutil.GetParser(sqlMode)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about combine them into one function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done in 3dccc00

Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@csuzhangxc csuzhangxc 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

if ansiQuotes {
sqlMode = "ANSI_QUOTES"
}
return getParser(sqlMode)
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 set sql_mode for all modes from GetSQLMode rather than only ANSI_QUOTES?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

f70d144

Okay, going to align DM's parser to this behaviour

Copy link
Member

@csuzhangxc csuzhangxc left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants