mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 01:04:19 +01:00
dfaf7e2eb4
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'
19 lines
468 B
Text
19 lines
468 B
Text
#
|
|
# Tests for time functions. The difference from func_time test is the
|
|
# timezone. In func_time it's GMT-3. In our case it's GMT+10
|
|
#
|
|
|
|
#
|
|
# Test for bug bug #9191 "TIMESTAMP/from_unixtime() no longer accepts 2^31-1"
|
|
#
|
|
|
|
select from_unixtime(0);
|
|
select from_unixtime(0.000001);
|
|
select from_unixtime(1);
|
|
|
|
# check 0 boundary
|
|
|
|
select unix_timestamp('1969-12-31 14:00:00');
|
|
select unix_timestamp('1969-12-31 14:00:00.000001');
|
|
select unix_timestamp('1969-12-31 14:00:01');
|
|
|