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

Wrong result for INSERT INTO t1 (datetime_field) VALUES (hybrid_function_of_TIME_data_type)

    XMLWordPrintable

Details

    Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATETIME);
      INSERT INTO t1 VALUES (TIME'10:20:30'),(COALESCE(TIME'10:20:30'));
      SHOW WARNINGS;
      SELECT * FROM t1;
      

      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1265 | Data truncated for column 'a' at row 2 |
      +---------+------+----------------------------------------+
      

      +---------------------+
      | a                   |
      +---------------------+
      | 2016-11-22 10:20:30 |
      | 0000-00-00 00:00:00 |
      +---------------------+
      

      This result is wrong. The expected result would be 2016-11-22 10:20:30 for both values.

      The same problem is repeatable in this script:

      SET timestamp=UNIX_TIMESTAMP('2001-02-03 10:20:30.123456');
      CREATE OR REPLACE TABLE t1 (a DECIMAL(30,6) DEFAULT COALESCE(CURRENT_TIMESTAMP(6)));
      SHOW CREATE TABLE t1;
      INSERT INTO t1 VALUES (CURRENT_TIMESTAMP(6));
      INSERT INTO t1 VALUES (COALESCE(CURRENT_TIMESTAMP(6)));
      INSERT INTO t1 VALUES();
      SELECT * FROM t1;
      

      +-----------------------+
      | a                     |
      +-----------------------+
      | 20010203102030.123456 |
      |           2001.000000 |
      |           2001.000000 |
      +-----------------------+
      

      The second and the third rows look wrong.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.