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

*: cherry-pick recent PRs for dumpling v5.0.1 #271

Merged
merged 11 commits into from
Apr 16, 2021

Conversation

lichunzhu
Copy link
Contributor

@lichunzhu lichunzhu commented Apr 14, 2021

What problem does this PR solve?

Some features are not cherry-picked to release-5.0.

What is changed and how it works?

Cherry-pick PRs on the master branch to release-5.0.

BugFix:

Feature:

Tests:

Check List

Tests

  • Unit test
  • Integration test

Release note

  • No release note

@lichunzhu lichunzhu changed the title *: cherry-pick features for dumpling v5.0.1 *: cherry-pick recent PRs for dumpling v5.0.1 Apr 14, 2021
}
} else {
pv = v
}
s := fmt.Sprintf("SET SESSION %s = ?", k)
Copy link
Collaborator

@lance6716 lance6716 Apr 14, 2021

Choose a reason for hiding this comment

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

Here using ? will let sql driver to check the type of pv, to decide if pv need quotes.

Instead, I prefer always use the input value as-is, that is to say we always use %s and printf to construct a SQL. So user should quote the value if it's a string type variable in SQL.

https://github.com/go-sql-driver/mysql/blob/bcc459a906419e2890a50fc2c99ea6dd927a88f2/connection.go#L68-L78

(I deleted previous misleading comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

we might append --param to dsn 😂 otherwise we can't control https://github.com/go-sql-driver/mysql#parameters and have to write a doc about dealing with , in parameter KVs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here using ? will let sql driver to check the type of pv, to decide if pv need quotes.

Instead, I prefer always use the input value as-is, that is to say we always use %s and printf to construct a SQL. So user should quote the value if it's a string type variable in SQL.

https://github.com/go-sql-driver/mysql/blob/bcc459a906419e2890a50fc2c99ea6dd927a88f2/connection.go#L68-L78

(I deleted previous misleading comment)

conf.SessionParams is a map[string]interface{}. I think using an original value to construct SQL is in-proper for being used as a library.

Copy link
Collaborator

@lance6716 lance6716 Apr 15, 2021

Choose a reason for hiding this comment

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

what's the detailed in-proper case?

if user input key=val, successful parsing val as a integer does not mean key is an interger MySQL variable, at that time it will raise an error.

Copy link
Collaborator

@kennytm kennytm Apr 15, 2021

Choose a reason for hiding this comment

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

I think that SET SESSION X = 123 and SET SESSION X = '123' are equivalent for system variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lance6716 @kennytm
Fixed in 1b33d20, and add an integration test in 278a128. PTAL again

Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry I didn't reply to above comment in time 😂 I didn't found a case for system variables that SET SESSION X = 123 will cause error if X is a string type variable. Will check it now.

@kennytm
Copy link
Collaborator

kennytm commented Apr 16, 2021

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • kennytm

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added the status/LGT1 One reviewer approved (LGTM1) label Apr 16, 2021
@lichunzhu
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: a7c8c08

@ti-chi-bot ti-chi-bot merged commit 4cb1157 into pingcap:release-5.0 Apr 16, 2021
@lichunzhu lichunzhu deleted the cherrypick501 branch April 16, 2021 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants