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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.0.6
    • 10.2
    • None
    • 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:

              Git Integration

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