Details
-
New Feature
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
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
- blocks
-
MDEV-15750 preserve MYSQL_TYPE_TIMESTAMP in temporal arithmetics
-
- Stalled
-
- causes
-
MDEV-34932 differrent result in 32-bit in MDEV-15751
-
- Closed
-
-
MDEV-35250 Assertion `dec <= 6' failed in my_timestamp_binary_length
-
- Closed
-
- relates to
-
MDEV-15654 ADDTIME creates invalid timestamp value near DST changes
-
- Closed
-
-
MDEV-15750 preserve MYSQL_TYPE_TIMESTAMP in temporal arithmetics
-
- Stalled
-
-
MDEV-34037 DATETIME <-> TIMESTAMP conversion in a virtual column corrups the table on @@time_zone change
-
- In Review
-
-
MDEV-34829 LOCALTIME returns a wrong data type
-
- Closed
-
-
MDEV-36126 FROM_UNIXTIME(0) used in WHERE gives warning and results in no data being returned
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue relates to |
Summary | CURRENT_TIMESTAMP should return a TIMESTAMP | CURRENT_TIMESTAMP should return a TIMESTAMP [WITH TIME ZONE?] |
Fix Version/s | 10.6 [ 24028 ] | |
Fix Version/s | 10.4 [ 22408 ] |
Link | This issue is blocked by MDEV-10018 [ MDEV-10018 ] |
Rank | Ranked higher |
Fix Version/s | 10.6 [ 24028 ] |
Assignee | Alexander Barkov [ bar ] |
Component/s | Data types [ 13906 ] |
Workflow | MariaDB v3 [ 86333 ] | MariaDB v4 [ 130812 ] |
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 |
Link | This issue relates to MDEV-15750 [ MDEV-15750 ] |
Assignee | Alexander Barkov [ bar ] |
Link | This issue blocks MDEV-15750 [ MDEV-15750 ] |
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() |
Fix Version/s | 11.0 [ 28320 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Alexander Barkov [ bar ] | Sergei Golubchik [ serg ] |
Fix Version/s | 11.3 [ 28565 ] | |
Fix Version/s | 11.0 [ 28320 ] |
Fix Version/s | 11.4 [ 29301 ] | |
Fix Version/s | 11.3 [ 28565 ] |
Fix Version/s | 11.5 [ 29506 ] | |
Fix Version/s | 11.4 [ 29301 ] |
Fix Version/s | 11.6 [ 29515 ] | |
Fix Version/s | 11.5 [ 29506 ] |
Fix Version/s | 11.7 [ 29815 ] | |
Fix Version/s | 11.6 [ 29515 ] |
Link | This issue is blocked by MDEV-10018 [ MDEV-10018 ] |
Assignee | Sergei Golubchik [ serg ] | Alexander Barkov [ bar ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
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(). |
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(). |
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(). |
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(). |
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(). |
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(). |
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(). |
Link |
This issue relates to |
Assignee | Alexander Barkov [ bar ] | Sergei Golubchik [ serg ] |
Status | Stalled [ 10000 ] | In Review [ 10002 ] |
Issue Type | Task [ 3 ] | New Feature [ 2 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Assignee | Sergei Golubchik [ serg ] | Alexander Barkov [ bar ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Testing [ 10301 ] |
Assignee | Alexander Barkov [ bar ] | Elena Stepanova [ elenst ] |
Link |
This issue causes |
Assignee | Elena Stepanova [ elenst ] | Ramesh Sivaraman [ JIRAUSER48189 ] |
Link | This issue is part of TODO-4907 [ TODO-4907 ] |
Labels | Preview_11.7 |
Summary | CURRENT_TIMESTAMP should return a TIMESTAMP [WITH TIME ZONE?] | CURRENT_TIMESTAMP should return a TIMESTAMP (WITH TIME ZONE?) |
Assignee | Ramesh Sivaraman [ JIRAUSER48189 ] | Alexander Barkov [ bar ] |
Status | In Testing [ 10301 ] | Stalled [ 10000 ] |
Assignee | Alexander Barkov [ bar ] | Sergei Golubchik [ serg ] |
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 ] |
Link |
This issue causes |
Link |
This issue is duplicated by |
Link |
This issue relates to |
Link |
This issue is duplicated by |
Link | This issue relates to MDEV-34037 [ MDEV-34037 ] |
According to the standard, it should return TIMESTAMP WITH TIMEZONE:
While, the best name for MariaDB's TIMESTAMP is "TIMESTAMP WITH LOCAL TIME ZONE".
So perhaps we should implement MDEV-10018 first.