Bug #80404 After sql_warnings to 0, the INSERT still get warnings message
Submitted: 17 Feb 2016 11:06 Modified: 17 Feb 2016 13:24
Reporter: Su Dylan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.0/5.1/5.5/5.6/5.7 OS:Any
Assigned to: CPU Architecture:Any

[17 Feb 2016 11:06] Su Dylan
Description:
Output:
=====
mysql>
mysql> set sql_mode = '';
Query OK, 0 rows affected (0.00 sec)

mysql> create table t1 (c1 int, c2 int);
set sql_warnings = 0;
Query OK, 0 rows affected (0.01 sec)

mysql> set sql_warnings = 0;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE '%sql_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_warnings  | OFF   |
+---------------+-------+
1 row in set, 1 warning (0.00 sec)

mysql> insert into t1 values(1,'b');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql>
mysql> set sql_warnings = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE '%sql_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_warnings  | ON    |
+---------------+-------+
1 row in set, 1 warning (0.00 sec)

mysql> insert into t1 values(1,'b');
Query OK, 1 row affected, 1 warning (0.00 sec)

Problem:
=====
After sql_warnings to 0, the INSERT still get warnings message.

How to repeat:
drop table t1;

set sql_mode = '';
create table t1 (c1 int, c2 int); 
set sql_warnings = 0;
SHOW VARIABLES LIKE '%sql_warnings%';
insert into t1 values(1,'b');

set sql_warnings = 1;
SHOW VARIABLES LIKE '%sql_warnings%';
insert into t1 values(1,'b');

Suggested fix:
After sql_warnings to 0, the INSERT returns NO warnings.
[17 Feb 2016 13:24] MySQL Verification Team
Thank you for the bug report. That behavior exists since 5.0.

C:\dbs>c:\dbs\5.7\bin\mysql -uroot -p --port=3570 --prompt="mysql 5.7 > "
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.12 Source distribution PULL: 2016-FEB-06

Copyright (c) 2000, 2016, 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 5.7 > use test
Database changed
mysql 5.7 > drop table t1;
Query OK, 0 rows affected (0.03 sec)

mysql 5.7 >
mysql 5.7 > set sql_mode = '';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql 5.7 > create table t1 (c1 int, c2 int);
Query OK, 0 rows affected (0.03 sec)

mysql 5.7 > set sql_warnings = 0;
Query OK, 0 rows affected (0.00 sec)

mysql 5.7 > SHOW VARIABLES LIKE '%sql_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_warnings  | OFF   |
+---------------+-------+
1 row in set (0.00 sec)

mysql 5.7 > insert into t1 values(1,'b');
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql 5.7 >
mysql 5.7 > set sql_warnings = 1;
Query OK, 0 rows affected (0.00 sec)

mysql 5.7 > SHOW VARIABLES LIKE '%sql_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_warnings  | ON    |
+---------------+-------+
1 row in set (0.00 sec)

mysql 5.7 > insert into t1 values(1,'b');
Query OK, 1 row affected, 1 warning (0.04 sec)

mysql 5.7 >