设置系统变量' sql_warnings'到0,为什么还要收到警告?

时间:2016-02-17 09:48:49

标签: mysql

重新创建SQL:

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');

输出:

mysql> create table t1 (c1 int, c2 int);
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.01 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)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.8-rc  |
+-----------+
1 row in set (0.00 sec)

从输出中,无论将sql_warnings设置为0还是1,我总是在INSERT语句中收到警告。 谁知道为什么?

更新

&#34>显示变量的结果'%sql_warnings%';"在上面添加。

1 个答案:

答案 0 :(得分:1)

向MySQL提交了一个错误,他们将其验证为版本5.0到5.7的错误。

http://bugs.mysql.com/bug.php?id=80404

我很好奇为什么以前找不到这种明显的行为。