~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/date_formats.test

  • Committer: Jay Pipes
  • Date: 2009-02-21 16:00:06 UTC
  • mto: (907.1.1 trunk-with-temporal)
  • mto: This revision was merged to the branch mainline in revision 908.
  • Revision ID: jpipes@serialcoder-20090221160006-vnk3wt4qbcz62eru
Removes the TIME column type and related time functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
# select cast(str_to_date('15-01-2001 12:59:59', '%d-%m-%Y %H:%i:%S') as TIME);
119
119
 
120
120
#
121
 
# Test of str_to_date
122
 
#
123
 
 
124
 
# PS doesn't support fraction of a seconds
125
 
--disable_ps_protocol
126
 
select str_to_date(concat('15-01-2001',' 2:59:58.999'),
127
 
                   concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
128
 
select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
129
 
--enable_ps_protocol
130
 
 
131
 
create table t1 (date char(30), format char(30) not null);
132
 
insert into t1 values
133
 
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
134
 
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
135
 
('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
136
 
('03-01-02 8:11:2.123456',   '%Y-%m-%d %H:%i:%S.%#'),
137
 
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
138
 
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
139
 
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
140
 
('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
141
 
('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
142
 
('10:20:10', '%H:%i:%s'),
143
 
('10:20:10', '%h:%i:%s.%f'),
144
 
('10:20:10', '%T'),
145
 
('10:20:10AM', '%h:%i:%s%p'),
146
 
('10:20:10AM', '%r'),
147
 
('10:20:10.44AM', '%h:%i:%s.%f%p'),
148
 
('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
149
 
('15 September 2001', '%d %M %Y'),
150
 
('15 SEPTEMB 2001', '%d %M %Y'),
151
 
('15 MAY 2001', '%d %b %Y'),
152
 
('15th May 2001', '%D %b %Y'),
153
 
('Sunday 15 MAY 2001', '%W %d %b %Y'),
154
 
('Sund 15 MAY 2001', '%W %d %b %Y'),
155
 
('Tuesday 00 2002', '%W %U %Y'),
156
 
('Thursday 53 1998', '%W %u %Y'),
157
 
('Sunday 01 2001', '%W %v %x'),
158
 
('Tuesday 52 2001', '%W %V %X'),
159
 
('060 2004', '%j %Y'),
160
 
('4 53 1998', '%w %u %Y'),
161
 
('15-01-2001', '%d-%m-%Y %H:%i:%S'),
162
 
('15-01-20', '%d-%m-%y'),
163
 
('15-2001-1', '%d-%Y-%c');
164
 
 
165
 
# PS doesn't support fractional seconds
166
 
--disable_ps_protocol
167
 
select date,format,str_to_date(date, format) as str_to_date from t1;
168
 
# Use as a string
169
 
select date,format,concat('',str_to_date(date, format)) as con from t1;
170
 
# Use as datetime
171
 
select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
172
 
select date,format,DATE(str_to_date(date, format)) as date2 from t1;
173
 
select date,format,TIME(str_to_date(date, format)) as time from t1;
174
 
select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
175
 
# Test small bug in %f handling
176
 
select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'));
177
 
 
178
 
# Test wrong dates or converion specifiers
179
 
 
180
 
truncate table t1;
181
 
insert into t1 values
182
 
('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
183
 
('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
184
 
('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
185
 
('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
186
 
('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
187
 
('10:20:10AM', '%H:%i:%s%p'),
188
 
('15 Septembei 2001', '%d %M %Y'),
189
 
('15 Ju 2001', '%d %M %Y'),
190
 
('Sund 15 MA', '%W %d %b %Y'),
191
 
('Thursdai 12 1998', '%W %u %Y'),
192
 
('Sunday 01 2001', '%W %v %X'),
193
 
('Tuesday 52 2001', '%W %V %x'),
194
 
('Tuesday 52 2001', '%W %V %Y'),
195
 
('Tuesday 52 2001', '%W %u %x'),
196
 
('7 53 1998', '%w %u %Y'),
197
 
(NULL, get_format(DATE,'USA'));
198
 
select date,format,str_to_date(date, format) as str_to_date from t1;
199
 
select date,format,concat(str_to_date(date, format),'') as con from t1;
200
 
 
201
 
# Test 'maybe' date formats and 'strange but correct' results
202
 
 
203
 
truncate table t1;
204
 
insert into t1 values
205
 
('10:20:10AM', '%h:%i:%s'),
206
 
('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
207
 
('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
208
 
 
209
 
select date,format,str_to_date(date, format) as str_to_date from t1;
210
 
select date,format,concat(str_to_date(date, format),'') as con from t1;
211
 
 
212
 
drop table t1;
213
 
--enable_ps_protocol
214
 
 
215
 
#
216
121
# Test of get_format
217
122
#
218
123
 
219
124
select get_format(DATE, 'USA') as a;
220
 
select get_format(TIME, 'internal') as a;
221
125
select get_format(DATETIME, 'eur') as a;
222
126
select get_format(TIMESTAMP, 'eur') as a;
223
127
select get_format(DATE, 'TEST') as a;
224
 
select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'));
225
128
 
226
 
explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001");
 
129
explain extended select makedate(1997,1), subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),microsecond("1997-12-31 23:59:59.000001");
227
130
 
228
131
#
229
132
# Test of date_format()
235
138
drop table t1;
236
139
 
237
140
#
238
 
# Commenting out all str_to_date(). It's an abomination 
239
 
# and hopefully we can get rid of it.
240
 
#
241
 
# I mean, seriously, this: str_to_date("02 10", "%d %H") is supposed to produce a date!? 
242
 
#
243
 
# PS doesn't support fractional seconds
244
 
#--disable_ps_protocol
245
 
#select str_to_date("2003-....01ABCD-02 10:11:12.0012", "%Y-%.%m%@-%d %H:%i:%S.%f") as a;
246
 
 
247
 
#create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
248
 
#                       str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2,
249
 
#                       str_to_date("2003-01-02", "%Y-%m-%d") as f3,
250
 
#                       str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
251
 
#describe t1;
252
 
#select * from t1;
253
 
#drop table t1;
254
 
#
255
 
#create table t1 select "02 10" as a, "%d %H" as b;
256
 
#select str_to_date(a,b) from t1;
257
 
#create table t2 select str_to_date(a,b) from t1;
258
 
#describe t2;
259
 
#select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
260
 
#       str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
261
 
#       str_to_date("2003-01-02", "%Y-%m-%d") as f3,
262
 
#       str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
263
 
#       str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
264
 
#       str_to_date("02 10", "%d %f") as f6;
265
 
#drop table t1, t2;
266
 
#--error 1686 # These are bad datetimes...
267
 
#select str_to_date("2003-01-02 10:11:12.0012ABCD", "%Y-%m-%d %H:%i:%S.%f") as f1,
268
 
#       addtime("-01:01:01.01 GGG", "-23:59:59.1") as f2,
269
 
#       microsecond("1997-12-31 23:59:59.01XXXX") as f3;
270
 
#
271
 
#select str_to_date("2003-04-05  g", "%Y-%m-%d") as f1,
272
 
#       str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2;
273
 
#--enable_ps_protocol
274
 
 
275
 
#
276
141
# Bug #14016 
277
142
#
278
143
create table t1 (f1 datetime);
282
147
drop table t1;
283
148
 
284
149
#
285
 
# Bug #15828
286
 
#
287
 
select str_to_date( 1, NULL );
288
 
select str_to_date( NULL, 1 );
289
 
select str_to_date( 1, IF(1=1,NULL,NULL) );
290
 
 
291
 
#
292
150
# Bug#11326
293
151
# TIME_FORMAT using "%r" returns wrong hour using 24:00:00 in TIME column
294
152
#
323
181
#
324
182
SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896);
325
183
 
326
 
#
327
 
# Bug #22029: str_to_date returning NULL
328
 
#
329
 
 
330
 
select str_to_date('04 /30/2004', '%m /%d/%Y');
331
 
select str_to_date('04/30 /2004', '%m /%d /%Y');
332
 
select str_to_date('04/30/2004 ', '%m/%d/%Y ');
333
 
 
334
184
--echo "End of 4.1 tests"