[MDEV-6941] SET STATEMENT affects the value of the GLOBAL variable for the duration of the statement Created: 2014-10-24  Updated: 2015-02-02  Resolved: 2014-10-26

Status: Closed
Project: MariaDB Server
Component/s: Admin statements
Affects Version/s: N/A
Fix Version/s: 10.1.2

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-5231 Per query variables from Percona Serv... Closed
relates to MDEV-6923 Testing for SET STATEMENT .. FOR (MDE... Closed

 Description   

Output of the test case below

# Initial values
SELECT @@global.lock_wait_timeout, @@lock_wait_timeout;
@@global.lock_wait_timeout	@@lock_wait_timeout
31536000	31536000
# 
set statement lock_wait_timeout=11 for show global variables like 'lock_wait_timeout';
Variable_name	Value
lock_wait_timeout	31536000
SET STATEMENT lock_wait_timeout=12 FOR SELECT SLEEP(2.5);
connect con1,localhost,root;
# 
# It's a new connection, so it picked up the current value 
# of the global variable for the session variable
SELECT @@global.lock_wait_timeout, @@lock_wait_timeout;
@@global.lock_wait_timeout	@@lock_wait_timeout
12	12
# 
# Now SET STATEMENT in the other connection ended, so the global value
# is back to normal (but the session one is not)
SELECT @@global.lock_wait_timeout, @@lock_wait_timeout;
@@global.lock_wait_timeout	@@lock_wait_timeout
31536000	12

Test case

--enable_connect_log
 
--echo # Initial values
SELECT @@global.lock_wait_timeout, @@lock_wait_timeout;
 
--echo # 
set statement lock_wait_timeout=11 for show global variables like 'lock_wait_timeout';
--send SET STATEMENT lock_wait_timeout=12 FOR SELECT SLEEP(2.5)
 
--sleep 1
--connect(con1,localhost,root)
--echo # 
--echo # It's a new connection, so it picked up the current value 
--echo # of the global variable for the session variable
SELECT @@global.lock_wait_timeout, @@lock_wait_timeout;
--sleep 2
--echo # 
--echo # Now SET STATEMENT in the other connection ended, so the global value
--echo # is back to normal (but the session one is not)
SELECT @@global.lock_wait_timeout, @@lock_wait_timeout;

commit 3a3f88e789a41b309cfe902f4823c9c7ebbce6ca
Author: Oleksandr Byelkin <sanja@mariadb.com>
Date:   Fri Oct 24 10:13:08 2014 +0200
 
    MDEV-5231: Per query variables from Percona Server (rewritten)



 Comments   
Comment by Elena Stepanova [ 2014-10-24 ]

In Percona-server it's worse, since the global value does not get restored (see bug#1385352)

Comment by Oleksandr Byelkin [ 2014-10-26 ]

It is duplicate (by problem) of MDEV-6940

Generated at Thu Feb 08 07:15:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.