mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
1cda265457
Use dedicated do_field_temporal() for Copy_field. * check_time_range() needs to know TIME's precision to use the correct max value.
96 lines
3.3 KiB
Text
96 lines
3.3 KiB
Text
|
|
set timestamp=unix_timestamp('2011-01-01 01:01:01') + 0.123456, time_zone='+03:00';
|
|
|
|
--vertical_results
|
|
select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2);
|
|
select now(), curtime(0), utc_timestamp(1), utc_time(2), current_time(3),
|
|
current_timestamp(4), localtime(5), localtimestamp(6), time_to_sec('12:34:56'),
|
|
time_to_sec('12:34:56.789');
|
|
select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
|
|
select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
|
|
--horizontal_results
|
|
--error ER_WRONG_ARGUMENTS
|
|
select current_timestamp(7);
|
|
--error ER_WRONG_ARGUMENTS
|
|
select curtime(7);
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
|
|
create table t1 select sec_to_time(12345), sec_to_time(12345.6789),
|
|
sec_to_time(1234567e-2), now(), curtime(0),
|
|
utc_timestamp(1), utc_time(2), current_time(3),
|
|
current_timestamp(4), localtime(5), localtimestamp(6),
|
|
time_to_sec('12:34:56'), time_to_sec('12:34:56.789');
|
|
show create table t1;
|
|
--query_vertical select * from t1
|
|
drop table t1;
|
|
|
|
#
|
|
# precision of expressions
|
|
#
|
|
set @a=cast('2011-01-02 12:13:14' as datetime);
|
|
select @a + interval 1 minute;
|
|
select @a + interval 10 microsecond;
|
|
select @a + interval 10 microsecond + interval 999990 microsecond;
|
|
|
|
#
|
|
# CAST
|
|
#
|
|
set @a='2011-01-02 12:13:14.123456';
|
|
create table t1 select CAST(@a AS DATETIME) as dauto,
|
|
CAST(@a AS DATETIME(0)) as d0,
|
|
CAST(@a AS DATETIME(1)) as d1,
|
|
CAST(@a AS DATETIME(2)) as d2,
|
|
CAST(@a AS DATETIME(3)) as d3,
|
|
CAST(@a AS DATETIME(4)) as d4,
|
|
CAST(@a AS DATETIME(5)) as d5,
|
|
CAST(@a AS DATETIME(6)) as d6,
|
|
CAST(@a AS TIME) as tauto,
|
|
CAST(@a AS TIME(0)) as t0,
|
|
CAST(@a AS TIME(1)) as t1,
|
|
CAST(@a AS TIME(2)) as t2,
|
|
CAST(@a AS TIME(3)) as t3,
|
|
CAST(@a AS TIME(4)) as t4,
|
|
CAST(@a AS TIME(5)) as t5,
|
|
CAST(@a AS TIME(6)) as t6;
|
|
show create table t1;
|
|
--query_vertical select * from t1
|
|
drop table t1;
|
|
|
|
--error ER_TOO_BIG_PRECISION
|
|
select CAST(@a AS DATETIME(7));
|
|
|
|
#
|
|
# CONVERT_TZ
|
|
#
|
|
SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
|
|
SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
|
|
SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
|
|
SELECT CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00');
|
|
|
|
#
|
|
# Field::store_time()
|
|
#
|
|
create table t1 (a varchar(200));
|
|
insert t1 values (now(6));
|
|
select * from t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# lp:736358 Unexpected increased timestamp resolution with UNION
|
|
#
|
|
# timestamp(6) case is fixed:
|
|
create table t1 (f1 timestamp(6));
|
|
insert into t1 values ('2002-07-15 21:00:00');
|
|
select time(f1) from t1;
|
|
select time(f1) from t1 union all select time(f1) from t1;
|
|
alter table t1 modify f1 timestamp;
|
|
select time(f1) from t1;
|
|
select time(f1) from t1 union all select time(f1) from t1;
|
|
# but the effect cannot be eliminated completely:
|
|
alter table t1 modify f1 varchar(100);
|
|
select time(f1) from t1;
|
|
select time(f1) from t1 union all select time(f1) from t1;
|
|
drop table t1;
|