forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FB8-117: Add thread ID option for SQL SET command (facebook#1012) (fa…
…cebook#1012) Summary: Jira issue: https://jira.percona.com/browse/FB8-117 Reference Patch: facebook@19f5aad Added thread ID option to the SQL SET command. The syntax of the command is as follows: `SET SESSION [THREAD_ID] var_name = var_value [, [SESSION [THREAD_ID]] var_name = var_value]` Notes: - The thread ID can be specified only with the SESSION keyword - If no thread ID is provided, it is assumed to be the current thread - Similarly, if own thread ID is provided, it is equivalent to `SET var_name = var_value` - If the thread with given ID does not exist, it will fail - For commands like `SET SESSION THREAD_ID var1 = var_value1, var2 = var_value2, var3 = var_value3` the SESSION THREAD_ID will apply to all three variables as explained in https://dev.mysql.com/doc/refman/5.6/en/set-variable.html Pull Request resolved: facebook#1012 Reviewed By: lloyd Differential Revision: D15773495 Pulled By: lth
- Loading branch information
Showing
12 changed files
with
395 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
CREATE USER mysqluser1; | ||
SET max_join_size = 1000; | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET max_join_size = 2000; | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION $mysqluser1 max_join_size = 1001; | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION $mysqluser1 innodb_lock_wait_timeout = 100; | ||
SET SESSION $conn_root max_join_size = 2001; | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION max_join_size = 2002; | ||
include/assert.inc [Check if max_join_size is correct] | ||
include/assert.inc [Check if max_join_size is correct] | ||
include/assert.inc [Check if innodb_lock_wait_timeout is correct] | ||
SET SESSION $conn_mysqluser1 max_join_size = 1002, SESSION $conn_root max_join_size = 2003; | ||
include/assert.inc [Check if max_join_size is correct] | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION $conn_root max_join_size = 1003, SESSION $conn_root max_join_size = 2004; | ||
ERROR 42000: Access denied; you need (at least one of) the SUPER or SYSTEM_VARIABLES_ADMIN privilege(s) for this operation | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION $mysqluser1 max_join_size = 1003; | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION max_join_size = 1004; | ||
include/assert.inc [Check if max_join_size is correct] | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION $conn_mysqluser1 max_join_size = 1005, max_sort_length = 30, SESSION $conn_root max_join_size = 2004, max_sort_length = 31; | ||
include/assert.inc [Check if max_join_size is correct] | ||
include/assert.inc [Check if max_join_size is correct] | ||
SET SESSION 999 max_join_size = 9999; | ||
ERROR HY000: Unknown thread id: 999 | ||
SET GLOBAL 1 max_join_size = 1000; | ||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 max_join_size = 1000' at line 1 | ||
SET SESSION -1 max_join_size = 1000; | ||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1 max_join_size = 1000' at line 1 | ||
SET SESSION 1 TRANSACTION READ WRITE; | ||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'READ WRITE' at line 1 | ||
SET GLOBAL TRANSACTION READ ONLY; | ||
SET SESSION TRANSACTION READ ONLY; | ||
include/assert.inc [Check if SET SESSION/GLOBAL TRANSACTION READ ONLY works correctly] | ||
SET GLOBAL TRANSACTION READ WRITE; | ||
SET SESSION TRANSACTION READ WRITE; | ||
DROP USER mysqluser1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
--source include/count_sessions.inc | ||
|
||
# | ||
# test SET VARIABLES with thread id | ||
# | ||
|
||
--let $conn_root = `SELECT CONNECTION_ID()` | ||
|
||
# Create a regular user | ||
CREATE USER mysqluser1; | ||
|
||
--connect (user1,localhost,mysqluser1) | ||
--let $conn_mysqluser1 = `SELECT CONNECTION_ID()` | ||
|
||
# Set a variable for current thd | ||
SET max_join_size = 1000; | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 1000 | ||
--source include/assert.inc | ||
|
||
|
||
# Connect as root | ||
--connection default | ||
|
||
# Set a variable for current thd | ||
SET max_join_size = 2000; | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 2000 | ||
--source include/assert.inc | ||
|
||
# Set variable for user1 thd from root thd | ||
--replace_regex /SESSION [0-9]*/SESSION $mysqluser1/ | ||
--eval SET SESSION $conn_mysqluser1 max_join_size = 1001 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 2000 | ||
--source include/assert.inc | ||
|
||
--replace_regex /SESSION [0-9]*/SESSION $mysqluser1/ | ||
--eval SET SESSION $conn_mysqluser1 innodb_lock_wait_timeout = 100 | ||
|
||
# Set variable for root thd from root thd | ||
--replace_regex /SESSION [0-9]*/SESSION $conn_root/ | ||
--eval SET SESSION $conn_root max_join_size = 2001 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 2001 | ||
--source include/assert.inc | ||
|
||
# Set variable for root thd from root thd without session ID | ||
SET SESSION max_join_size = 2002; | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 2002 | ||
--source include/assert.inc | ||
|
||
|
||
--connection user1 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 1001 | ||
--source include/assert.inc | ||
|
||
--let $assert_text = Check if innodb_lock_wait_timeout is correct | ||
--let $assert_cond = @@innodb_lock_wait_timeout = 100 | ||
--source include/assert.inc | ||
|
||
|
||
# Reconnect as root | ||
--connection default | ||
|
||
# Set variable for both current thd and user1 from root thd | ||
--replace_regex /SESSION [0-9]* max_join_size = 1002, SESSION [0-9]* max_join_size = 2003/SESSION $conn_mysqluser1 max_join_size = 1002, SESSION $conn_root max_join_size = 2003/ | ||
--eval SET SESSION $conn_mysqluser1 max_join_size = 1002, SESSION $conn_root max_join_size = 2003 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 2003 | ||
--source include/assert.inc | ||
|
||
|
||
--connection user1 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 1002 | ||
--source include/assert.inc | ||
|
||
# Set variable for root thd from user1 thd | ||
--replace_regex /SESSION [0-9]*/SESSION $conn_root/ /thread [0-9]*/thread $root/ | ||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR | ||
--eval SET SESSION $conn_mysqluser1 max_join_size = 1003, SESSION $conn_root max_join_size = 2004 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 1002 | ||
--source include/assert.inc | ||
|
||
# Set variable for user1 thd from user1 thd | ||
--replace_regex /SESSION [0-9]*/SESSION $mysqluser1/ | ||
--eval SET SESSION $conn_mysqluser1 max_join_size = 1003 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 1003 | ||
--source include/assert.inc | ||
|
||
# Set variable for user1 thd from user1 thd without session ID | ||
SET SESSION max_join_size = 1004; | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 1004 | ||
--source include/assert.inc | ||
|
||
|
||
--connection default | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 2003 | ||
--source include/assert.inc | ||
|
||
# Set multiple variables for both current thd and user1 from root thd | ||
--replace_regex /SESSION [0-9]* max_join_size = 1005/SESSION $conn_mysqluser1 max_join_size = 1005/ /SESSION [0-9]* max_join_size = 2004/SESSION $conn_root max_join_size = 2004/ | ||
--eval SET SESSION $conn_mysqluser1 max_join_size = 1005, max_sort_length = 30, SESSION $conn_root max_join_size = 2004, max_sort_length = 31 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 2004 AND @@max_sort_length = 31 | ||
--source include/assert.inc | ||
|
||
|
||
--connection user1 | ||
|
||
--let $assert_text = Check if max_join_size is correct | ||
--let $assert_cond = @@max_join_size = 1005 AND @@max_sort_length = 30 | ||
--source include/assert.inc | ||
|
||
--error ER_NO_SUCH_THREAD | ||
--eval SET SESSION 999 max_join_size = 9999 | ||
|
||
--error ER_PARSE_ERROR | ||
--eval SET GLOBAL 1 max_join_size = 1000 | ||
|
||
--error ER_PARSE_ERROR | ||
--eval SET SESSION -1 max_join_size = 1000 | ||
|
||
--error ER_PARSE_ERROR | ||
--eval SET SESSION 1 TRANSACTION READ WRITE | ||
|
||
--connection default | ||
SET GLOBAL TRANSACTION READ ONLY; | ||
SET SESSION TRANSACTION READ ONLY; | ||
--let $assert_text = Check if SET SESSION/GLOBAL TRANSACTION READ ONLY works correctly | ||
--let $assert_cond = @@GLOBAL.transaction_read_only = 1 AND @@transaction_read_only = 1 | ||
--source include/assert.inc | ||
SET GLOBAL TRANSACTION READ WRITE; | ||
SET SESSION TRANSACTION READ WRITE; | ||
|
||
# cleanup | ||
DROP USER mysqluser1; | ||
--disconnect user1 | ||
--source include/wait_until_count_sessions.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.