-
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
#7353
Conversation
/run-all-tests |
LGTM |
@@ -133,7 +133,8 @@ func (s *testSuite) TestSetVar(c *C) { | |||
c.Assert(charset, Equals, "utf8") | |||
c.Assert(collation, Equals, "utf8_bin") | |||
|
|||
tk.MustExec("set @@character_set_results = NULL") | |||
tk.MustExec("set character_set_results = NULL") | |||
tk.MustQuery("select @@character_set_results").Check(testkit.Rows("")) |
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.
In MySQL, it's very strange that will return NULL
instead of ""
in select @@
but return ""
in show variable
orz
mysql> select @@character_set_results ;
+-------------------------+
| @@character_set_results |
+-------------------------+
| utf8 |
+-------------------------+
1 row in set (0.00 sec)
mysql> set character_set_results = NULL;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@character_set_results ;
+-------------------------+
| @@character_set_results |
+-------------------------+
| NULL |
+-------------------------+
1 row in set (0.00 sec)
mysql> show variables where variable_name='character_set_results';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| character_set_results | |
+-----------------------+-------+
1 row in set (0.01 sec)
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 system variables in MySQL have their own types.
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
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)