-
Notifications
You must be signed in to change notification settings - Fork 85
*: cherry-pick recent PRs for dumpling v5.0.1 #271
Conversation
} | ||
} else { | ||
pv = v | ||
} | ||
s := fmt.Sprintf("SET SESSION %s = ?", k) |
There was a problem hiding this comment.
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.
(I deleted previous misleading comment)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ofpv
, to decide ifpv
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.(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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
This reverts commit 1b33d20.
/lgtm |
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: a7c8c08
|
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
Release note