~stewart/drizzle/docs-improvements-1

« back to all changes in this revision

Viewing changes to tests/suite/time_type/t/basic.test

merged with up to date trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# testing of the TIME column type
 
3
#
 
4
 
 
5
--disable_warnings
 
6
DROP TABLE if exists t1;
 
7
--enable_warnings
 
8
 
 
9
CREATE TABLE t1 (t time);
 
10
INSERT INTO t1 VALUES ("10:22:33");
 
11
INSERT INTO t1 VALUES ("12:34:56.78");
 
12
 
 
13
INSERT INTO t1 VALUES (10);
 
14
 
 
15
INSERT INTO t1 VALUES (1234);
 
16
 
 
17
INSERT INTO t1 VALUES (123456.78);
 
18
 
 
19
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
20
INSERT INTO t1 VALUES (1234559.99);
 
21
 
 
22
INSERT INTO t1 VALUES ("1");
 
23
 
 
24
INSERT INTO t1 VALUES ("1:23");
 
25
 
 
26
INSERT INTO t1 VALUES ("1:23:45");
 
27
 
 
28
INSERT INTO t1 VALUES ("10.22");
 
29
 
 
30
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
31
INSERT INTO t1 VALUES ("20 10:22:33");
 
32
 
 
33
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
34
INSERT INTO t1 VALUES ("-10  1:22:33.45");
 
35
 
 
36
INSERT INTO t1 VALUES ("1999-02-03 20:33:34");
 
37
 
 
38
insert t1 values (30);
 
39
insert t1 values (1230);
 
40
insert t1 values ("1230");
 
41
insert t1 values ("12:30");
 
42
insert t1 values ("12:30:35");
 
43
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
44
insert t1 values ("1 12:30:31.32");
 
45
 
 
46
select * from t1;
 
47
# Test wrong values
 
48
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
49
INSERT INTO t1 VALUES ("10.22.22");
 
50
 
 
51
INSERT INTO t1 VALUES (1234567);
 
52
 
 
53
INSERT INTO t1 VALUES (123456789);
 
54
 
 
55
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
56
INSERT INTO t1 VALUES (123456789.10);
 
57
 
 
58
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
59
INSERT INTO t1 VALUES ("10 22:22");
 
60
 
 
61
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
62
INSERT INTO t1 VALUES ("12.45a");
 
63
select * from t1;
 
64
DROP TABLE t1;
 
65
 
 
66
CREATE TABLE t1 (t time);
 
67
INSERT INTO t1 VALUES ('09:00:00');
 
68
INSERT INTO t1 VALUES ('13:00:00');
 
69
INSERT INTO t1 VALUES ('19:38:34');
 
70
INSERT INTO t1 VALUES ('13:00:00');
 
71
INSERT INTO t1 VALUES ('09:00:00');
 
72
INSERT INTO t1 VALUES ('09:00:00');
 
73
INSERT INTO t1 VALUES ('13:00:00');
 
74
INSERT INTO t1 VALUES ('13:00:00');
 
75
INSERT INTO t1 VALUES ('13:00:00');
 
76
INSERT INTO t1 VALUES ('09:00:00');
 
77
 
 
78
--error ER_SP_DOES_NOT_EXIST
 
79
select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1;
 
80
 
 
81
--error ER_SP_DOES_NOT_EXIST
 
82
select sec_to_time(time_to_sec(t)) from t1;
 
83
 
 
84
DROP TABLE t1;
 
85
 
 
86
#
 
87
# BUG #12440: Incorrect processing of time values containing
 
88
# long fraction part and/or large exponent part.
 
89
#
 
90
# These must return normal result:
 
91
# ##########################################################
 
92
# To be uncommented after fix BUG #15805
 
93
# ##########################################################
 
94
# SELECT CAST(235959.123456 AS TIME);
 
95
# SELECT CAST(0.235959123456e+6 AS TIME);
 
96
# SELECT CAST(235959123456e-6 AS TIME);
 
97
# These must cut fraction part and produce warning:
 
98
# SELECT CAST(235959.1234567 AS TIME);
 
99
# SELECT CAST(0.2359591234567e6 AS TIME);
 
100
# This must return NULL and produce warning:
 
101
# SELECT CAST(0.2359591234567e+30 AS TIME);
 
102
# ##########################################################
 
103
 
 
104
# End of 4.1 tests
 
105
 
 
106
#
 
107
# Bug#29555: Comparing time values as strings may lead to a wrong result.
 
108
#
 
109
SELECT CAST('100:55:50' as time) < cast('24:00:00' as time);
 
110
 
 
111
SELECT CAST('100:55:50' as time) < cast('024:00:00' as time);
 
112
 
 
113
SELECT CAST('300:55:50' as time) < cast('240:00:00' as time);
 
114
 
 
115
SELECT CAST('100:55:50' as time) > cast('24:00:00' as time);
 
116
 
 
117
SELECT CAST('100:55:50' as time) > cast('024:00:00' as time);
 
118
 
 
119
SELECT CAST('300:55:50' as time) > cast('240:00:00' as time);
 
120
 
 
121
CREATE TABLE t1 (f1 time);
 
122
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
123
INSERT INTO t1 VALUES ('24:00:00');
 
124
 
 
125
SELECT CAST('24:00:00' as time) = (select f1 from t1);
 
126
 
 
127
DROP TABLE t1;
 
128
 
 
129
#
 
130
# Bug#29739: Incorrect time comparison in BETWEEN.
 
131
#
 
132
CREATE TABLE t1(f1 time, f2 time);
 
133
--error ER_INVALID_UNIX_TIMESTAMP_VALUE
 
134
INSERT INTO t1 VALUES('20:00:00','150:00:00');
 
135
 
 
136
select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
 
137
 
 
138
DROP TABLE t1;
 
139
 
 
140
#
 
141
# Bug#29729: Wrong conversion error led to an empty result set.
 
142
#
 
143
CREATE TABLE  t1 (
 
144
  f2 date NOT NULL,
 
145
  f3 int NOT NULL default '0',
 
146
  PRIMARY KEY  (f3, f2)
 
147
);
 
148
INSERT INTO t1 VALUES ('2007-07-01', 1);
 
149
INSERT INTO t1 VALUES ('2007-07-01', 2);
 
150
INSERT INTO t1 VALUES ('2007-07-02', 1);
 
151
INSERT INTO t1 VALUES ('2007-07-02', 2);
 
152
SELECT sum(f3) FROM t1 WHERE f2='2007-07-01 00:00:00' group by f2;
 
153
 
 
154
DROP TABLE t1;