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

ALTER from DECIMAL and INT to DATETIME returns a wrong result

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5, 10.0, 10.1
    • 10.2.0
    • Temporal Types
    • 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

              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.