Bug #84085 inconsistent states for system variables after PL routine finished

Submitted: 7 Dec 2016 2:30 Modified: 9 Dec 2016 6:52
Reporter: 帅 Bang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.7, 5.7.16 OS:Linux
Assigned to: CPU Architecture:Any

[7 Dec 2016 2:30] 帅 Bang
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
[8 Dec 2016 11:25] 帅 Bang
Excuse me, is there any progress  on this issue ?
[9 Dec 2016 6:52] MySQL Verification Team
Hello Bang,

Thank you for the report.

Thanks,
Umesh

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.