Details
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
Gliffy Diagrams
Attachments
Issue Links
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
It's explicitly documented behavior: http://dev.mysql.com/doc/refman/5.5/en/show-warnings.html
Lets see what Oracle are going to do with this bug report.