[MDEV-7291] Warnings are not reset on SELECT not touching any tables Created: 2014-12-08  Updated: 2015-01-29  Resolved: 2015-01-29

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0.14
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Hartmut Holzgraefe Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: upstream


 Description   

see also http://bugs.mysql.com/bug.php?id=75141

mysql 5.7 >  select cast('foo' as unsigned);
+-------------------------+
| cast('foo' as unsigned) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)
 
mysql 5.7 > show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'foo' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

mysql 5.7 > select cast('bar' as unsigned);
+-------------------------+
| cast('bar' as unsigned) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)
 
mysql 5.7 > show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'bar' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

mysql 5.7 > select cast(42.0 as unsigned);
+------------------------+
| cast(42.0 as unsigned) |
+------------------------+
|                     42 |
+------------------------+
1 row in set (0.00 sec)
 
mysql 5.7 > show warnings;
Empty set (0.00 sec)
 
mysql 5.7 > select cast(42.0 as unsigned) from mysql.user limit 1;
+------------------------+
| cast(42.0 as unsigned) |
+------------------------+
|                     42 |
+------------------------+
1 row in set (0.00 sec)
 
mysql 5.7 > show warnings;
Empty set (0.00 sec)

------------------------------------------------------------------------

[8 Dec 15:21] Miguel Solorzano
 
C:\dbs>c:\dbs\5.6\bin\mysql -uroot --port=3560 --debug-info
--prompt="mysql 5.6 > "
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.23 Source distribution 2014.12.02
 
Copyright (c) 2000, 2014, 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.6 >  select cast('foo' as unsigned);
+-------------------------+
| cast('foo' as unsigned) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)
 
mysql 5.6 > show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'foo' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
 
mysql 5.6 > select cast('bar' as unsigned);
+-------------------------+
| cast('bar' as unsigned) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)
 
mysql 5.6 > show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'bar' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
 
mysql 5.6 > select cast(42.0 as unsigned);
+------------------------+
| cast(42.0 as unsigned) |
+------------------------+
|                     42 |
+------------------------+
1 row in set (0.00 sec)
 
mysql 5.6 > show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'bar' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
 
mysql 5.6 > select cast(42.0 as unsigned) from mysql.user limit 1;
+------------------------+
| cast(42.0 as unsigned) |
+------------------------+
|                     42 |
+------------------------+
1 row in set (0.00 sec)
 
mysql 5.6 > show warnings;
Empty set (0.00 sec)
 
mysql 5.6 >
 
 
------------------------------------------------------------------------
 
[8 Dec 14:35] Hartmut Holzgraefe
 
Description:
Warnings are not reset on successful execution of a SELECT statement
without FROM clause or when using the dummy "FROM DUAL". If the
statement raises a new warning though the old warnings are replaced.
 
How to repeat:
MySQL [test]> select cast('foo' as unsigned);
+-------------------------+
| cast('foo' as unsigned) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)
 
MySQL [test]> show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'foo' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
 
MySQL [test]> select cast('bar' as unsigned);
+-------------------------+
| cast('bar' as unsigned) |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set, 1 warning (0.00 sec)
 
MySQL [test]> show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'bar' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
 
MySQL [test]> select cast(42.0 as unsigned);
+------------------------+
| cast(42.0 as unsigned) |
+------------------------+
|                     42 |
+------------------------+
1 row in set (0.00 sec)
 
MySQL [test]> show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'bar' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
 
MySQL [test]> select cast(42.0 as unsigned) from dual;
+------------------------+
| cast(42.0 as unsigned) |
+------------------------+
|                     42 |
+------------------------+
1 row in set (0.00 sec)
 
MySQL [test]> show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'bar' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)
 
MySQL [test]> select cast(42.0 as unsigned) from mysql.user limit 1;
+------------------------+
| cast(42.0 as unsigned) |
+------------------------+
|                     42 |
+------------------------+
1 row in set (0.00 sec)
 
MySQL [test]> show warnings;
Empty set (0.00 sec)

Suggested fix:
Always reset warnings after on successful execution of a SELECT



 Comments   
Comment by Elena Stepanova [ 2014-12-08 ]

It's explicitly documented behavior: http://dev.mysql.com/doc/refman/5.5/en/show-warnings.html

SHOW WARNINGS displays information about the conditions resulting from the most recent statement in the current session that generated messages. It shows nothing if the most recent statement used a table and generated no messages. (That is, statements that use a table but generate no messages clear the message list.) Statements that do not use tables and do not generate messages have no effect on the message list.

Lets see what Oracle are going to do with this bug report.

Comment by Elena Stepanova [ 2015-01-29 ]

Oracle closed it as not a bug, I'm closing it too. Please comment if you disagree.

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