2
# Test of timestamp with hires resolution;
4
set time_zone='+03:00';
5
set timestamp=unix_timestamp('2011-01-01 01:01:01.123456');
8
select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2);
9
select now(), curtime(0), utc_timestamp(1), utc_time(2), current_time(3),
10
current_timestamp(4), localtime(5), localtimestamp(6), time_to_sec('12:34:56'),
11
time_to_sec('12:34:56.789');
12
select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
13
select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
15
--error ER_TOO_BIG_PRECISION
16
select current_timestamp(7);
17
--error ER_TOO_BIG_PRECISION
21
drop table if exists t1;
24
create table t1 select sec_to_time(12345), sec_to_time(12345.6789),
25
sec_to_time(1234567e-2), now(), curtime(0),
26
utc_timestamp(1), utc_time(2), current_time(3),
27
current_timestamp(4), localtime(5), localtimestamp(6),
28
time_to_sec(123456), time_to_sec('12:34:56.789');
30
--query_vertical select * from t1
33
--query_vertical select unix_timestamp('2011-01-01 01:01:01'), unix_timestamp('2011-01-01 01:01:01.123456'), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4)));
34
--query_vertical select from_unixtime(unix_timestamp('2011/1/1 1:1:1')), from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4))));
36
select sec_to_time(3020399.99999), sec_to_time(3020399.999999), sec_to_time(3020399.9999999);
37
select sec_to_time(-3020399.99999), sec_to_time(-3020399.999999), sec_to_time(-3020399.9999999);
38
select 20010101000203.000000004 + interval 1 day;
39
select 20010101000203.4 + interval 1 day;
41
# precision of expressions
43
set @a=cast('2011-01-02 12:13:14' as datetime);
44
select @a + interval 1 minute;
45
select @a + interval 10 microsecond;
46
select @a + interval 10 microsecond + interval 999990 microsecond;
51
set @a='2011-01-02 12:13:14.123456';
52
create table t1 select CAST(@a AS DATETIME) as dauto,
53
CAST(@a AS DATETIME(0)) as d0,
54
CAST(@a AS DATETIME(1)) as d1,
55
CAST(@a AS DATETIME(2)) as d2,
56
CAST(@a AS DATETIME(3)) as d3,
57
CAST(@a AS DATETIME(4)) as d4,
58
CAST(@a AS DATETIME(5)) as d5,
59
CAST(@a AS DATETIME(6)) as d6,
60
CAST(@a AS TIME) as tauto,
61
CAST(@a AS TIME(0)) as t0,
62
CAST(@a AS TIME(1)) as t1,
63
CAST(@a AS TIME(2)) as t2,
64
CAST(@a AS TIME(3)) as t3,
65
CAST(@a AS TIME(4)) as t4,
66
CAST(@a AS TIME(5)) as t5,
67
CAST(@a AS TIME(6)) as t6;
69
--query_vertical select * from t1
71
explain extended select cast(cast(@a as datetime(4)) as time(0));
72
select cast(cast(@a as time(2)) as time(6));
74
--error ER_TOO_BIG_PRECISION
75
select CAST(@a AS DATETIME(7));
80
SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
81
SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
82
SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
83
SELECT CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00');
88
create table t1 (a varchar(200));
89
insert t1 values (now(6));
94
# lp:736358 Unexpected increased timestamp resolution with UNION
96
# timestamp(6) case is fixed:
97
create table t1 (f1 timestamp(6));
98
insert into t1 values ('2002-07-15 21:00:00');
99
select time(f1) from t1;
100
select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
101
alter table t1 modify f1 timestamp;
102
select time(f1) from t1;
103
select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
104
# but the effect cannot be eliminated completely:
105
alter table t1 modify f1 varchar(100);
106
select time(f1) from t1;
107
select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;