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

ALTER from DECIMAL and INT to DATETIME returns a wrong result

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1
    • Fix Version/s: 10.2.0
    • Component/s: Temporal Types
    • Labels:
      None

      Description

      These two scripts:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a DATETIME);
      INSERT INTO t1 VALUES (1000);
      SELECT * FROM t1;

      DROP TABLE IF EXISTS t1,t2;
      CREATE TABLE t1 (a DATETIME);
      CREATE TABLE t2 (a INT);
      INSERT INTO t2 VALUES (1000);
      INSERT INTO t1 SELECT * FROM t2;
      SELECT * FROM t1;

      return

      +---------------------+
      | a                   |
      +---------------------+
      | 2000-10-00 00:00:00 |
      +---------------------+

      This script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (1000);
      ALTER TABLE t1 MODIFY a DATETIME;
      SELECT * FROM t1;

      returns a different result:

      +---------------------+
      | a                   |
      +---------------------+
      | 0000-00-00 00:00:00 |
      +---------------------+

      All three cases are expected to return the same result.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: