~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/suite/broken/t/strict-date.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- source include/have_innodb.inc
 
2
 
 
3
set @org_mode=@@sql_mode;
 
4
set @@sql_mode='ansi,traditional';
 
5
select @@sql_mode;
 
6
 
 
7
--disable_warnings
 
8
DROP TABLE IF EXISTS t1, t2;
 
9
--enable_warnings
 
10
 
 
11
# Test INSERT with DATE
 
12
 
 
13
CREATE TABLE t1 (col1 date);
 
14
INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
 
15
INSERT INTO t1 VALUES('0000-10-31');
 
16
 
 
17
# All test cases expected to fail should return 
 
18
#      SQLSTATE 22007 <invalid date value>
 
19
--error 1292
 
20
INSERT INTO t1 VALUES('2004-0-31');
 
21
--error 1292
 
22
INSERT INTO t1 VALUES('2004-01-02'),('2004-0-31');
 
23
--error 1292
 
24
INSERT INTO t1 VALUES('2004-10-0');
 
25
--error 1292
 
26
INSERT INTO t1 VALUES('2004-09-31');
 
27
--error 1292
 
28
INSERT INTO t1 VALUES('2004-10-32');
 
29
--error 1292
 
30
INSERT INTO t1 VALUES('2003-02-29');
 
31
--error 1292
 
32
INSERT INTO t1 VALUES('2004-13-15');
 
33
--error 1292
 
34
INSERT INTO t1 VALUES('0000-00-00');
 
35
# Standard says we should return SQLSTATE 22018
 
36
--error 1292
 
37
INSERT INTO t1 VALUES ('59');
 
38
 
 
39
# Test the different related modes
 
40
set @@sql_mode='STRICT_ALL_TABLES';
 
41
INSERT INTO t1 VALUES('2004-01-03'),('2004-0-31');
 
42
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_IN_DATE';
 
43
--error 1292
 
44
INSERT INTO t1 VALUES('2004-0-30');
 
45
--error 1292
 
46
INSERT INTO t1 VALUES('2004-01-04'),('2004-0-31'),('2004-01-05');
 
47
INSERT INTO t1 VALUES('0000-00-00');
 
48
INSERT IGNORE INTO t1 VALUES('2004-0-29');
 
49
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_DATE';
 
50
--error 1292
 
51
INSERT INTO t1 VALUES('0000-00-00');
 
52
INSERT IGNORE INTO t1 VALUES('0000-00-00');
 
53
INSERT INTO t1 VALUES ('2004-0-30');
 
54
--error 1292
 
55
INSERT INTO t1 VALUES ('2004-2-30');
 
56
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
 
57
INSERT INTO t1 VALUES ('2004-2-30');
 
58
set @@sql_mode='ansi,traditional';
 
59
INSERT IGNORE INTO t1 VALUES('2004-02-29'),('2004-13-15'),('0000-00-00');
 
60
 
 
61
select * from t1;
 
62
drop table t1;
 
63
# Test difference in behaviour with InnoDB and MyISAM tables
 
64
 
 
65
set @@sql_mode='strict_trans_tables';
 
66
CREATE TABLE t1 (col1 date) engine=myisam;
 
67
--error 1292
 
68
INSERT INTO t1 VALUES('2004-13-31'),('2004-1-1');
 
69
INSERT INTO t1 VALUES ('2004-1-2'), ('2004-13-31'),('2004-1-3');
 
70
INSERT IGNORE INTO t1 VALUES('2004-13-31'),('2004-1-4');
 
71
--error 1292
 
72
INSERT INTO t1 VALUES ('2003-02-29');
 
73
INSERT ignore INTO t1 VALUES('2003-02-30');
 
74
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
 
75
INSERT ignore INTO t1 VALUES('2003-02-31');
 
76
select * from t1;
 
77
drop table t1;
 
78
 
 
79
set @@sql_mode='strict_trans_tables';
 
80
CREATE TABLE t1 (col1 date) engine=innodb;
 
81
--error 1292
 
82
INSERT INTO t1 VALUES('2004-13-31'),('2004-1-1');
 
83
--error 1292
 
84
INSERT INTO t1 VALUES ('2004-1-2'), ('2004-13-31'),('2004-1-3');
 
85
INSERT IGNORE INTO t1 VALUES('2004-13-31'),('2004-1-4');
 
86
--error 1292
 
87
INSERT INTO t1 VALUES ('2003-02-29');
 
88
INSERT ignore INTO t1 VALUES('2003-02-30');
 
89
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
 
90
INSERT ignore INTO t1 VALUES('2003-02-31');
 
91
select * from t1;
 
92
drop table t1;
 
93
 
 
94
 
 
95
# Test INSERT with DATETIME
 
96
 
 
97
CREATE TABLE t1 (col1 datetime);
 
98
INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
 
99
INSERT INTO t1 VALUES('0000-10-31 15:30:00');
 
100
 
 
101
# All test cases expected to fail should return 
 
102
#      SQLSTATE 22007 <invalid datetime value>
 
103
--error 1292
 
104
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
 
105
--error 1292
 
106
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
 
107
--error 1292
 
108
INSERT INTO t1 VALUES('2004-09-31 15:30:00');
 
109
--error 1292
 
110
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
 
111
--error 1292
 
112
INSERT INTO t1 VALUES('2003-02-29 15:30:00');
 
113
--error 1292
 
114
INSERT INTO t1 VALUES('2004-13-15 15:30:00');
 
115
--error 1292
 
116
INSERT INTO t1 VALUES('0000-00-00 15:30:00');
 
117
# Standard says we should return SQLSTATE 22018
 
118
--error 1292
 
119
INSERT INTO t1 VALUES ('59');
 
120
select * from t1;
 
121
drop table t1;
 
122
 
 
123
 
 
124
# Test INSERT with TIMESTAMP
 
125
 
 
126
CREATE TABLE t1 (col1 timestamp);
 
127
INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
 
128
 
 
129
# All test cases expected to fail should return 
 
130
#      SQLSTATE 22007 <invalid datetime value>
 
131
# Standard says we should return ok, but we can't as this is out of range
 
132
--error 1292
 
133
INSERT INTO t1 VALUES('0000-10-31 15:30:00');
 
134
--error 1292
 
135
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
 
136
--error 1292
 
137
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
 
138
--error 1292
 
139
INSERT INTO t1 VALUES('2004-09-31 15:30:00');
 
140
--error 1292
 
141
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
 
142
--error 1292
 
143
INSERT INTO t1 VALUES('2003-02-29 15:30:00');
 
144
--error 1292
 
145
INSERT INTO t1 VALUES('2004-13-15 15:30:00');
 
146
--error 1292
 
147
INSERT INTO t1 VALUES('2004-02-29 25:30:00');
 
148
--error 1292
 
149
INSERT INTO t1 VALUES('2004-02-29 15:65:00');
 
150
--error 1292
 
151
INSERT INTO t1 VALUES('2004-02-29 15:31:61');
 
152
--error 1292
 
153
INSERT INTO t1 VALUES('0000-00-00 15:30:00');
 
154
--error 1292
 
155
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
 
156
INSERT IGNORE INTO t1 VALUES('0000-00-00 00:00:00');
 
157
# Standard says we should return SQLSTATE 22018
 
158
--error 1292
 
159
INSERT INTO t1 VALUES ('59');
 
160
 
 
161
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
 
162
--error 1292
 
163
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
 
164
--error 1292
 
165
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
 
166
--error 1292
 
167
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
 
168
--error 1292
 
169
INSERT INTO t1 VALUES('2004-02-30 15:30:04');
 
170
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
 
171
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_IN_DATE';
 
172
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
 
173
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_DATE';
 
174
--error 1292
 
175
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
 
176
set @@sql_mode='ansi,traditional';
 
177
SELECT * FROM t1;
 
178
DROP TABLE t1;
 
179
 
 
180
#### Test INSERT with STR_TO_DATE into DATE/DATETIME/TIMESTAMP
 
181
 
 
182
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
 
183
 
 
184
INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y'));
 
185
INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
 
186
INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
 
187
 
 
188
## Test INSERT with STR_TO_DATE into DATE
 
189
#       All test cases expected to fail should return 
 
190
#       SQLSTATE 22007 <invalid date value>
 
191
 
 
192
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
 
193
 
 
194
--error 1292
 
195
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
 
196
--error 1292
 
197
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
 
198
--error 1292
 
199
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
 
200
--error 1411
 
201
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
 
202
--error 1292
 
203
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
 
204
--error 1411
 
205
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
 
206
--error 1292
 
207
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
 
208
 
 
209
## Test INSERT with STR_TO_DATE into DATETIME
 
210
#       All test cases expected to fail should return 
 
211
#       SQLSTATE 22007 <invalid datetime value>
 
212
 
 
213
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
 
214
 
 
215
--error 1292
 
216
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
 
217
--error 1292
 
218
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
 
219
--error 1292
 
220
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
 
221
--error 1411
 
222
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
 
223
--error 1292
 
224
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
 
225
--error 1411
 
226
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
 
227
--error 1292
 
228
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
 
229
 
 
230
## Test INSERT with STR_TO_DATE into TIMESTAMP
 
231
#       All test cases expected to fail should return 
 
232
#       SQLSTATE 22007 <invalid datetime value>
 
233
 
 
234
--error 1292
 
235
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
 
236
--error 1292
 
237
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
 
238
--error 1292
 
239
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
 
240
--error 1292
 
241
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
 
242
--error 1411
 
243
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
 
244
--error 1292
 
245
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
 
246
--error 1411
 
247
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
 
248
--error 1292
 
249
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
 
250
 
 
251
drop table t1;
 
252
 
 
253
#### Test INSERT with CAST AS DATE/DATETIME into DATE/DATETIME/TIMESTAMP
 
254
 
 
255
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
 
256
 
 
257
INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE));
 
258
INSERT INTO t1 (col2) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
 
259
INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
 
260
 
 
261
 
 
262
## Test INSERT with CAST AS DATE into DATE
 
263
#       All test cases expected to fail should return 
 
264
#       SQLSTATE 22007 <invalid date value>
 
265
 
 
266
INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
 
267
 
 
268
--error 1292
 
269
INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE));
 
270
--error 1292
 
271
INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE));
 
272
 
 
273
# deactivated because of Bug#8294
 
274
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
 
275
# --error 1292
 
276
# INSERT INTO t1 (col1) VALUES(CAST('2004-9-31' AS DATE));
 
277
# --error 1292
 
278
# INSERT INTO t1 (col1) VALUES(CAST('2004-10-32' AS DATE));
 
279
# --error 1292
 
280
# INSERT INTO t1 (col1) VALUES(CAST('2003-02-29' AS DATE));
 
281
# --error 1292
 
282
# INSERT INTO t1 (col1) VALUES(CAST('2004-13-15' AS DATE));
 
283
 
 
284
# deactivated because of Bug#6145
 
285
#  Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
 
286
--error 1292
 
287
INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
 
288
 
 
289
## Test INSERT with CAST AS DATETIME into DATETIME
 
290
#       All test cases expected to fail should return 
 
291
#       SQLSTATE 22007 <invalid datetime value>
 
292
 
 
293
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
 
294
 
 
295
--error 1292
 
296
INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
 
297
--error 1292
 
298
INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
 
299
 
 
300
# deactivated because of Bug#8294
 
301
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
 
302
#--error 1292
 
303
#INSERT INTO t1 (col2) VALUES(CAST('2004-9-31 15:30' AS DATETIME));
 
304
#--error 1292
 
305
#INSERT INTO t1 (col2) VALUES(CAST('2004-10-32 15:30' AS DATETIME));
 
306
#--error 1292
 
307
#INSERT INTO t1 (col2) VALUES(CAST('2003-02-29 15:30' AS DATETIME));
 
308
#--error 1292
 
309
#INSERT INTO t1 (col2) VALUES(CAST('2004-13-15 15:30' AS DATETIME));
 
310
 
 
311
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
 
312
--error 1292
 
313
INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME));
 
314
 
 
315
## Test INSERT with CAST AS DATETIME into TIMESTAMP
 
316
#       All test cases expected to fail should return 
 
317
#       SQLSTATE 22007 <invalid datetime value>
 
318
--error 1292
 
319
INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
 
320
# should return OK
 
321
# We accept this to be a failure
 
322
 
 
323
--error 1292
 
324
INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
 
325
--error 1292
 
326
INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
 
327
# should return SQLSTATE 22007 <invalid datetime value>
 
328
 
 
329
# deactivated because of Bug#8294
 
330
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
 
331
#--error 1292
 
332
#INSERT INTO t1 (col3) VALUES(CAST('2004-9-31 15:30' AS DATETIME));
 
333
#--error 1292
 
334
#INSERT INTO t1 (col3) VALUES(CAST('2004-10-32 15:30' AS DATETIME));
 
335
#--error 1292
 
336
#INSERT INTO t1 (col3) VALUES(CAST('2003-02-29 15:30' AS DATETIME));
 
337
#--error 1292
 
338
#INSERT INTO t1 (col3) VALUES(CAST('2004-13-15 15:30' AS DATETIME));
 
339
 
 
340
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
 
341
--error 1292
 
342
INSERT INTO t1 (col3) VALUES(CAST('0000-00-00' AS DATETIME));
 
343
 
 
344
drop table t1;
 
345
 
 
346
 
 
347
#### Test INSERT with CONVERT to DATE/DATETIME into DATE/DATETIME/TIMESTAMP
 
348
 
 
349
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
 
350
 
 
351
INSERT INTO t1 (col1) VALUES (CONVERT('2004-10-15',DATE));
 
352
INSERT INTO t1 (col2) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
 
353
INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
 
354
 
 
355
 
 
356
## Test INSERT with CONVERT to DATE into DATE
 
357
#       All test cases expected to fail should return 
 
358
#       SQLSTATE 22007 <invalid date value>
 
359
 
 
360
INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
 
361
 
 
362
--error 1292
 
363
INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
 
364
--error 1292
 
365
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
 
366
 
 
367
# deactivated because of Bug#8294
 
368
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
 
369
#--error 1292
 
370
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-9-31' , DATE));
 
371
#--error 1292
 
372
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-32' , DATE));
 
373
#--error 1292
 
374
#INSERT INTO t1 (col1) VALUES(CONVERT('2003-02-29' , DATE));
 
375
#--error 1292
 
376
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-13-15',DATE));
 
377
 
 
378
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
 
379
--error 1292
 
380
INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
 
381
 
 
382
## Test INSERT with CONVERT to DATETIME into DATETIME
 
383
#       All test cases expected to fail should return 
 
384
#       SQLSTATE 22007 <invalid datetime value>
 
385
 
 
386
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
 
387
 
 
388
--error 1292
 
389
INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
 
390
--error 1292
 
391
INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
 
392
 
 
393
# deactivated because of Bug#8294
 
394
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
 
395
#--error 1292
 
396
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-9-31 15:30',DATETIME));
 
397
#--error 1292
 
398
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-32 15:30',DATETIME));
 
399
#--error 1292
 
400
#INSERT INTO t1 (col2) VALUES(CONVERT('2003-02-29 15:30',DATETIME));
 
401
#--error 1292
 
402
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-13-15 15:30',DATETIME));
 
403
 
 
404
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
 
405
--error 1292
 
406
INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME));
 
407
 
 
408
## Test INSERT with CONVERT to DATETIME into DATETIME
 
409
#       All test cases expected to fail should return 
 
410
#       SQLSTATE 22007 <invalid datetime value>
 
411
--error 1292
 
412
INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
 
413
# should return OK
 
414
# We accept this to be a failure
 
415
 
 
416
--error 1292
 
417
INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
 
418
--error 1292
 
419
INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
 
420
 
 
421
# deactivated because of Bug#8294
 
422
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
 
423
#--error 1292
 
424
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-9-31 15:30',DATETIME));
 
425
#--error 1292
 
426
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-32 15:30',DATETIME));
 
427
#--error 1292
 
428
#INSERT INTO t1 (col3) VALUES(CONVERT('2003-02-29 15:30',DATETIME));
 
429
#--error 1292
 
430
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-13-15 15:30',DATETIME));
 
431
 
 
432
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
 
433
--error 1292
 
434
INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME));
 
435
 
 
436
drop table t1;
 
437
 
 
438
#
 
439
# Zero dates using numbers was not checked properly (Bug #5933 & #6145)
 
440
#
 
441
 
 
442
create table t1 (col1 date, col2 datetime, col3 timestamp);
 
443
--error 1292
 
444
insert into t1 values (0,0,0);
 
445
--error 1292
 
446
insert into t1 values (0.0,0.0,0.0);
 
447
--error 1292
 
448
insert into t1 (col1) values (convert('0000-00-00',date));
 
449
--error 1292
 
450
insert into t1 (col1) values (cast('0000-00-00' as date));
 
451
 
 
452
set sql_mode='no_zero_date';
 
453
insert into t1 values (0,0,0);
 
454
insert into t1 values (0.0,0.0,0.0);
 
455
drop table t1;
 
456
set sql_mode='traditional';
 
457
create table t1 (col1 date);
 
458
insert ignore into t1 values ('0000-00-00');
 
459
--error 1292
 
460
insert into t1 select * from t1;
 
461
insert ignore into t1 values ('0000-00-00');
 
462
insert ignore into t1 (col1) values (cast('0000-00-00' as date));
 
463
--error 1292
 
464
insert into t1 select * from t1;
 
465
--error 1292
 
466
alter table t1 modify col1 datetime;
 
467
alter ignore table t1 modify col1 datetime;
 
468
--error 1292
 
469
insert into t1 select * from t1;
 
470
select * from t1;
 
471
drop table t1;
 
472
 
 
473
#
 
474
# Bug #5906: handle invalid date due to conversion
 
475
#
 
476
create table t1 (d date);
 
477
--error 1292
 
478
insert into t1 values ('2000-10-00');
 
479
--error 1292
 
480
insert into t1 values (1000);
 
481
insert into t1 values ('2000-10-01');
 
482
--error 1292
 
483
update t1 set d = 1100;
 
484
select * from t1;
 
485
drop table t1;
 
486
 
 
487
#
 
488
# Bug #22824: strict, datetime, NULL, wrong warning
 
489
#
 
490
set @@sql_mode='NO_ZERO_DATE';
 
491
create table t1(a datetime not null);
 
492
select count(*) from t1 where a is null;
 
493
drop table t1;