Bug #84085 inconsistent states for system variables after PL routine finished
Description:
mysql> use test;
Database changed
mysql> show variables like 'sql_mode';
+---------------+-------------------+
| Variable_name | Value |
+---------------+-------------------+
| sql_mode | STRICT_ALL_TABLES |
+---------------+-------------------+
1 row in set (0.00 sec)
mysql> show variables like 'collation_connection';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
+----------------------+--------------------+
1 row in set (0.00 sec)
mysql> show variables like 'lock_wait_timeout';
+-------------------+----------+
| Variable_name | Value |
+-------------------+----------+
| lock_wait_timeout | 31536000 |
+-------------------+----------+
1 row in set (0.00 sec)
mysql> delimiter //
mysql> CREATE PROCEDURE dorepeat(p1 INT)
-> BEGIN
->
-> set sql_mode = '';
-> set collation_connection = 'utf8_bin';
-> set lock_wait_timeout = 100;
->
-> END //
Query OK, 0 rows affected (0.01 sec)
mysql> delimiter ;
mysql> call dorepeat(10);
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'sql_mode';
+---------------+-------------------+
| Variable_name | Value |
+---------------+-------------------+
| sql_mode | STRICT_ALL_TABLES |
+---------------+-------------------+
1 row in set (0.00 sec)
mysql> show variables like 'collation_connection';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
+----------------------+--------------------+
1 row in set (0.01 sec)
mysql> show variables like 'lock_wait_timeout';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| lock_wait_timeout | 100 |
+-------------------+-------+
1 row in set (0.01 sec)
As can be seen that, only lock_wait_timeout has been changed after the routine finished while, collation_connection and sql_mode both stay the same.
Why? is it a bug ?
How to repeat:
show variables like 'sql_mode';
show variables like 'collation_connection';
show variables like 'lock_wait_timeout';
delimiter //
CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
set sql_mode = '';
set collation_connection = 'utf8_bin';
set lock_wait_timeout = 100;
END //
delimiter ;
call dorepeat(10);
show variables like 'sql_mode';
show variables like 'collation_connection';
show variables like 'lock_wait_timeout';
Suggested fix:
all are changed
or
all stay the same
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: mysql> use test; Database changed mysql> show variables like 'sql_mode'; +---------------+-------------------+ | Variable_name | Value | +---------------+-------------------+ | sql_mode | STRICT_ALL_TABLES | +---------------+-------------------+ 1 row in set (0.00 sec) mysql> show variables like 'collation_connection'; +----------------------+--------------------+ | Variable_name | Value | +----------------------+--------------------+ | collation_connection | utf8mb4_general_ci | +----------------------+--------------------+ 1 row in set (0.00 sec) mysql> show variables like 'lock_wait_timeout'; +-------------------+----------+ | Variable_name | Value | +-------------------+----------+ | lock_wait_timeout | 31536000 | +-------------------+----------+ 1 row in set (0.00 sec) mysql> delimiter // mysql> CREATE PROCEDURE dorepeat(p1 INT) -> BEGIN -> -> set sql_mode = ''; -> set collation_connection = 'utf8_bin'; -> set lock_wait_timeout = 100; -> -> END // Query OK, 0 rows affected (0.01 sec) mysql> delimiter ; mysql> call dorepeat(10); Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'sql_mode'; +---------------+-------------------+ | Variable_name | Value | +---------------+-------------------+ | sql_mode | STRICT_ALL_TABLES | +---------------+-------------------+ 1 row in set (0.00 sec) mysql> show variables like 'collation_connection'; +----------------------+--------------------+ | Variable_name | Value | +----------------------+--------------------+ | collation_connection | utf8mb4_general_ci | +----------------------+--------------------+ 1 row in set (0.01 sec) mysql> show variables like 'lock_wait_timeout'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | lock_wait_timeout | 100 | +-------------------+-------+ 1 row in set (0.01 sec) As can be seen that, only lock_wait_timeout has been changed after the routine finished while, collation_connection and sql_mode both stay the same. Why? is it a bug ? How to repeat: show variables like 'sql_mode'; show variables like 'collation_connection'; show variables like 'lock_wait_timeout'; delimiter // CREATE PROCEDURE dorepeat(p1 INT) BEGIN set sql_mode = ''; set collation_connection = 'utf8_bin'; set lock_wait_timeout = 100; END // delimiter ; call dorepeat(10); show variables like 'sql_mode'; show variables like 'collation_connection'; show variables like 'lock_wait_timeout'; Suggested fix: all are changed or all stay the same