Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-7291

Warnings are not reset on SELECT not touching any tables

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a Bug
    • Affects Version/s: 10.0.14
    • Fix Version/s: N/A
    • Component/s: OTHER
    • Labels:

      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

              Hide
              elenst Elena Stepanova added a comment -

              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.

              Show
              elenst Elena Stepanova added a comment - 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.
              Hide
              elenst Elena Stepanova added a comment -

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

              Show
              elenst Elena Stepanova added a comment - Oracle closed it as not a bug, I'm closing it too. Please comment if you disagree.

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  hholzgra Hartmut Holzgraefe
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: