Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

*: auto discover ANSI_QUOTES #889

Merged
merged 36 commits into from
Sep 7, 2020
Merged

*: auto discover ANSI_QUOTES #889

merged 36 commits into from
Sep 7, 2020

Conversation

lance6716
Copy link
Collaborator

@lance6716 lance6716 commented Aug 12, 2020

What problem does this PR solve?

close #878

What is changed and how it works?

still need user specified ANSI_QUOTES:

Check List

Tests

  • Unit test
  • Integration test

Code changes

Side effects

  • Possible performance regression

Related changes

  • Need to cherry-pick to the release branch

@lance6716 lance6716 added needs-cherry-pick-release-1.0 This PR should be cherry-picked to release-1.0. Remove this label after cherry-picked to release-1.0 priority/normal Minor change, requires approval from ≥1 primary reviewer status/PTAL This PR is ready for review. Add this label back after committing new changes type/feature New feature labels Aug 12, 2020
syncer/syncer.go Outdated Show resolved Hide resolved
@lance6716 lance6716 added status/WIP This PR is still work in progress and removed status/PTAL This PR is ready for review. Add this label back after committing new changes labels Aug 12, 2020
@lance6716 lance6716 added status/PTAL This PR is ready for review. Add this label back after committing new changes and removed status/WIP This PR is still work in progress labels Aug 12, 2020
@@ -612,18 +614,17 @@ func (s *Syncer) getTable(origSchema, origTable, renamedSchema, renamedTable str
func (s *Syncer) trackTableInfoFromDownstream(origSchema, origTable, renamedSchema, renamedTable string) error {
// TODO: Switch to use the HTTP interface to retrieve the TableInfo directly
Copy link
Collaborator Author

@lance6716 lance6716 Aug 12, 2020

Choose a reason for hiding this comment

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

going to fix this TODO in another PR (though fix this TODO will make GetParserForConn unued, we might left GetParserForConn there in case of future using)

Copy link
Member

Choose a reason for hiding this comment

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

Now, we have TLS support, if switching to HTTP API, do we need to handle it, right?

@lance6716
Copy link
Collaborator Author

/run-all-tests

@lance6716

This comment has been minimized.

pkg/utils/db.go Outdated
// GetSQLMode returns sql_mode.
func GetSQLMode(db *sql.DB) (tmysql.SQLMode, error) {
// GetParser gets a parser for sql.DB which maybe enabled `ANSI_QUOTES` sql_mode
func GetParser(db *sql.DB) (*parser.Parser, error) {
sqlMode, err := GetGlobalVariable(db, "sql_mode")
Copy link
Collaborator

@GMHDBJD GMHDBJD Aug 24, 2020

Choose a reason for hiding this comment

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

Session here ditto or use func of tidb-tools.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed in 104f5df

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have not change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

want to explain that (*UpStreamConn).getParser will use GetParserForConn, which further uses session variables so could reflect variables set though DSN. And (*UpStreamConn).getParser is used in most unit, in fact GetParser is only used in relay unit and tests 😿

will change it 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.

@lance6716 lance6716 added the needs-cherry-pick-release-2.0 This PR should be cherry-picked to release-2.0. Remove this label after cherry-picked to release-2.0 label Aug 25, 2020
@lance6716
Copy link
Collaborator Author

dumpling's SessionParams and GetDSN doesn't change SQL mode. so currently we can't make dumpling's session variable different than global. If in future we find that we should manually set SQL mode, we might handling "use session variable" as well as "pass specified SQL mode to dumpling"

ansiQuotes = false
}
if ansiQuotes {
parser2.SetSQLMode(tmysql.ModeANSIQuotes)
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 may as well parse all available SQL mode and set here 😂

will check "Full List of SQL Modes" in https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html tomorrow

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 except #889 (comment)

db, err := sql.Open("mysql", m.dumpConfig.GetDSN(""))
if err != nil {
return
}
defer db.Close()
enable, err := utils.HasAnsiQuotesMode(db)

sqlMode, err := utils.GetGlobalVariable(db, "sql_mode")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Session here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

dumpling didn't expose it's connection, so in fact we can't see its session variable. and by GetDSN and config, we can change its session variable different than global ones

@lance6716 lance6716 added the status/DNM Do not merge, test is failing or blocked by another PR label Sep 4, 2020
@lance6716
Copy link
Collaborator Author

waiting pingcap/parser#1008

@lance6716 lance6716 removed the status/DNM Do not merge, test is failing or blocked by another PR label Sep 5, 2020
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

@lance6716
Copy link
Collaborator Author

PTAL @GMHDBJD

@lance6716 lance6716 added status/LGT1 One reviewer already commented LGTM and removed status/PTAL This PR is ready for review. Add this label back after committing new changes labels Sep 7, 2020
Copy link
Collaborator

@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

@lance6716 lance6716 merged commit 684a1be into pingcap:master Sep 7, 2020
@ti-srebot
Copy link

cherry pick to release-2.0 failed

lance6716 added a commit to lance6716/dm that referenced this pull request Sep 8, 2020
lance6716 added a commit that referenced this pull request Sep 9, 2020
@csuzhangxc csuzhangxc added already-cherry-pick-2.0 The related PR is already cherry-picked to release-2.0. Add this label once the PR is cherry-picked and removed needs-cherry-pick-release-2.0 This PR should be cherry-picked to release-2.0. Remove this label after cherry-picked to release-2.0 labels Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
already-cherry-pick-2.0 The related PR is already cherry-picked to release-2.0. Add this label once the PR is cherry-picked priority/normal Minor change, requires approval from ≥1 primary reviewer status/LGT1 One reviewer already commented LGTM type/feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uniform handle for ansi-quotes and ANSI_QUOTES sql_mode in session for task config
4 participants