~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/strict.test

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 01:02:23 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321010223-j8cph7eeyt1u3xol
Fixed function object to ensure it correctly returns a boolean type since
memcmp returns an integer. Added some more comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
-- source include/have_innodb.inc
4
4
 
5
 
set @org_mode=@@sql_mode;
6
 
set @@sql_mode='ansi,traditional';
7
 
select @@sql_mode;
 
5
# Test INSERT with INT
8
6
 
9
7
--disable_warnings
10
 
DROP TABLE IF EXISTS t1, t2;
 
8
DROP TABLE IF EXISTS t1;
11
9
--enable_warnings
12
 
 
13
 
# Test INSERT with DATE
14
 
 
15
 
CREATE TABLE t1 (col1 date);
16
 
INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
17
 
INSERT INTO t1 VALUES('0000-10-31');
18
 
 
19
 
# All test cases expected to fail should return 
20
 
#      SQLSTATE 22007 <invalid date value>
21
 
--error 1292
22
 
INSERT INTO t1 VALUES('2004-0-31');
23
 
--error 1292
24
 
INSERT INTO t1 VALUES('2004-01-02'),('2004-0-31');
25
 
--error 1292
26
 
INSERT INTO t1 VALUES('2004-10-0');
27
 
--error 1292
28
 
INSERT INTO t1 VALUES('2004-09-31');
29
 
--error 1292
30
 
INSERT INTO t1 VALUES('2004-10-32');
31
 
--error 1292
32
 
INSERT INTO t1 VALUES('2003-02-29');
33
 
--error 1292
34
 
INSERT INTO t1 VALUES('2004-13-15');
35
 
--error 1292
36
 
INSERT INTO t1 VALUES('0000-00-00');
37
 
# Standard says we should return SQLSTATE 22018
38
 
--error 1292
39
 
INSERT INTO t1 VALUES ('59');
40
 
 
41
 
# Test the different related modes
42
 
set @@sql_mode='STRICT_ALL_TABLES';
43
 
INSERT INTO t1 VALUES('2004-01-03'),('2004-0-31');
44
 
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_IN_DATE';
45
 
--error 1292
46
 
INSERT INTO t1 VALUES('2004-0-30');
47
 
--error 1292
48
 
INSERT INTO t1 VALUES('2004-01-04'),('2004-0-31'),('2004-01-05');
49
 
INSERT INTO t1 VALUES('0000-00-00');
50
 
INSERT IGNORE INTO t1 VALUES('2004-0-29');
51
 
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_DATE';
52
 
--error 1292
53
 
INSERT INTO t1 VALUES('0000-00-00');
54
 
INSERT IGNORE INTO t1 VALUES('0000-00-00');
55
 
INSERT INTO t1 VALUES ('2004-0-30');
56
 
--error 1292
57
 
INSERT INTO t1 VALUES ('2004-2-30');
58
 
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
59
 
INSERT INTO t1 VALUES ('2004-2-30');
60
 
set @@sql_mode='ansi,traditional';
61
 
INSERT IGNORE INTO t1 VALUES('2004-02-29'),('2004-13-15'),('0000-00-00');
62
 
 
63
 
select * from t1;
64
 
drop table t1;
65
 
 
66
 
# Test difference in behaviour with InnoDB and MyISAM tables
67
 
 
68
 
set @@sql_mode='strict_trans_tables';
69
 
CREATE TABLE t1 (col1 date) engine=myisam;
70
 
--error 1292
71
 
INSERT INTO t1 VALUES('2004-13-31'),('2004-1-1');
72
 
INSERT INTO t1 VALUES ('2004-1-2'), ('2004-13-31'),('2004-1-3');
73
 
INSERT IGNORE INTO t1 VALUES('2004-13-31'),('2004-1-4');
74
 
--error 1292
75
 
INSERT INTO t1 VALUES ('2003-02-29');
76
 
INSERT ignore INTO t1 VALUES('2003-02-30');
77
 
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
78
 
INSERT ignore INTO t1 VALUES('2003-02-31');
79
 
select * from t1;
80
 
drop table t1;
81
 
 
82
 
set @@sql_mode='strict_trans_tables';
83
 
CREATE TABLE t1 (col1 date) engine=innodb;
84
 
--error 1292
85
 
INSERT INTO t1 VALUES('2004-13-31'),('2004-1-1');
86
 
--error 1292
87
 
INSERT INTO t1 VALUES ('2004-1-2'), ('2004-13-31'),('2004-1-3');
88
 
INSERT IGNORE INTO t1 VALUES('2004-13-31'),('2004-1-4');
89
 
--error 1292
90
 
INSERT INTO t1 VALUES ('2003-02-29');
91
 
INSERT ignore INTO t1 VALUES('2003-02-30');
92
 
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
93
 
INSERT ignore INTO t1 VALUES('2003-02-31');
94
 
select * from t1;
95
 
drop table t1;
96
 
set @@sql_mode='ansi,traditional';
97
 
 
98
 
# Test INSERT with DATETIME
99
 
 
100
 
CREATE TABLE t1 (col1 datetime);
101
 
INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
102
 
INSERT INTO t1 VALUES('0000-10-31 15:30:00');
103
 
 
104
 
# All test cases expected to fail should return 
105
 
#      SQLSTATE 22007 <invalid datetime value>
106
 
--error 1292
107
 
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
108
 
--error 1292
109
 
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
110
 
--error 1292
111
 
INSERT INTO t1 VALUES('2004-09-31 15:30:00');
112
 
--error 1292
113
 
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
114
 
--error 1292
115
 
INSERT INTO t1 VALUES('2003-02-29 15:30:00');
116
 
--error 1292
117
 
INSERT INTO t1 VALUES('2004-13-15 15:30:00');
118
 
--error 1292
119
 
INSERT INTO t1 VALUES('0000-00-00 15:30:00');
120
 
# Standard says we should return SQLSTATE 22018
121
 
--error 1292
122
 
INSERT INTO t1 VALUES ('59');
123
 
select * from t1;
124
 
drop table t1;
125
 
 
126
 
# Test INSERT with TIMESTAMP
127
 
 
128
 
CREATE TABLE t1 (col1 timestamp);
129
 
INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
130
 
 
131
 
# All test cases expected to fail should return 
132
 
#      SQLSTATE 22007 <invalid datetime value>
133
 
# Standard says we should return ok, but we can't as this is out of range
134
 
--error 1292
135
 
INSERT INTO t1 VALUES('0000-10-31 15:30:00');
136
 
--error 1292
137
 
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
138
 
--error 1292
139
 
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
140
 
--error 1292
141
 
INSERT INTO t1 VALUES('2004-09-31 15:30:00');
142
 
--error 1292
143
 
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
144
 
--error 1292
145
 
INSERT INTO t1 VALUES('2003-02-29 15:30:00');
146
 
--error 1292
147
 
INSERT INTO t1 VALUES('2004-13-15 15:30:00');
148
 
--error 1292
149
 
INSERT INTO t1 VALUES('2004-02-29 25:30:00');
150
 
--error 1292
151
 
INSERT INTO t1 VALUES('2004-02-29 15:65:00');
152
 
--error 1292
153
 
INSERT INTO t1 VALUES('2004-02-29 15:31:61');
154
 
--error 1292
155
 
INSERT INTO t1 VALUES('0000-00-00 15:30:00');
156
 
--error 1292
157
 
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
158
 
INSERT IGNORE INTO t1 VALUES('0000-00-00 00:00:00');
159
 
# Standard says we should return SQLSTATE 22018
160
 
--error 1292
161
 
INSERT INTO t1 VALUES ('59');
162
 
 
163
 
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
164
 
--error 1292
165
 
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
166
 
--error 1292
167
 
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
168
 
--error 1292
169
 
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
170
 
--error 1292
171
 
INSERT INTO t1 VALUES('2004-02-30 15:30:04');
172
 
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
173
 
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_IN_DATE';
174
 
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
175
 
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_DATE';
176
 
--error 1292
177
 
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
178
 
set @@sql_mode='ansi,traditional';
179
 
SELECT * FROM t1;
180
 
DROP TABLE t1;
181
 
 
182
 
 
183
 
#### Test INSERT with STR_TO_DATE into DATE/DATETIME/TIMESTAMP
184
 
 
185
 
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
186
 
 
187
 
INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y'));
188
 
INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
189
 
INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
190
 
 
191
 
## Test INSERT with STR_TO_DATE into DATE
192
 
#       All test cases expected to fail should return 
193
 
#       SQLSTATE 22007 <invalid date value>
194
 
 
195
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
196
 
 
197
 
--error 1292
198
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
199
 
--error 1292
200
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
201
 
--error 1292
202
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
203
 
--error 1411
204
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
205
 
--error 1292
206
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
207
 
--error 1411
208
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
209
 
--error 1292
210
 
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
211
 
 
212
 
## Test INSERT with STR_TO_DATE into DATETIME
213
 
#       All test cases expected to fail should return 
214
 
#       SQLSTATE 22007 <invalid datetime value>
215
 
 
216
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
217
 
 
218
 
--error 1292
219
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
220
 
--error 1292
221
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
222
 
--error 1292
223
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
224
 
--error 1411
225
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
226
 
--error 1292
227
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
228
 
--error 1411
229
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
230
 
--error 1292
231
 
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
232
 
 
233
 
## Test INSERT with STR_TO_DATE into TIMESTAMP
234
 
#       All test cases expected to fail should return 
235
 
#       SQLSTATE 22007 <invalid datetime value>
236
 
 
237
 
--error 1292
238
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
239
 
--error 1292
240
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
241
 
--error 1292
242
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
243
 
--error 1292
244
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
245
 
--error 1411
246
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
247
 
--error 1292
248
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
249
 
--error 1411
250
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
251
 
--error 1292
252
 
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
253
 
 
254
 
drop table t1;
255
 
 
256
 
 
257
 
#### Test INSERT with CAST AS DATE/DATETIME into DATE/DATETIME/TIMESTAMP
258
 
 
259
 
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
260
 
 
261
 
INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE));
262
 
INSERT INTO t1 (col2) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
263
 
INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
264
 
 
265
 
 
266
 
## Test INSERT with CAST AS DATE into DATE
267
 
#       All test cases expected to fail should return 
268
 
#       SQLSTATE 22007 <invalid date value>
269
 
 
270
 
INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
271
 
 
272
 
--error 1292
273
 
INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE));
274
 
--error 1292
275
 
INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE));
276
 
 
277
 
# deactivated because of Bug#8294
278
 
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
279
 
# --error 1292
280
 
# INSERT INTO t1 (col1) VALUES(CAST('2004-9-31' AS DATE));
281
 
# --error 1292
282
 
# INSERT INTO t1 (col1) VALUES(CAST('2004-10-32' AS DATE));
283
 
# --error 1292
284
 
# INSERT INTO t1 (col1) VALUES(CAST('2003-02-29' AS DATE));
285
 
# --error 1292
286
 
# INSERT INTO t1 (col1) VALUES(CAST('2004-13-15' AS DATE));
287
 
 
288
 
# deactivated because of Bug#6145
289
 
#  Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
290
 
--error 1292
291
 
INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
292
 
 
293
 
## Test INSERT with CAST AS DATETIME into DATETIME
294
 
#       All test cases expected to fail should return 
295
 
#       SQLSTATE 22007 <invalid datetime value>
296
 
 
297
 
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
298
 
 
299
 
--error 1292
300
 
INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
301
 
--error 1292
302
 
INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
303
 
 
304
 
# deactivated because of Bug#8294
305
 
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
306
 
#--error 1292
307
 
#INSERT INTO t1 (col2) VALUES(CAST('2004-9-31 15:30' AS DATETIME));
308
 
#--error 1292
309
 
#INSERT INTO t1 (col2) VALUES(CAST('2004-10-32 15:30' AS DATETIME));
310
 
#--error 1292
311
 
#INSERT INTO t1 (col2) VALUES(CAST('2003-02-29 15:30' AS DATETIME));
312
 
#--error 1292
313
 
#INSERT INTO t1 (col2) VALUES(CAST('2004-13-15 15:30' AS DATETIME));
314
 
 
315
 
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
316
 
--error 1292
317
 
INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME));
318
 
 
319
 
## Test INSERT with CAST AS DATETIME into TIMESTAMP
320
 
#       All test cases expected to fail should return 
321
 
#       SQLSTATE 22007 <invalid datetime value>
322
 
--error 1292
323
 
INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
324
 
# should return OK
325
 
# We accept this to be a failure
326
 
 
327
 
--error 1292
328
 
INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
329
 
--error 1292
330
 
INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
331
 
# should return SQLSTATE 22007 <invalid datetime value>
332
 
 
333
 
# deactivated because of Bug#8294
334
 
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
335
 
#--error 1292
336
 
#INSERT INTO t1 (col3) VALUES(CAST('2004-9-31 15:30' AS DATETIME));
337
 
#--error 1292
338
 
#INSERT INTO t1 (col3) VALUES(CAST('2004-10-32 15:30' AS DATETIME));
339
 
#--error 1292
340
 
#INSERT INTO t1 (col3) VALUES(CAST('2003-02-29 15:30' AS DATETIME));
341
 
#--error 1292
342
 
#INSERT INTO t1 (col3) VALUES(CAST('2004-13-15 15:30' AS DATETIME));
343
 
 
344
 
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
345
 
--error 1292
346
 
INSERT INTO t1 (col3) VALUES(CAST('0000-00-00' AS DATETIME));
347
 
 
348
 
drop table t1;
349
 
 
350
 
 
351
 
#### Test INSERT with CONVERT to DATE/DATETIME into DATE/DATETIME/TIMESTAMP
352
 
 
353
 
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
354
 
 
355
 
INSERT INTO t1 (col1) VALUES (CONVERT('2004-10-15',DATE));
356
 
INSERT INTO t1 (col2) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
357
 
INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
358
 
 
359
 
 
360
 
## Test INSERT with CONVERT to DATE into DATE
361
 
#       All test cases expected to fail should return 
362
 
#       SQLSTATE 22007 <invalid date value>
363
 
 
364
 
INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
365
 
 
366
 
--error 1292
367
 
INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
368
 
--error 1292
369
 
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
370
 
 
371
 
# deactivated because of Bug#8294
372
 
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
373
 
#--error 1292
374
 
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-9-31' , DATE));
375
 
#--error 1292
376
 
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-32' , DATE));
377
 
#--error 1292
378
 
#INSERT INTO t1 (col1) VALUES(CONVERT('2003-02-29' , DATE));
379
 
#--error 1292
380
 
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-13-15',DATE));
381
 
 
382
 
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
383
 
--error 1292
384
 
INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
385
 
 
386
 
## Test INSERT with CONVERT to DATETIME into DATETIME
387
 
#       All test cases expected to fail should return 
388
 
#       SQLSTATE 22007 <invalid datetime value>
389
 
 
390
 
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
391
 
 
392
 
--error 1292
393
 
INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
394
 
--error 1292
395
 
INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
396
 
 
397
 
# deactivated because of Bug#8294
398
 
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
399
 
#--error 1292
400
 
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-9-31 15:30',DATETIME));
401
 
#--error 1292
402
 
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-32 15:30',DATETIME));
403
 
#--error 1292
404
 
#INSERT INTO t1 (col2) VALUES(CONVERT('2003-02-29 15:30',DATETIME));
405
 
#--error 1292
406
 
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-13-15 15:30',DATETIME));
407
 
 
408
 
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
409
 
--error 1292
410
 
INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME));
411
 
 
412
 
## Test INSERT with CONVERT to DATETIME into DATETIME
413
 
#       All test cases expected to fail should return 
414
 
#       SQLSTATE 22007 <invalid datetime value>
415
 
--error 1292
416
 
INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
417
 
# should return OK
418
 
# We accept this to be a failure
419
 
 
420
 
--error 1292
421
 
INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
422
 
--error 1292
423
 
INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
424
 
 
425
 
# deactivated because of Bug#8294
426
 
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
427
 
#--error 1292
428
 
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-9-31 15:30',DATETIME));
429
 
#--error 1292
430
 
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-32 15:30',DATETIME));
431
 
#--error 1292
432
 
#INSERT INTO t1 (col3) VALUES(CONVERT('2003-02-29 15:30',DATETIME));
433
 
#--error 1292
434
 
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-13-15 15:30',DATETIME));
435
 
 
436
 
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
437
 
--error 1292
438
 
INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME));
439
 
 
440
 
drop table t1;
441
 
 
442
 
 
443
 
# Test INSERT with int
444
 
 
445
 
CREATE TABLE t1(col1 int, col2 int UNSIGNED);
446
 
INSERT INTO t1 VALUES(-128,0),(0,0),(127,255),('-128','0'),('0','0'),('127','255'),(-128.0,0.0),(0.0,0.0),(127.0,255.0);
447
 
# Test that we restored the mode checking properly after an ok query
448
 
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 2;
449
 
INSERT INTO t1 (col1) VALUES(-129);
450
 
INSERT INTO t1 (col1) VALUES(128);
451
 
INSERT INTO t1 (col2) VALUES(-1);
452
 
INSERT INTO t1 (col2) VALUES(256);
453
 
INSERT INTO t1 (col1) VALUES('-129');
454
 
INSERT INTO t1 (col1) VALUES('128');
455
 
INSERT INTO t1 (col2) VALUES('-1');
456
 
INSERT INTO t1 (col2) VALUES('256');
457
 
INSERT INTO t1 (col1) VALUES(128.0);
458
 
INSERT INTO t1 (col2) VALUES(-1.0);
459
 
INSERT INTO t1 (col2) VALUES(256.0);
460
 
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 1;
461
 
--error 1264
462
 
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
463
 
--error 1264
464
 
UPDATE t1 SET col2=col2 + 50 WHERE col2 > 0;
465
 
--error 1365
466
 
UPDATE t1 SET col1=col1 / 0 WHERE col1 > 0;
467
 
set @@sql_mode='ERROR_FOR_DIVISION_BY_ZERO';
468
 
INSERT INTO t1 values (1/0,1/0);
469
 
set @@sql_mode='ansi,traditional';
470
 
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 2;
471
 
# Should return SQLSTATE 22018 invalid character value for cast
472
 
--error 1366
473
 
INSERT INTO t1 (col1) VALUES ('');
474
 
--error 1366
475
 
INSERT INTO t1 (col1) VALUES ('a59b');
476
 
--error 1265
477
 
INSERT INTO t1 (col1) VALUES ('1a');
478
 
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
479
 
INSERT IGNORE INTO t1 values (1/0,1/0);
480
 
set @@sql_mode='ansi';
481
 
INSERT INTO t1 values (1/0,1/0);
482
 
set @@sql_mode='ansi,traditional';
483
 
INSERT IGNORE INTO t1 VALUES('-129','-1'),('128','256');
484
 
INSERT IGNORE INTO t1 VALUES(-129.0,-1.0),(128.0,256.0);
485
 
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
486
 
 
487
 
SELECT * FROM t1;
488
 
DROP TABLE t1;
489
 
 
490
 
# Test INSERT with int
491
 
 
492
 
CREATE TABLE t1(col1 int, col2 int UNSIGNED);
493
 
INSERT INTO t1 VALUES(-32768,0),(0,0),(32767,65535),('-32768','0'),('32767','65535'),(-32768.0,0.0),(32767.0,65535.0);
494
 
 
495
 
--error 1264
496
 
INSERT INTO t1 (col1) VALUES(-32769);
497
 
--error 1264
498
 
INSERT INTO t1 (col1) VALUES(32768);
499
 
--error 1264
500
 
INSERT INTO t1 (col2) VALUES(-1);
501
 
--error 1264
502
 
INSERT INTO t1 (col2) VALUES(65536);
503
 
--error 1264
504
 
INSERT INTO t1 (col1) VALUES('-32769');
505
 
--error 1264
506
 
INSERT INTO t1 (col1) VALUES('32768');
507
 
--error 1264
508
 
INSERT INTO t1 (col2) VALUES('-1');
509
 
--error 1264
510
 
INSERT INTO t1 (col2) VALUES('65536');
511
 
--error 1264
512
 
INSERT INTO t1 (col1) VALUES(-32769.0);
513
 
--error 1264
514
 
INSERT INTO t1 (col1) VALUES(32768.0);
515
 
--error 1264
516
 
INSERT INTO t1 (col2) VALUES(-1.0);
517
 
--error 1264
518
 
INSERT INTO t1 (col2) VALUES(65536.0);
519
 
--error 1264
520
 
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
521
 
--error 1264
522
 
UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
523
 
--error 1365
524
 
UPDATE t1 SET col1 = col1 / 0 WHERE col1 > 0;
525
 
--error 1365
526
 
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
527
 
--error 1366
528
 
INSERT INTO t1 (col1) VALUES ('');
529
 
--error 1366
530
 
INSERT INTO t1 (col1) VALUES ('a59b');
531
 
--error 1265
532
 
INSERT INTO t1 (col1) VALUES ('1a');
533
 
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
534
 
INSERT IGNORE INTO t1 values (1/0,1/0);
535
 
INSERT IGNORE INTO t1 VALUES(-32769,-1),(32768,65536);
536
 
INSERT IGNORE INTO t1 VALUES('-32769','-1'),('32768','65536');
537
 
INSERT IGNORE INTO t1 VALUES(-32769,-1.0),(32768.0,65536.0);
538
 
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
539
 
 
540
 
SELECT * FROM t1;
541
 
DROP TABLE t1;
542
 
 
543
 
# Test INSERT with MEDIUMINT
544
 
 
545
 
CREATE TABLE t1 (col1 MEDIUMINT, col2 MEDIUMINT UNSIGNED);
546
 
INSERT INTO t1 VALUES(-8388608,0),(0,0),(8388607,16777215),('-8388608','0'),('8388607','16777215'),(-8388608.0,0.0),(8388607.0,16777215.0);
547
 
--error 1264
548
 
INSERT INTO t1 (col1) VALUES(-8388609);
549
 
--error 1264
550
 
INSERT INTO t1 (col1) VALUES(8388608);
551
 
--error 1264
552
 
INSERT INTO t1 (col2) VALUES(-1);
553
 
--error 1264
554
 
INSERT INTO t1 (col2) VALUES(16777216);
555
 
--error 1264
556
 
INSERT INTO t1 (col1) VALUES('-8388609');
557
 
--error 1264
558
 
INSERT INTO t1 (col1) VALUES('8388608');
559
 
--error 1264
560
 
INSERT INTO t1 (col2) VALUES('-1');
561
 
--error 1264
562
 
INSERT INTO t1 (col2) VALUES('16777216');
563
 
--error 1264
564
 
INSERT INTO t1 (col1) VALUES(-8388609.0);
565
 
--error 1264
566
 
INSERT INTO t1 (col1) VALUES(8388608.0);
567
 
--error 1264
568
 
INSERT INTO t1 (col2) VALUES(-1.0);
569
 
--error 1264
570
 
INSERT INTO t1 (col2) VALUES(16777216.0);
571
 
 
572
 
--error 1264
573
 
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
574
 
--error 1264
575
 
UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
576
 
--error 1365
577
 
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
578
 
--error 1365
579
 
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
580
 
--error 1366
581
 
INSERT INTO t1 (col1) VALUES ('');
582
 
--error 1366
583
 
INSERT INTO t1 (col1) VALUES ('a59b');
584
 
--error 1265
585
 
INSERT INTO t1 (col1) VALUES ('1a');
586
 
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
587
 
INSERT IGNORE INTO t1 values (1/0,1/0);
588
 
INSERT IGNORE INTO t1 VALUES(-8388609,-1),(8388608,16777216);
589
 
INSERT IGNORE INTO t1 VALUES('-8388609','-1'),('8388608','16777216');
590
 
INSERT IGNORE INTO t1 VALUES(-8388609.0,-1.0),(8388608.0,16777216.0);
591
 
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
592
 
 
593
 
SELECT * FROM t1;
594
 
DROP TABLE t1;
595
 
 
596
 
# Test INSERT with INT
597
 
 
598
 
CREATE TABLE t1 (col1 INT, col2 INT UNSIGNED);
599
 
INSERT INTO t1 VALUES(-2147483648,0),(0,0),(2147483647,4294967295),('-2147483648','0'),('2147483647','4294967295'),(-2147483648.0,0.0),(2147483647.0,4294967295.0);
600
 
--error 1264
 
10
CREATE TABLE t1 (col1 INT);
 
11
INSERT INTO t1 VALUES(-2147483648),(0),(2147483647),('-2147483648'),('2147483647'),(-2147483648.0),(2147483647.0);
 
12
--error ER_WARN_DATA_OUT_OF_RANGE
601
13
INSERT INTO t1 (col1) VALUES(-2147483649);
602
 
--error 1264
 
14
--error ER_WARN_DATA_OUT_OF_RANGE
603
15
INSERT INTO t1 (col1) VALUES(2147643648);
604
 
--error 1264
605
 
INSERT INTO t1 (col2) VALUES(-1);
606
 
--error 1264
607
 
INSERT INTO t1 (col2) VALUES(4294967296);
608
 
--error 1264
 
16
--error ER_WARN_DATA_OUT_OF_RANGE
609
17
INSERT INTO t1 (col1) VALUES('-2147483649');
610
 
--error 1264
 
18
--error ER_WARN_DATA_OUT_OF_RANGE
611
19
INSERT INTO t1 (col1) VALUES('2147643648');
612
 
--error 1264
613
 
INSERT INTO t1 (col2) VALUES('-1');
614
 
--error 1264
615
 
INSERT INTO t1 (col2) VALUES('4294967296');
616
 
--error 1264
 
20
--error ER_WARN_DATA_OUT_OF_RANGE
617
21
INSERT INTO t1 (col1) VALUES(-2147483649.0);
618
 
--error 1264
 
22
--error ER_WARN_DATA_OUT_OF_RANGE
619
23
INSERT INTO t1 (col1) VALUES(2147643648.0);
620
 
--error 1264
621
 
INSERT INTO t1 (col2) VALUES(-1.0);
622
 
--error 1264
623
 
INSERT INTO t1 (col2) VALUES(4294967296.0);
624
24
 
625
 
--error 1264
 
25
--error ER_WARN_DATA_OUT_OF_RANGE
626
26
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
627
 
--error 1264
628
 
UPDATE t1 SET col2 =col2 + 50 WHERE col2 > 0;
629
 
--error 1365
 
27
--error ER_DIVISION_BY_ZERO
630
28
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
631
 
--error 1365
 
29
--error ER_DIVISION_BY_ZERO
632
30
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
633
 
--error 1366
 
31
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
634
32
INSERT INTO t1 (col1) VALUES ('');
635
 
--error 1366
 
33
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
636
34
INSERT INTO t1 (col1) VALUES ('a59b');
637
35
--error 1265
638
36
INSERT INTO t1 (col1) VALUES ('1a');
639
37
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
640
 
INSERT IGNORE INTO t1 values (1/0,1/0);
641
 
INSERT IGNORE INTO t1 values (-2147483649, -1),(2147643648,4294967296);
642
 
INSERT IGNORE INTO t1 values ('-2147483649', '-1'),('2147643648','4294967296');
643
 
INSERT IGNORE INTO t1 values (-2147483649.0, -1.0),(2147643648.0,4294967296.0);
644
 
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
 
38
INSERT IGNORE INTO t1 values (1/0);
 
39
INSERT IGNORE INTO t1 values (-2147483649),(2147643648);
 
40
INSERT IGNORE INTO t1 values ('-2147483649'),('2147643648');
 
41
INSERT IGNORE INTO t1 values (-2147483649.0),(2147643648.0);
645
42
SELECT * FROM t1;
646
43
DROP TABLE t1;
647
44
 
660
46
# Note that this doesn't behave 100 % to standard as we rotate
661
47
# integers when it's too big/small (just like C)
662
48
 
663
 
CREATE TABLE t1 (col1 BIGINT, col2 BIGINT UNSIGNED);
664
 
INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,18446744073709551615);
665
 
INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615');
666
 
INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0);
 
49
CREATE TABLE t1 (col1 BIGINT);
 
50
INSERT INTO t1 VALUES(-9223372036854775808),(0),(9223372036854775807);
 
51
INSERT INTO t1 VALUES('-9223372036854775808'),('9223372036854775807');
 
52
INSERT INTO t1 VALUES(-9223372036854774000.0),(9223372036854775700.0);
667
53
 
668
 
--error 1264
 
54
--error ER_WARN_DATA_OUT_OF_RANGE
669
55
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
670
 
--error 1264
671
 
INSERT INTO t1 (col1) VALUES(9223372036854775808);
672
 
--error 1264
673
 
INSERT INTO t1 (col2) VALUES(-1);
 
56
# DISABLED due to https://bugs.launchpad.net/drizzle/+bug/316221
 
57
# --error ER_WARN_DATA_OUT_OF_RANGE
 
58
# INSERT INTO t1 (col1) VALUES(9223372036854775808);
674
59
 
675
 
--error 1264
676
 
INSERT INTO t1 (col2) VALUES(18446744073709551616);
677
 
--error 1264
 
60
--error ER_WARN_DATA_OUT_OF_RANGE
678
61
INSERT INTO t1 (col1) VALUES('-9223372036854775809');
679
 
--error 1264
 
62
--error ER_WARN_DATA_OUT_OF_RANGE
680
63
INSERT INTO t1 (col1) VALUES('9223372036854775808');
681
 
--error 1264
682
 
INSERT INTO t1 (col2) VALUES('-1');
683
 
--error 1264
684
 
INSERT INTO t1 (col2) VALUES('18446744073709551616');
685
64
 
686
65
# Note that the following two double numbers are slighty bigger than max/min
687
66
# bigint becasue of rounding errors when converting it to bigint
688
 
--error 1264
 
67
--error ER_WARN_DATA_OUT_OF_RANGE
689
68
INSERT INTO t1 (col1) VALUES(-9223372036854785809.0);
690
 
--error 1264
 
69
--error ER_WARN_DATA_OUT_OF_RANGE
691
70
INSERT INTO t1 (col1) VALUES(9223372036854785808.0);
692
 
--error 1264
693
 
INSERT INTO t1 (col2) VALUES(-1.0);
694
 
--error 1264
695
 
INSERT INTO t1 (col2) VALUES(18446744073709551616.0);
696
71
 
697
72
# The following doesn't give an error as it's done in integer context
698
73
# UPDATE t1 SET col1=col1 - 5000 WHERE col1 < 0;
699
74
# UPDATE t1 SET col2 =col2 + 5000 WHERE col2 > 0;
700
75
 
701
 
--error 1365
 
76
--error ER_DIVISION_BY_ZERO
702
77
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
703
 
--error 1365
 
78
--error ER_DIVISION_BY_ZERO
704
79
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
705
 
--error 1366
 
80
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
706
81
INSERT INTO t1 (col1) VALUES ('');
707
 
--error 1366
 
82
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
708
83
INSERT INTO t1 (col1) VALUES ('a59b');
709
84
--error 1265
710
85
INSERT INTO t1 (col1) VALUES ('1a');
711
86
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
712
 
INSERT IGNORE INTO t1 values (1/0,1/0);
713
 
INSERT IGNORE INTO t1 VALUES(-9223372036854775809,-1),(9223372036854775808,18446744073709551616);
714
 
INSERT IGNORE INTO t1 VALUES('-9223372036854775809','-1'),('9223372036854775808','18446744073709551616');
715
 
INSERT IGNORE INTO t1 VALUES(-9223372036854785809.0,-1.0),(9223372036854785808.0,18446744073709551616.0);
716
 
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
 
87
INSERT IGNORE INTO t1 values (1/0);
 
88
INSERT IGNORE INTO t1 VALUES(-9223372036854775809),(9223372036854775808);
 
89
INSERT IGNORE INTO t1 VALUES('-9223372036854775809'),('9223372036854775808');
 
90
INSERT IGNORE INTO t1 VALUES(-9223372036854785809.0),(9223372036854785808.0);
717
91
SELECT * FROM t1;
718
92
DROP TABLE t1;
719
93
 
726
100
 
727
101
# The 2 following inserts should generate a warning, but doesn't yet
728
102
# because NUMERIC works like DECIMAL
729
 
--error 1264
 
103
--error ER_WARN_DATA_OUT_OF_RANGE
730
104
INSERT INTO t1 VALUES (101.55);
731
 
--error 1264
 
105
--error ER_WARN_DATA_OUT_OF_RANGE
732
106
INSERT INTO t1 VALUES (101);
733
 
--error 1264
 
107
--error ER_WARN_DATA_OUT_OF_RANGE
734
108
INSERT INTO t1 VALUES (-101.55);
735
 
--error 1264
 
109
--error ER_WARN_DATA_OUT_OF_RANGE
736
110
INSERT INTO t1 VALUES (1010.55);
737
 
--error 1264
 
111
--error ER_WARN_DATA_OUT_OF_RANGE
738
112
INSERT INTO t1 VALUES (1010);
739
113
# The 2 following inserts should generate a warning, but doesn't yet
740
114
# because NUMERIC works like DECIMAL
741
 
--error 1264
 
115
--error ER_WARN_DATA_OUT_OF_RANGE
742
116
INSERT INTO t1 VALUES ('101.55');
743
 
--error 1264
 
117
--error ER_WARN_DATA_OUT_OF_RANGE
744
118
INSERT INTO t1 VALUES ('101');
745
 
--error 1264
 
119
--error ER_WARN_DATA_OUT_OF_RANGE
746
120
INSERT INTO t1 VALUES ('-101.55');
747
 
--error 1264
 
121
--error ER_WARN_DATA_OUT_OF_RANGE
748
122
INSERT INTO t1 VALUES ('-1010.55');
749
 
--error 1264
 
123
--error ER_WARN_DATA_OUT_OF_RANGE
750
124
INSERT INTO t1 VALUES ('-100E+1');
751
 
--error 1366
 
125
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
752
126
INSERT INTO t1 VALUES ('-100E');
753
 
--error 1264
 
127
--error ER_WARN_DATA_OUT_OF_RANGE
754
128
UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
755
 
--error 1365
 
129
--error ER_DIVISION_BY_ZERO
756
130
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
757
 
--error 1365
 
131
--error ER_DIVISION_BY_ZERO
758
132
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
759
133
#--error 1265
760
 
--error 1366
 
134
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
761
135
INSERT INTO t1 (col1) VALUES ('');
762
136
#--error 1265
763
 
--error 1366
 
137
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
764
138
INSERT INTO t1 (col1) VALUES ('a59b');
765
 
--error 1366
 
139
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
766
140
INSERT INTO t1 (col1) VALUES ('1a');
767
141
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
768
142
INSERT IGNORE INTO t1 values (1/0);
773
147
SELECT * FROM t1;
774
148
DROP TABLE t1;
775
149
 
776
 
# Test INSERT with FLOAT
777
 
 
778
 
CREATE TABLE t1 (col1 FLOAT, col2 FLOAT UNSIGNED);
779
 
INSERT INTO t1 VALUES (-1.1E-37,0),(+3.4E+38,+3.4E+38);
780
 
INSERT INTO t1 VALUES ('-1.1E-37',0),('+3.4E+38','+3.4E+38');
781
 
# We don't give warnings for underflow
782
 
INSERT INTO t1 (col1) VALUES (3E-46);
783
 
--error 1264
784
 
INSERT INTO t1 (col1) VALUES (+3.4E+39);
785
 
--error 1264
786
 
INSERT INTO t1 (col2) VALUES (-1.1E-3);
787
 
--error 1264
788
 
INSERT INTO t1 (col1) VALUES ('+3.4E+39');
789
 
--error 1264
790
 
INSERT INTO t1 (col2) VALUES ('-1.1E-3');
791
 
--error 1264
792
 
UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0;
793
 
--error 1365
794
 
UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0;
795
 
--error 1365
796
 
UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0;
797
 
--error 1265
798
 
INSERT INTO t1 (col1) VALUES ('');
799
 
--error 1265
800
 
INSERT INTO t1 (col1) VALUES ('a59b');
801
 
--error 1265
802
 
INSERT INTO t1 (col1) VALUES ('1a');
803
 
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
804
 
INSERT IGNORE INTO t1 (col1) VALUES (1/0);
805
 
INSERT IGNORE INTO t1 VALUES (+3.4E+39,-3.4E+39);
806
 
INSERT IGNORE INTO t1 VALUES ('+3.4E+39','-3.4E+39');
807
 
SELECT * FROM t1;
808
 
DROP TABLE t1;
809
 
 
810
 
# Test INSERT with DOUBLE
811
 
 
812
 
CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED);
813
 
INSERT INTO t1 VALUES (-2.2E-307,0),(2E-307,0),(+1.7E+308,+1.7E+308);
814
 
INSERT INTO t1 VALUES ('-2.2E-307',0),('-2E-307',0),('+1.7E+308','+1.7E+308');
815
 
# We don't give warnings for underflow
816
 
INSERT INTO t1 (col1) VALUES (-2.2E-330);
817
 
--error 1367,1264
818
 
INSERT INTO t1 (col1) VALUES (+1.7E+309);
819
 
--error 1264
820
 
INSERT INTO t1 (col2) VALUES (-1.1E-3);
821
 
--error 1264
822
 
INSERT INTO t1 (col1) VALUES ('+1.8E+309');
823
 
--error 1264
824
 
INSERT INTO t1 (col2) VALUES ('-1.2E-3');
825
 
UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0;
826
 
--error 1365
827
 
UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0;
828
 
--error 1365
829
 
UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0;
830
 
--error 1265
831
 
INSERT INTO t1 (col1) VALUES ('');
832
 
--error 1265
833
 
INSERT INTO t1 (col1) VALUES ('a59b');
834
 
--error 1265
835
 
INSERT INTO t1 (col1) VALUES ('1a');
836
 
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
837
 
INSERT IGNORE INTO t1 (col1) values (1/0);
838
 
--error 1367
839
 
INSERT IGNORE INTO t1 VALUES (+1.9E+309,-1.9E+309);
840
 
INSERT IGNORE INTO t1 VALUES ('+2.0E+309','-2.0E+309');
841
 
# stupid...
842
 
--replace_result -0 0 1.7976931348623e+308 1.79769313486232e+308
843
 
SELECT * FROM t1;
844
 
DROP TABLE t1;
845
 
 
846
150
# Testing INSERT with CHAR/VARCHAR
847
151
 
848
152
CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6));
865
169
 
866
170
CREATE TABLE t1 (col1 enum('red','blue','green'));
867
171
INSERT INTO t1 VALUES ('red'),('blue'),('green');
868
 
--error 1265
 
172
--error 1691 # Bad enum
869
173
INSERT INTO t1 (col1) VALUES ('yellow');
870
 
--error 1265
 
174
--error 1691 # Bad enum
871
175
INSERT INTO t1 (col1) VALUES ('redd');
872
 
--error 1265
 
176
--error 1691 # Bad enum
873
177
INSERT INTO t1 VALUES ('');
874
 
--error 1265
 
178
--error 1691 # Bad enum
875
179
UPDATE t1 SET col1 ='yellow' WHERE col1 ='green';
 
180
--error 1691 # Bad enum
876
181
INSERT IGNORE INTO t1 VALUES ('yellow');
 
182
--error 1691 # Bad enum
877
183
UPDATE IGNORE t1 SET col1 ='yellow' WHERE col1 ='blue';
878
184
SELECT * FROM t1;
879
185
DROP TABLE t1;
916
222
--error 1048
917
223
INSERT INTO t1 SELECT 1,NULL;
918
224
INSERT IGNORE INTO t1 values (NULL,NULL);
 
225
--error ER_NO_DEFAULT_FOR_FIELD
919
226
INSERT IGNORE INTO t1 (col1) values (3);
 
227
--error ER_NO_DEFAULT_FOR_FIELD
920
228
INSERT IGNORE INTO t1 () values ();
921
229
SELECT * FROM t1;
922
230
DROP TABLE t1;
925
233
# Bug #9029 Traditional: Wrong SQLSTATE returned for string truncation
926
234
#
927
235
 
928
 
set sql_mode='traditional';
929
236
create table t1 (charcol char(255), varcharcol varchar(255),
930
 
binarycol binary(255), varbinarycol varbinary(255), tinytextcol tinytext,
931
 
tinyblobcol tinyblob);
 
237
       varbinarycol varbinary(255));
932
238
--error 1406
933
239
insert into t1 (charcol) values (repeat('x',256));
934
240
--error 1406
935
241
insert into t1 (varcharcol) values (repeat('x',256));
936
242
--error 1406
937
 
insert into t1 (binarycol) values (repeat('x',256));
938
 
--error 1406
939
243
insert into t1 (varbinarycol) values (repeat('x',256));
940
 
--error 1406
941
 
insert into t1 (tinytextcol) values (repeat('x',256));
942
 
--error 1406
943
 
insert into t1 (tinyblobcol) values (repeat('x',256));
944
 
select * from t1;
945
 
drop table t1;
946
 
 
947
 
#
948
 
# Bug #5902: STR_TO_DATE() didn't give errors in traditional mode
949
 
#
950
 
 
951
 
set sql_mode='traditional';
952
 
create table t1 (col1 datetime);
953
 
--error 1292
954
 
insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
955
 
--error 1411
956
 
insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
957
 
--error 1411
958
 
insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
959
 
--error 1411
960
 
insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
961
 
set sql_mode='';
962
 
insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
963
 
insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
964
 
insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
965
 
insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
966
 
 
967
 
# Some correct values, just to test the functions
968
 
insert into t1 values(STR_TO_DATE('31.10.2004 15.30','%d.%m.%Y %H.%i'));
969
 
insert into t1 values(STR_TO_DATE('2004.12.12 11:22:33 AM','%Y.%m.%d %r'));
970
 
insert into t1 values(STR_TO_DATE('2004.12.12 10:22:59','%Y.%m.%d %T'));
971
 
 
972
 
select * from t1;
973
 
 
974
 
# Check that select don't abort even in strict mode (for now)
975
 
set sql_mode='traditional';
976
 
 
977
 
select count(*) from t1 where STR_TO_DATE('2004.12.12 10:22:61','%Y.%m.%d %T') IS NULL;
978
 
 
 
244
select * from t1;
979
245
drop table t1;
980
246
 
981
247
#
990
256
--error 1292
991
257
insert into t1 (col1) values (cast(1000.0 as char(3)));
992
258
--error 1292
993
 
insert into t1 (col2) values (cast('abc' as signed integer));
 
259
insert into t1 (col2) values (cast('abc' as DECIMAL));
994
260
--error 1292
995
261
insert into t1 (col2) values (10E+0 + 'a');
996
 
--error 1292
997
 
insert into t1 (col2) values (cast('10a' as integer));
998
 
insert into t1 (col2) values (cast('10' as integer));
999
 
insert into t1 (col2) values (cast('10' as signed integer));
 
262
--error 1265
 
263
insert into t1 (col2) values ('10a');
 
264
insert into t1 (col2) values (cast('10a' as DECIMAL));
 
265
insert into t1 (col2) values (cast('10' as DECIMAL));
 
266
insert into t1 (col2) values (cast('10' as DECIMAL));
1000
267
insert into t1 (col2) values (10E+0 + '0 ');
1001
268
select * from t1;
1002
269
drop table t1;
1003
270
 
1004
 
#
1005
 
# Zero dates using numbers was not checked properly (Bug #5933 & #6145)
1006
 
#
1007
 
 
1008
 
create table t1 (col1 date, col2 datetime, col3 timestamp);
1009
 
--error 1292
1010
 
insert into t1 values (0,0,0);
1011
 
--error 1292
1012
 
insert into t1 values (0.0,0.0,0.0);
1013
 
--error 1292
1014
 
insert into t1 (col1) values (convert('0000-00-00',date));
1015
 
--error 1292
1016
 
insert into t1 (col1) values (cast('0000-00-00' as date));
1017
 
 
1018
 
set sql_mode='no_zero_date';
1019
 
insert into t1 values (0,0,0);
1020
 
insert into t1 values (0.0,0.0,0.0);
1021
 
drop table t1;
1022
 
set sql_mode='traditional';
1023
 
create table t1 (col1 date);
1024
 
insert ignore into t1 values ('0000-00-00');
1025
 
--error 1292
1026
 
insert into t1 select * from t1;
1027
 
insert ignore into t1 values ('0000-00-00');
1028
 
insert ignore into t1 (col1) values (cast('0000-00-00' as date));
1029
 
--error 1292
1030
 
insert into t1 select * from t1;
1031
 
--error 1292
1032
 
alter table t1 modify col1 datetime;
1033
 
alter ignore table t1 modify col1 datetime;
1034
 
--error 1292
1035
 
insert into t1 select * from t1;
1036
 
select * from t1;
1037
 
drop table t1;
1038
 
 
1039
 
#
1040
 
# Test of inserting an invalid value via a stored procedure (Bug #5907)
1041
 
#
1042
 
create table t1 (col1 int);
1043
 
drop procedure if exists t1;
1044
 
delimiter |;
1045
 
create procedure t1 () begin declare exit handler for sqlexception
1046
 
select'a'; insert into t1 values (200); end;|
1047
 
delimiter ;|
1048
 
call t1();
1049
 
select * from t1;
1050
 
drop procedure t1;
1051
 
drop table t1;
1052
 
 
1053
 
#
1054
 
# Restore mode
1055
 
#
1056
 
set sql_mode=@org_mode;
1057
 
 
1058
271
# Test fields with no default value that are NOT NULL (Bug #5986)
1059
 
SET @@sql_mode = 'traditional';
1060
272
CREATE TABLE t1 (i int not null);
1061
273
--error 1364
1062
274
INSERT INTO t1 VALUES ();
1074
286
--error 1364
1075
287
INSERT INTO t1 VALUES (DEFAULT,1);
1076
288
DROP TABLE t1;
1077
 
SET @@sql_mode = '';
1078
289
CREATE TABLE t1 (i int not null);
 
290
--error 1364
1079
291
INSERT INTO t1 VALUES ();
 
292
--error 1364
1080
293
INSERT INTO t1 VALUES (DEFAULT);
1081
294
# DEFAULT(i) is an error even with the default sql_mode
1082
295
--error 1364
1083
296
INSERT INTO t1 VALUES (DEFAULT(i));
1084
297
ALTER TABLE t1 ADD j int;
 
298
--error 1364
1085
299
INSERT INTO t1 SET j = 1;
 
300
--error 1364
1086
301
INSERT INTO t1 SET j = 1, i = DEFAULT;
1087
302
--error 1364
1088
303
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
 
304
--error 1364
1089
305
INSERT INTO t1 VALUES (DEFAULT,1);
1090
306
DROP TABLE t1;
1091
307
 
1093
309
# Bugs #8295 and #8296: varchar and varbinary conversion
1094
310
#
1095
311
 
1096
 
set @@sql_mode='traditional';
1097
312
--error 1074
1098
313
create table t1(a varchar(65537));
1099
314
--error 1074
1103
318
# Bug #9881: problem with altering table
1104
319
#
1105
320
 
1106
 
set @@sql_mode='traditional';
1107
321
create table t1(a int, b date not null);                                       
1108
322
alter table t1 modify a bigint not null;
1109
323
show create table t1;
1110
324
drop table t1;
1111
325
 
1112
326
#
1113
 
# Bug #5906: handle invalid date due to conversion
1114
 
#
1115
 
set @@sql_mode='traditional';
1116
 
create table t1 (d date);
1117
 
--error 1292
1118
 
insert into t1 values ('2000-10-00');
1119
 
--error 1292
1120
 
insert into t1 values (1000);
1121
 
insert into t1 values ('2000-10-01');
1122
 
--error 1292
1123
 
update t1 set d = 1100;
1124
 
select * from t1;
1125
 
drop table t1;
1126
 
 
1127
 
#
1128
327
# Bug #11964: alter table with timestamp field
1129
328
#
1130
329
 
1131
 
set @@sql_mode='traditional';
1132
330
create table t1(a int, b timestamp);
1133
331
alter table t1 add primary key(a);
1134
332
show create table t1;
1138
336
show create table t1;
1139
337
drop table t1;
1140
338
 
1141
 
#
1142
 
# BIT fields
1143
 
#
1144
 
 
1145
 
set @@sql_mode='traditional';
1146
 
create table t1(a bit(2));
1147
 
--error 1406
1148
 
insert into t1 values(b'101');
1149
 
select * from t1;
1150
 
drop table t1;
1151
339
 
1152
340
#
1153
341
# Bug#17626 CREATE TABLE ... SELECT failure with TRADITIONAL SQL mode
1154
342
#
1155
 
set sql_mode='traditional';
1156
343
create table t1 (date date not null);
1157
344
create table t2 select date from t1;
1158
345
show create table t2;
1159
346
drop table t2,t1;
1160
 
set @@sql_mode= @org_mode;
1161
347
 
1162
 
set names utf8;
1163
348
create table t1 (i int)
1164
349
comment '123456789*123456789*123456789*123456789*123456789*123456789*';
1165
350
show create table t1;
1168
353
#
1169
354
# Bug #26359: Strings becoming truncated and converted to numbers under STRICT mode
1170
355
#
1171
 
set sql_mode= 'traditional';
 
356
 
1172
357
create table t1(col1 int, col2 int, 
1173
358
  col3 int, col4 int,
1174
 
  col5 mediumint, col6 mediumint,
1175
359
  col7 int, col8 int,
1176
360
  col9 bigint, col10 bigint);
1177
 
--error 1366
 
361
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1178
362
insert into t1(col1) values('-');
1179
 
--error 1366
 
363
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1180
364
insert into t1(col2) values('+');
1181
 
--error 1366
 
365
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1182
366
insert into t1(col3) values('-');
1183
 
--error 1366
 
367
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1184
368
insert into t1(col4) values('+');
1185
 
--error 1366
1186
 
insert into t1(col5) values('-');
1187
 
--error 1366
1188
 
insert into t1(col6) values('+');
1189
 
--error 1366
 
369
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1190
370
insert into t1(col7) values('-');
1191
 
--error 1366
 
371
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1192
372
insert into t1(col8) values('+');
1193
 
--error 1366
 
373
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1194
374
insert into t1(col9) values('-');
1195
 
--error 1366
 
375
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
1196
376
insert into t1(col10) values('+');
1197
377
drop table t1;
1198
378
 
1199
 
#
1200
 
# Bug #27176: Assigning a string to an year column has unexpected results
1201
 
#
1202
 
set sql_mode='traditional';
1203
 
create table t1(a year);
1204
 
--error 1366
1205
 
insert into t1 values ('-');
1206
 
--error 1366
1207
 
insert into t1 values ('+');
1208
 
--error 1366
1209
 
insert into t1 values ('');
1210
 
--error 1265
1211
 
insert into t1 values ('2000a');
1212
 
--error 1265
1213
 
insert into t1 values ('2E3x');
1214
 
drop table t1;
1215
379
 
1216
380
#
1217
381
# Bug#27069 set with identical elements are created
1218
382
#
1219
 
set sql_mode='traditional';
1220
 
--error 1291
1221
 
create table t1 (f1 set('a','a'));
1222
383
--error 1291
1223
384
create table t1 (f1 enum('a','a'));
1224
385
 
1225
 
#
1226
 
# Bug #22824: strict, datetime, NULL, wrong warning
1227
 
#
1228
 
set @@sql_mode='NO_ZERO_DATE';
1229
 
create table t1(a datetime not null);
1230
 
select count(*) from t1 where a is null;
1231
 
drop table t1;
1232
 
 
1233
386
--echo End of 5.0 tests