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

CURRENT_TIMESTAMP should return a TIMESTAMP (WITH TIME ZONE?)

Details

    Description

      create table t1 as select now();
      show create table t1;
      

      returns

      +-------+----------------------------------------------------------------------------------------+
      | Table | Create Table                                                                           |
      +-------+----------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `now()` datetime NOT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
      +-------+----------------------------------------------------------------------------------------+
      

      should be timestamp.

      These functions should also return TIMESTAMP:

      • FROM_UNIXTIME()
      • SYSDATE()

      Note, the function LOCALTIMESTAMP() according to the SQL Standard returns TIMESTAMP WITHOUT TIME ZONE, therefore we'll keep its return type as DATETIME.

      This change is (among other things) expected to fix the following problem:

      SET time_zone='Europe/Moscow';
      CREATE OR REPLACE TABLE t1 (a TIMESTAMP);
       
      SET timestamp=1288477526 /*summer time in Moscow*/;
      INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));
       
      SET timestamp=1288477526+3599 /*winter time in Moscow*/;
      INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));
       
      SELECT a, UNIX_TIMESTAMP(a) FROM t1;
      DROP TABLE t1;
      

      +---------------------+-------------------+
      | a                   | UNIX_TIMESTAMP(a) |
      +---------------------+-------------------+
      | 2010-10-31 02:25:26 |        1288477526 |
      | 2010-10-31 02:25:26 |        1288477526 |
      | 2010-10-31 02:25:25 |        1288481125 | <-- this value is good
      | 2010-10-31 02:25:25 |        1288477525 | <-- this value is wrong
      +---------------------+-------------------+
      

      Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:

      • Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
      • Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

      After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with CURRENT_TIMESTAMP().

      Attachments

        Issue Links

          Activity

            serg Sergei Golubchik created issue -
            serg Sergei Golubchik made changes -
            Field Original Value New Value
            bar Alexander Barkov added a comment - - edited

            According to the standard, it should return TIMESTAMP WITH TIMEZONE:

            The declared type of a <current timestamp value function> is TIMESTAMP WITH TIME ZONE.

            While, the best name for MariaDB's TIMESTAMP is "TIMESTAMP WITH LOCAL TIME ZONE".

            So perhaps we should implement MDEV-10018 first.

            bar Alexander Barkov added a comment - - edited According to the standard, it should return TIMESTAMP WITH TIMEZONE: The declared type of a <current timestamp value function> is TIMESTAMP WITH TIME ZONE. While, the best name for MariaDB's TIMESTAMP is " TIMESTAMP WITH LOCAL TIME ZONE ". So perhaps we should implement MDEV-10018 first.
            bar Alexander Barkov made changes -
            Summary CURRENT_TIMESTAMP should return a TIMESTAMP CURRENT_TIMESTAMP should return a TIMESTAMP [WITH TIME ZONE?]
            bar Alexander Barkov made changes -
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.4 [ 22408 ]
            bar Alexander Barkov made changes -
            serg Sergei Golubchik made changes -
            Rank Ranked higher
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 10.6 [ 24028 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Assignee Alexander Barkov [ bar ]
            bar Alexander Barkov made changes -
            Component/s Data types [ 13906 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 86333 ] MariaDB v4 [ 130812 ]
            AirFocus AirFocus made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}
            returns
            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}
            should be timestamp
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Assignee Alexander Barkov [ bar ]
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()

            bar Alexander Barkov made changes -
            Fix Version/s 11.0 [ 28320 ]
            bar Alexander Barkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            bar Alexander Barkov added a comment - Hello serg , please review a patch for this task: https://github.com/MariaDB/server/commit/fec3696fef6fb5a0be5f78632c056382f227e778
            bar Alexander Barkov made changes -
            Status In Progress [ 3 ] In Review [ 10002 ]
            bar Alexander Barkov made changes -
            Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 11.3 [ 28565 ]
            Fix Version/s 11.0 [ 28320 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 11.4 [ 29301 ]
            Fix Version/s 11.3 [ 28565 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 11.5 [ 29506 ]
            Fix Version/s 11.4 [ 29301 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 11.6 [ 29515 ]
            Fix Version/s 11.5 [ 29506 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 11.7 [ 29815 ]
            Fix Version/s 11.6 [ 29515 ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()

            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is among other things is expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 |
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is among other things is expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 |
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 |
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 |
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with NOW().
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with CURRENT_TIMESTAMP().
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()


            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with CURRENT_TIMESTAMP().
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()

            Note, the function LOCALTIMESTAMP() according to the SQL Standard return TIMESTAMP WITHOUT TIME ZONE, therefore we'll keep its return type as DATETIME.

            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with CURRENT_TIMESTAMP().
            bar Alexander Barkov made changes -
            Description {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()

            Note, the function LOCALTIMESTAMP() according to the SQL Standard return TIMESTAMP WITHOUT TIME ZONE, therefore we'll keep its return type as DATETIME.

            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with CURRENT_TIMESTAMP().
            {code:sql}
            create table t1 as select now();
            show create table t1;
            {code}

            returns

            {noformat}
            +-------+----------------------------------------------------------------------------------------+
            | Table | Create Table |
            +-------+----------------------------------------------------------------------------------------+
            | t1 | CREATE TABLE `t1` (
              `now()` datetime NOT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
            +-------+----------------------------------------------------------------------------------------+
            {noformat}

            should be timestamp.

            These functions should also return TIMESTAMP:
            - FROM_UNIXTIME()
            - SYSDATE()

            Note, the function LOCALTIMESTAMP() according to the SQL Standard returns TIMESTAMP WITHOUT TIME ZONE, therefore we'll keep its return type as DATETIME.

            This change is (among other things) expected to fix the following problem:
            {code:sql}
            SET time_zone='Europe/Moscow';
            CREATE OR REPLACE TABLE t1 (a TIMESTAMP);

            SET timestamp=1288477526 /*summer time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SET timestamp=1288477526+3599 /*winter time in Moscow*/;
            INSERT INTO t1 VALUES (CURRENT_TIMESTAMP()), (COALESCE(CURRENT_TIMESTAMP()));

            SELECT a, UNIX_TIMESTAMP(a) FROM t1;
            DROP TABLE t1;
            {code}
            {noformat}
            +---------------------+-------------------+
            | a | UNIX_TIMESTAMP(a) |
            +---------------------+-------------------+
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:26 | 1288477526 |
            | 2010-10-31 02:25:25 | 1288481125 | <-- this value is good
            | 2010-10-31 02:25:25 | 1288477525 | <-- this value is wrong
            +---------------------+-------------------+
            {noformat}

            Notice, on the second INSERT statement (soon after DST fallback), CURRENT_TIMESTAMP() and COALESCE(CURRENT_TIMESTAMP()) inserted different values because:
            - Insertion of CURRENT_TIMESTAMP() works in TIMESTAMP format due to a hack in Item_func_now_local::save_in_field
            - Insertion of COALESCE(CURRENT_TIMESTAMP()) works in DATETIME format.

            After the change COALESCE(CURRENT_TIMESTAMP()) is expected to insert the same value with CURRENT_TIMESTAMP().
            bar Alexander Barkov made changes -
            serg Sergei Golubchik made changes -
            Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Status Stalled [ 10000 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Issue Type Task [ 3 ] New Feature [ 2 ]
            serg Sergei Golubchik made changes -
            Priority Major [ 3 ] Critical [ 2 ]

            b626f5398dc is ok

            serg Sergei Golubchik added a comment - b626f5398dc is ok
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            bar Alexander Barkov made changes -
            Status Stalled [ 10000 ] In Testing [ 10301 ]
            bar Alexander Barkov made changes -
            Assignee Alexander Barkov [ bar ] Elena Stepanova [ elenst ]
            bar Alexander Barkov added a comment - elenst , please find the patch here: https://github.com/MariaDB/server/tree/bb-11.7-MDEV-15751-timestamp Thanks.
            serg Sergei Golubchik made changes -
            elenst Elena Stepanova made changes -
            Assignee Elena Stepanova [ elenst ] Ramesh Sivaraman [ JIRAUSER48189 ]
            serg Sergei Golubchik made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            Labels Preview_11.7

            ramesh, I force-pushed the branch. There was a test failure on 32bit platforms.

            bar Alexander Barkov added a comment - ramesh , I force-pushed the branch. There was a test failure on 32bit platforms.

            bar ack, latest commit will be used for testing.

            ramesh Ramesh Sivaraman added a comment - bar ack, latest commit will be used for testing.
            julien.fritsch Julien Fritsch made changes -
            Summary CURRENT_TIMESTAMP should return a TIMESTAMP [WITH TIME ZONE?] CURRENT_TIMESTAMP should return a TIMESTAMP (WITH TIME ZONE?)

            okay to push

            ramesh Ramesh Sivaraman added a comment - okay to push
            ramesh Ramesh Sivaraman made changes -
            Assignee Ramesh Sivaraman [ JIRAUSER48189 ] Alexander Barkov [ bar ]
            Status In Testing [ 10301 ] Stalled [ 10000 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Assignee Alexander Barkov [ bar ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Fix Version/s 11.7.1 [ 29913 ]
            Fix Version/s 11.7 [ 29815 ]
            Assignee Sergei Golubchik [ serg ] Alexander Barkov [ bar ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            bar Alexander Barkov made changes -
            itsonlybinary ItsOnlyBinary made changes -
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            serg Sergei Golubchik made changes -

            People

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