-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
sessionctx: supports set character_set_results = null
#7314
Conversation
PTAL @coocood @jackysp @tiancaiamao |
/run-all-tests |
sessionctx/variable/sysvar.go
Outdated
@@ -391,7 +391,7 @@ var defaultSysVars = []*SysVar{ | |||
{ScopeGlobal | ScopeSession, "binlog_direct_non_transactional_updates", "OFF"}, | |||
{ScopeGlobal, "innodb_change_buffering", "all"}, | |||
{ScopeGlobal | ScopeSession, "sql_big_selects", "ON"}, | |||
{ScopeGlobal | ScopeSession, CharacterSetResults, "latin1"}, |
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 are planning to change it to "utf8". Will this solve your problem?
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.
Refer to #7198
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.
Changing it to "utf8" may not solve this problem. "show variables where variable_name='character_set_results'" result will become "utf8" after run "set character_set_results = null".
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.
How about setting the variable to empty string when it is null? |
Please add a test case for this pr. |
/run-all-tests |
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
/run-all-tests |
sessionctx/variable/varsutil.go
Outdated
sVal = "" | ||
} else { | ||
sVal, err = value.ToString() | ||
} |
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.
How about
if !value.IsNull() {
sVal, err = value.ToString()
}
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.
@imtbkcat please address this comment.
/ok-to-test |
/rebuild |
1 similar comment
/rebuild |
set character_set_results = null
/ok-to-test |
/rebuild |
var err error | ||
sVal, err = value.ToString() | ||
if !value.IsNull() { | ||
//return vars.deleteSystemVar(name) |
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.
Why do we need this comment?
/rebuild |
What have you changed? (mandatory)
When tidb executes "set character_set_results = null", it will delete "character_set_results" variable because we set it to null. (see executor/set.go:79)
This will delete "character_set_results". When we use show variable to show it, executor can not find it.
Then ShowExecutor will go to variable.SysVars to find its default value. (see executor/show.go:434)
Originally, variable.SysVars["character_set_results"] is "latin1", so the return value of "show variables where variable_name='character_set_results'" is "latin1". But "character_set_results" in TiDB is always "utf8", set variable can not effect it.
This PR just fix compatibility with mysql when execute "set character_set_results = null".
What is the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
unit test
After change:
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
No
Does this PR affect tidb-ansible update? (mandatory)
No
Does this PR need to be added to the release notes? (mandatory)
No
Refer to a related PR or issue link (optional)
Fix #7284
Benchmark result if necessary (optional)
Add a few positive/negative examples (optional)