~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Reverted 1103

Show diffs side-by-side

added added

removed removed

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