-
Notifications
You must be signed in to change notification settings - Fork 188
config: support setting session variable #687
Conversation
Codecov Report
@@ Coverage Diff @@
## master #687 +/- ##
===========================================
Coverage 56.9257% 56.9257%
===========================================
Files 205 205
Lines 20994 20994
===========================================
Hits 11951 11951
Misses 7884 7884
Partials 1159 1159 |
pkg/conn/basedb.go
Outdated
@@ -56,10 +56,16 @@ func (d *DefaultDBProviderImpl) Apply(config config.DBConfig) (*BaseDB, error) { | |||
} | |||
maxIdleConns = rawCfg.MaxIdleConns | |||
} | |||
|
|||
for key, val := range config.Session { | |||
dsn += fmt.Sprintf("&%s=\"%s\"", key, val) |
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.
Do we need to use different formats for types of val
? see https://github.com/go-sql-driver/mysql#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.
Because we don't restrict user config, it's hard to judge the type of val.
I use '
for all types and url.QueryEscape to escape string in 36e8103. MySQL extracts the relevant type from a string.
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.
can it work if add "" for number value?
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.
yes,see
dm/tests/all_mode/conf/dm-task.yaml
Line 20 in 9ec51cb
tidb_retry_limit: "10" |
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.
MySQL extracts the relevant type from a string.
Are there any docs/links explain about this?
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.
Seems not official. go-sql-driver/mysql#405 (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.
👍 you can add this as a comment above the code (the link in the about comment has out of date because it's not a permanent link).
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.
add commet in 5d57a5b
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.
LGTM. 👍
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.
LGTM
cherry pick to release-1.0 in PR #690 |
What problem does this PR solve?
Support setting session variables #677
What is changed and how it works?
add SessionConfig in TargetDB, set session variables in db.Apply.
Tests
Code changes