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

Incosistent warnings from CAST(AS DATETIME) for different field types

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.0.6
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      This SQL script

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT, b REAL, c DECIMAL(20,6), d TIME,e CHAR(30));
      INSERT INTO t1 VALUES (-1,-1,-1,'-800:10:10','-800:10:10');
      SELECT CAST(a AS DATETIME) AS a, CAST(b AS DATETIME) AS b, CAST(c AS DATETIME) AS c,
      CAST(d AS DATETIME) AS d, CAST(e AS datetime) AS e FROM t1;
      SHOW WARNINGS;
      

      returns NULL for all columns:

      +------+------+------+------+------+
      | a    | b    | c    | d    | e    |
      +------+------+------+------+------+
      | NULL | NULL | NULL | NULL | NULL |
      +------+------+------+------+------+
      1 row in set, 5 warnings (0.00 sec)
      

      which is OK.

      But the warnings returned are different:

      +---------+------+--------------------------------------------------------+
      | Level   | Code | Message                                                |
      +---------+------+--------------------------------------------------------+
      | Warning | 1292 | Incorrect datetime value: '-1'                         |
      | Warning | 1292 | Incorrect datetime value: '-1' for column 'b' at row 1 |
      | Warning | 1292 | Incorrect datetime value: '-1.000000'                  |
      | Warning | 1292 | Truncated incorrect datetime value: '-800:10:10'       |
      | Warning | 1292 | Incorrect datetime value: '-800:10:10'                 |
      +---------+------+--------------------------------------------------------+
      5 rows in set (0.00 sec)
      

      Notice three different warning versions.

      This should probably be fixed to return the same warning
      for all column types.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            bar Alexander Barkov added a comment -

            There should not be field names (field names should be printed only on INSERT/UPDATE).

            Show
            bar Alexander Barkov added a comment - There should not be field names (field names should be printed only on INSERT/UPDATE).

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: