SET STATEMENT does not work after SET GLOBAL / SHOW GLOBAL STATUS and affects the global value
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS | Status tracked in 5.7 | |||||
5.5 |
Invalid
|
Undecided
|
Unassigned | |||
5.6 |
Fix Released
|
Medium
|
Laurynas Biveinis | |||
5.7 |
Fix Released
|
Medium
|
Laurynas Biveinis |
Bug Description
# Initial values:
MySQL [test]> select @@global.
+------
| @@global.
+------
| 31536000 | 31536000 |
+------
1 row in set (0.01 sec)
# SET STATEMENT works (OK):
MySQL [test]> set statement lock_wait_timeout=1 for select @@lock_
+------
| @@lock_wait_timeout |
+------
| 1 |
+------
1 row in set (0.00 sec)
# Initial values are intact (OK):
MySQL [test]> select @@global.
+------
| @@global.
+------
| 31536000 | 31536000 |
+------
1 row in set (0.00 sec)
# Setting a totally unrelated global variable:
MySQL [test]> set global general_log=0;
Query OK, 0 rows affected (0.01 sec)
# Initial values are still intact (OK):
MySQL [test]> select @@global.
+------
| @@global.
+------
| 31536000 | 31536000 |
+------
1 row in set (0.00 sec)
# ... but SET STATEMENT does not work anymore (FAIL):
MySQL [test]> set statement lock_wait_timeout=1 for select @@lock_
+------
| @@lock_wait_timeout |
+------
| 31536000 |
+------
1 row in set (0.00 sec)
# ... and it corrupts the global value (BIG FAIL):
MySQL [test]> select @@global.
+------
| @@global.
+------
| 1 | 31536000 |
+------
1 row in set (0.00 sec)
tags: | added: set-statement |
This is easy to confirm:
[openxs@centos ~]$ mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21-69.0 Percona Server (GPL), Release 69.0, Revision 675
Copyright (c) 2009-2014 Percona LLC and/or its affiliates
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select @@global. lock_wait_ timeout, @@session. lock_wait_ timeout; ------- ------- ------- -+----- ------- ------- ------- ---+ lock_wait_ timeout | @@session. lock_wait_ timeout | ------- ------- ------- -+----- ------- ------- ------- ---+ ------- ------- ------- -+----- ------- ------- ------- ---+
+------
| @@global.
+------
| 31536000 | 31536000 |
+------
1 row in set (0.00 sec)
mysql> set statement lock_wait_timeout=1 for select @@lock_ wait_timeout; ------- ------- -+ ------- ------- -+ ------- ------- -+
+------
| @@lock_wait_timeout |
+------
| 1 |
+------
1 row in set (0.00 sec)
mysql> select @@global. lock_wait_ timeout, @@session. lock_wait_ timeout; ------- ------- ------- -+----- ------- ------- ------- ---+ lock_wait_ timeout | @@session. lock_wait_ timeout | ------- ------- ------- -+----- ------- ------- ------- ---+ ------- ------- ------- -+----- ------- ------- ------- ---+
+------
| @@global.
+------
| 31536000 | 31536000 |
+------
1 row in set (0.00 sec)
mysql> set global general_log=0;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@global. lock_wait_ timeout, @@session. lock_wait_ timeout; ------- ------- ------- -+----- ------- ------- ------- ---+ lock_wait_ timeout | @@session. lock_wait_ timeout | ------- ------- ------- -+----- ------- ------- ------- ---+ ------- ------- ------- -+----- ------- ------- ------- ---+
+------
| @@global.
+------
| 31536000 | 31536000 |
+------
1 row in set (0.00 sec)
mysql> set statement lock_wait_timeout=1 for select @@lock_ wait_timeout; ------- ------- -+ ------- ------- -+ ------- ------- -+
+------
| @@lock_wait_timeout |
+------
| 31536000 |
+------
1 row in set (0.00 sec)
mysql> select @@global. lock_wait_ timeout, @@session. lock_wait_ timeout; ------- ------- ------- -+----- ------- ------- ------- ---+ lock_wait_ timeout | @@session. lock_wait_ timeout | ------- ------- ------- -+----- ------- ------- ------- ---+ ------- ------- ------- -+----- ------- ------- ------- ---+
+------
| @@global.
+------
| 1 | 31536000 |
+------
1 row in set (0.00 sec)