mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-15751 CURRENT_TIMESTAMP should return a TIMESTAMP [WITH TIME ZONE?]
Changing the return type of the following functions: - CURRENT_TIMESTAMP, CURRENT_TIMESTAMP(), NOW() - SYSDATE() - FROM_UNIXTIME() from DATETIME to TIMESTAMP. Note, the old function NOW() returning DATETIME is still available as LOCALTIMESTAMP or LOCALTIMESTAMP(), e.g.: SELECT LOCALTIMESTAMP, -- DATETIME CURRENT_TIMESTAMP; -- TIMESTAMP The change in the functions return data type fixes some problems that occurred near a DST change: - Problem #1 INSERT INTO t1 (timestamp_field) VALUES (CURRENT_TIMESTAMP); INSERT INTO t1 (timestamp_field) VALUES (COALESCE(CURRENT_TIMESTAMP)); could result into two different values inserted. - Problem #2 INSERT INTO t1 (timestamp_field) VALUES (FROM_UNIXTIME(1288477526)); INSERT INTO t1 (timestamp_field) VALUES (FROM_UNIXTIME(1288477526+3600)); could result into two equal TIMESTAMP values near a DST change. Additional changes: - FROM_UNIXTIME(0) now returns SQL NULL instead of '1970-01-01 00:00:00' (assuming time_zone='+00:00') - UNIX_TIMESTAMP('1970-01-01 00:00:00') now returns SQL NULL instead of 0 (assuming time_zone='+00:00' These additional changes are needed for consistency with TIMESTAMP fields, which cannot store '1970-01-01 00:00:00 +00:00'
This commit is contained in:
committed by
Sergei Golubchik
parent
128fc34990
commit
dfaf7e2eb4
@ -1340,7 +1340,7 @@ public:
|
||||
{
|
||||
return is_valid_temporal() ? TIME_to_double(this) : 0;
|
||||
}
|
||||
my_decimal *to_decimal(my_decimal *to)
|
||||
my_decimal *to_decimal(my_decimal *to) const
|
||||
{
|
||||
return is_valid_temporal() ? Temporal::to_decimal(to) : bad_to_decimal(to);
|
||||
}
|
||||
@ -1987,7 +1987,7 @@ public:
|
||||
str->length(my_time_to_str(this, const_cast<char*>(str->ptr()), dec));
|
||||
return str;
|
||||
}
|
||||
my_decimal *to_decimal(my_decimal *to)
|
||||
my_decimal *to_decimal(my_decimal *to) const
|
||||
{
|
||||
return is_valid_time() ? Temporal::to_decimal(to) : bad_to_decimal(to);
|
||||
}
|
||||
@ -2342,7 +2342,7 @@ public:
|
||||
str->length(my_date_to_str(this, const_cast<char*>(str->ptr())));
|
||||
return str;
|
||||
}
|
||||
my_decimal *to_decimal(my_decimal *to)
|
||||
my_decimal *to_decimal(my_decimal *to) const
|
||||
{
|
||||
return is_valid_date() ? Temporal::to_decimal(to) : bad_to_decimal(to);
|
||||
}
|
||||
@ -2663,7 +2663,7 @@ public:
|
||||
str->length(my_datetime_to_str(this, const_cast<char*>(str->ptr()), dec));
|
||||
return str;
|
||||
}
|
||||
my_decimal *to_decimal(my_decimal *to)
|
||||
my_decimal *to_decimal(my_decimal *to) const
|
||||
{
|
||||
return is_valid_datetime() ? Temporal::to_decimal(to) : bad_to_decimal(to);
|
||||
}
|
||||
|
Reference in New Issue
Block a user