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

Warnings are not reset on SELECT not touching any tables

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • 10.0.14
    • N/A
    • OTHER

    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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.