~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/strict.test

  • Committer: Monty
  • Date: 2008-11-07 05:51:15 UTC
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: mordred@palanthas.inaugust.com-20081107055115-0275gvq62buzls77
Fixed a decimal sign thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
-- source include/have_innodb.inc
4
4
 
5
 
# Test INSERT with INT
 
5
set @org_mode=@@sql_mode;
 
6
set @@sql_mode='ansi,traditional';
 
7
select @@sql_mode;
6
8
 
7
9
--disable_warnings
8
 
DROP TABLE IF EXISTS t1;
 
10
DROP TABLE IF EXISTS t1, t2;
9
11
--enable_warnings
10
 
CREATE TABLE t1 (col1 INT);
11
 
INSERT INTO t1 VALUES(-2147483648);
12
 
INSERT INTO t1 VALUES (0);
13
 
INSERT INTO t1 VALUES (2147483647);
14
 
INSERT INTO t1 VALUES ('-2147483648');
15
 
INSERT INTO t1 VALUES ('2147483647');
16
 
INSERT INTO t1 VALUES (-2147483648.0);
17
 
INSERT INTO t1 VALUES (2147483647.0);
18
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
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
-- error 1264
 
450
INSERT INTO t1 (col1) VALUES(-129);
 
451
-- error 1264
 
452
INSERT INTO t1 (col1) VALUES(128);
 
453
-- error 1264
 
454
INSERT INTO t1 (col2) VALUES(-1);
 
455
-- error 1264
 
456
INSERT INTO t1 (col2) VALUES(256);
 
457
-- error 1264
 
458
INSERT INTO t1 (col1) VALUES('-129');
 
459
-- error 1264
 
460
INSERT INTO t1 (col1) VALUES('128');
 
461
-- error 1264
 
462
INSERT INTO t1 (col2) VALUES('-1');
 
463
-- error 1264
 
464
INSERT INTO t1 (col2) VALUES('256');
 
465
-- error 1264
 
466
INSERT INTO t1 (col1) VALUES(128.0);
 
467
-- error 1264
 
468
INSERT INTO t1 (col2) VALUES(-1.0);
 
469
-- error 1264
 
470
INSERT INTO t1 (col2) VALUES(256.0);
 
471
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 1;
 
472
--error 1264
 
473
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
 
474
--error 1264
 
475
UPDATE t1 SET col2=col2 + 50 WHERE col2 > 0;
 
476
--error 1365
 
477
UPDATE t1 SET col1=col1 / 0 WHERE col1 > 0;
 
478
set @@sql_mode='ERROR_FOR_DIVISION_BY_ZERO';
 
479
INSERT INTO t1 values (1/0,1/0);
 
480
set @@sql_mode='ansi,traditional';
 
481
SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 2;
 
482
# Should return SQLSTATE 22018 invalid character value for cast
 
483
--error 1366
 
484
INSERT INTO t1 (col1) VALUES ('');
 
485
--error 1366
 
486
INSERT INTO t1 (col1) VALUES ('a59b');
 
487
--error 1265
 
488
INSERT INTO t1 (col1) VALUES ('1a');
 
489
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
 
490
INSERT IGNORE INTO t1 values (1/0,1/0);
 
491
set @@sql_mode='ansi';
 
492
INSERT INTO t1 values (1/0,1/0);
 
493
set @@sql_mode='ansi,traditional';
 
494
INSERT IGNORE INTO t1 VALUES('-129','-1'),('128','256');
 
495
INSERT IGNORE INTO t1 VALUES(-129.0,-1.0),(128.0,256.0);
 
496
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
 
497
 
 
498
SELECT * FROM t1;
 
499
DROP TABLE t1;
 
500
 
 
501
# Test INSERT with int
 
502
 
 
503
CREATE TABLE t1(col1 int, col2 int UNSIGNED);
 
504
INSERT INTO t1 VALUES(-32768,0),(0,0),(32767,65535),('-32768','0'),('32767','65535'),(-32768.0,0.0),(32767.0,65535.0);
 
505
 
 
506
--error 1264
 
507
INSERT INTO t1 (col1) VALUES(-32769);
 
508
--error 1264
 
509
INSERT INTO t1 (col1) VALUES(32768);
 
510
--error 1264
 
511
INSERT INTO t1 (col2) VALUES(-1);
 
512
--error 1264
 
513
INSERT INTO t1 (col2) VALUES(65536);
 
514
--error 1264
 
515
INSERT INTO t1 (col1) VALUES('-32769');
 
516
--error 1264
 
517
INSERT INTO t1 (col1) VALUES('32768');
 
518
--error 1264
 
519
INSERT INTO t1 (col2) VALUES('-1');
 
520
--error 1264
 
521
INSERT INTO t1 (col2) VALUES('65536');
 
522
--error 1264
 
523
INSERT INTO t1 (col1) VALUES(-32769.0);
 
524
--error 1264
 
525
INSERT INTO t1 (col1) VALUES(32768.0);
 
526
--error 1264
 
527
INSERT INTO t1 (col2) VALUES(-1.0);
 
528
--error 1264
 
529
INSERT INTO t1 (col2) VALUES(65536.0);
 
530
--error 1264
 
531
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
 
532
--error 1264
 
533
UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
 
534
--error 1365
 
535
UPDATE t1 SET col1 = col1 / 0 WHERE col1 > 0;
 
536
--error 1365
 
537
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
 
538
--error 1366
 
539
INSERT INTO t1 (col1) VALUES ('');
 
540
--error 1366
 
541
INSERT INTO t1 (col1) VALUES ('a59b');
 
542
--error 1265
 
543
INSERT INTO t1 (col1) VALUES ('1a');
 
544
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
 
545
INSERT IGNORE INTO t1 values (1/0,1/0);
 
546
INSERT IGNORE INTO t1 VALUES(-32769,-1),(32768,65536);
 
547
INSERT IGNORE INTO t1 VALUES('-32769','-1'),('32768','65536');
 
548
INSERT IGNORE INTO t1 VALUES(-32769,-1.0),(32768.0,65536.0);
 
549
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
 
550
 
 
551
SELECT * FROM t1;
 
552
DROP TABLE t1;
 
553
 
 
554
# Test INSERT with MEDIUMINT
 
555
 
 
556
CREATE TABLE t1 (col1 MEDIUMINT, col2 MEDIUMINT UNSIGNED);
 
557
INSERT INTO t1 VALUES(-8388608,0),(0,0),(8388607,16777215),('-8388608','0'),('8388607','16777215'),(-8388608.0,0.0),(8388607.0,16777215.0);
 
558
--error 1264
 
559
INSERT INTO t1 (col1) VALUES(-8388609);
 
560
--error 1264
 
561
INSERT INTO t1 (col1) VALUES(8388608);
 
562
--error 1264
 
563
INSERT INTO t1 (col2) VALUES(-1);
 
564
--error 1264
 
565
INSERT INTO t1 (col2) VALUES(16777216);
 
566
--error 1264
 
567
INSERT INTO t1 (col1) VALUES('-8388609');
 
568
--error 1264
 
569
INSERT INTO t1 (col1) VALUES('8388608');
 
570
--error 1264
 
571
INSERT INTO t1 (col2) VALUES('-1');
 
572
--error 1264
 
573
INSERT INTO t1 (col2) VALUES('16777216');
 
574
--error 1264
 
575
INSERT INTO t1 (col1) VALUES(-8388609.0);
 
576
--error 1264
 
577
INSERT INTO t1 (col1) VALUES(8388608.0);
 
578
--error 1264
 
579
INSERT INTO t1 (col2) VALUES(-1.0);
 
580
--error 1264
 
581
INSERT INTO t1 (col2) VALUES(16777216.0);
 
582
 
 
583
--error 1264
 
584
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
 
585
--error 1264
 
586
UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
 
587
--error 1365
 
588
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
 
589
--error 1365
 
590
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
 
591
--error 1366
 
592
INSERT INTO t1 (col1) VALUES ('');
 
593
--error 1366
 
594
INSERT INTO t1 (col1) VALUES ('a59b');
 
595
--error 1265
 
596
INSERT INTO t1 (col1) VALUES ('1a');
 
597
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
 
598
INSERT IGNORE INTO t1 values (1/0,1/0);
 
599
INSERT IGNORE INTO t1 VALUES(-8388609,-1),(8388608,16777216);
 
600
INSERT IGNORE INTO t1 VALUES('-8388609','-1'),('8388608','16777216');
 
601
INSERT IGNORE INTO t1 VALUES(-8388609.0,-1.0),(8388608.0,16777216.0);
 
602
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
 
603
 
 
604
SELECT * FROM t1;
 
605
DROP TABLE t1;
 
606
 
 
607
# Test INSERT with INT
 
608
 
 
609
CREATE TABLE t1 (col1 INT, col2 INT UNSIGNED);
 
610
INSERT INTO t1 VALUES(-2147483648,0),(0,0),(2147483647,4294967295),('-2147483648','0'),('2147483647','4294967295'),(-2147483648.0,0.0),(2147483647.0,4294967295.0);
 
611
--error 1264
19
612
INSERT INTO t1 (col1) VALUES(-2147483649);
20
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
613
--error 1264
21
614
INSERT INTO t1 (col1) VALUES(2147643648);
22
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
615
--error 1264
 
616
INSERT INTO t1 (col2) VALUES(-1);
 
617
--error 1264
 
618
INSERT INTO t1 (col2) VALUES(4294967296);
 
619
--error 1264
23
620
INSERT INTO t1 (col1) VALUES('-2147483649');
24
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
621
--error 1264
25
622
INSERT INTO t1 (col1) VALUES('2147643648');
26
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
623
--error 1264
 
624
INSERT INTO t1 (col2) VALUES('-1');
 
625
--error 1264
 
626
INSERT INTO t1 (col2) VALUES('4294967296');
 
627
--error 1264
27
628
INSERT INTO t1 (col1) VALUES(-2147483649.0);
28
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
629
--error 1264
29
630
INSERT INTO t1 (col1) VALUES(2147643648.0);
 
631
--error 1264
 
632
INSERT INTO t1 (col2) VALUES(-1.0);
 
633
--error 1264
 
634
INSERT INTO t1 (col2) VALUES(4294967296.0);
30
635
 
31
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
636
--error 1264
32
637
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
33
 
--error ER_DIVISION_BY_ZERO
 
638
--error 1264
 
639
UPDATE t1 SET col2 =col2 + 50 WHERE col2 > 0;
 
640
--error 1365
34
641
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
35
 
--error ER_DIVISION_BY_ZERO
 
642
--error 1365
36
643
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
37
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
644
--error 1366
38
645
INSERT INTO t1 (col1) VALUES ('');
39
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
646
--error 1366
40
647
INSERT INTO t1 (col1) VALUES ('a59b');
41
 
--error ER_WARN_DATA_TRUNCATED
 
648
--error 1265
42
649
INSERT INTO t1 (col1) VALUES ('1a');
43
650
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
44
 
--error ER_DIVISION_BY_ZERO
45
 
INSERT IGNORE INTO t1 values (1/0);
46
 
INSERT IGNORE INTO t1 values (-2147483649);
47
 
INSERT IGNORE INTO t1 values (2147643648);
48
 
INSERT IGNORE INTO t1 values ('-2147483649');
49
 
INSERT IGNORE INTO t1 values ('2147643648');
50
 
INSERT IGNORE INTO t1 values (-2147483649.0);
51
 
INSERT IGNORE INTO t1 values (2147643648.0);
 
651
INSERT IGNORE INTO t1 values (1/0,1/0);
 
652
INSERT IGNORE INTO t1 values (-2147483649, -1),(2147643648,4294967296);
 
653
INSERT IGNORE INTO t1 values ('-2147483649', '-1'),('2147643648','4294967296');
 
654
INSERT IGNORE INTO t1 values (-2147483649.0, -1.0),(2147643648.0,4294967296.0);
 
655
UPDATE IGNORE t1 SET col2=1/NULL where col1=0;
52
656
SELECT * FROM t1;
53
657
DROP TABLE t1;
54
658
 
56
660
# Note that this doesn't behave 100 % to standard as we rotate
57
661
# integers when it's too big/small (just like C)
58
662
 
59
 
CREATE TABLE t1 (col1 BIGINT);
60
 
INSERT INTO t1 VALUES (-9223372036854775808);
61
 
INSERT INTO t1 VALUES (0);
62
 
INSERT INTO t1 VALUES (9223372036854775807);
63
 
INSERT INTO t1 VALUES ('-9223372036854775808');
64
 
INSERT INTO t1 VALUES ('9223372036854775807');
65
 
INSERT INTO t1 VALUES (-9223372036854774000.0);
66
 
INSERT INTO t1 VALUES (9223372036854775700.0);
 
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);
67
667
 
68
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
668
--error 1264
69
669
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
70
 
# https://bugs.launchpad.net/drizzle/+bug/316221
71
 
 --error ER_WARN_DATA_OUT_OF_RANGE
 
670
--error 1264
72
671
INSERT INTO t1 (col1) VALUES(9223372036854775808);
 
672
--error 1264
 
673
INSERT INTO t1 (col2) VALUES(-1);
73
674
 
74
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
675
--error 1264
 
676
INSERT INTO t1 (col2) VALUES(18446744073709551616);
 
677
--error 1264
75
678
INSERT INTO t1 (col1) VALUES('-9223372036854775809');
76
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
679
--error 1264
77
680
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');
78
685
 
79
686
# Note that the following two double numbers are slighty bigger than max/min
80
687
# bigint becasue of rounding errors when converting it to bigint
81
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
688
--error 1264
82
689
INSERT INTO t1 (col1) VALUES(-9223372036854785809.0);
83
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
690
--error 1264
84
691
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);
85
696
 
86
697
# The following doesn't give an error as it's done in integer context
87
698
# UPDATE t1 SET col1=col1 - 5000 WHERE col1 < 0;
88
699
# UPDATE t1 SET col2 =col2 + 5000 WHERE col2 > 0;
89
700
 
90
 
--error ER_DIVISION_BY_ZERO
 
701
--error 1365
91
702
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
92
 
--error ER_DIVISION_BY_ZERO
 
703
--error 1365
93
704
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
94
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
705
--error 1366
95
706
INSERT INTO t1 (col1) VALUES ('');
96
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
707
--error 1366
97
708
INSERT INTO t1 (col1) VALUES ('a59b');
98
 
--error ER_WARN_DATA_TRUNCATED
 
709
--error 1265
99
710
INSERT INTO t1 (col1) VALUES ('1a');
100
711
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
101
 
--error ER_DIVISION_BY_ZERO
102
 
INSERT IGNORE INTO t1 values (1/0);
103
 
INSERT IGNORE INTO t1 VALUES (-9223372036854775809);
104
 
INSERT IGNORE INTO t1 VALUES (9223372036854775808);
105
 
INSERT IGNORE INTO t1 VALUES ('-9223372036854775809');
106
 
INSERT IGNORE INTO t1 VALUES ('9223372036854775808');
107
 
INSERT IGNORE INTO t1 VALUES (-9223372036854785809.0);
108
 
INSERT IGNORE INTO t1 VALUES (9223372036854785808.0);
 
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;
109
717
SELECT * FROM t1;
110
718
DROP TABLE t1;
111
719
 
112
720
# Test INSERT with NUMERIC
113
721
 
114
722
CREATE TABLE t1 (col1 NUMERIC(4,2));
115
 
# The following INSERT statements used to look as follows before 
116
 
# the fix for bug#337038 was implemented:
117
 
# INSERT INTO t1 
118
 
# VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01);
119
 
# Now that decimal truncation gives an error instead of a warning, we will
120
 
# get an error on certain INSERT statements below about decimal truncation.
121
 
 
122
 
INSERT INTO t1 VALUES (10.55);
123
 
# this statement errors due to decimal truncation. The number
124
 
# used in insertion is chosen to test that this this error does
125
 
# in fact occur
126
 
--error ER_WARN_DATA_TRUNCATED 
127
 
INSERT INTO t1 VALUES (10.5555);
128
 
INSERT INTO t1 VALUES (0);
129
 
INSERT INTO t1 VALUES (-10.55);
130
 
# this statement errors due to decimal truncation. The number
131
 
# used in insertion is chosen to test that this this error does
132
 
# in fact occur
133
 
--error ER_WARN_DATA_TRUNCATED
134
 
INSERT INTO t1 VALUES (-10.5555);
135
 
INSERT INTO t1 VALUES (11);
136
 
INSERT INTO t1 VALUES (1e+01);
137
 
 
138
 
# The following INSERT statements used to look as follows before 
139
 
# the fix for bug#337038 was implemented:
140
 
# INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');
141
 
# Now that decimal truncation gives an error instead of a warning, we will
142
 
# get an error on certain INSERT statements below about decimal truncation.
143
 
 
144
 
INSERT INTO t1 VALUES ('10.55');
145
 
# this statement errors due to decimal truncation. The number
146
 
# used in insertion is chosen to test that this this error does
147
 
# in fact occur
148
 
--error ER_WARN_DATA_TRUNCATED 
149
 
INSERT INTO t1 VALUES ('10.5555');
150
 
INSERT INTO t1 VALUES ('-10.55');
151
 
# this statement errors due to decimal truncation. The number 
152
 
# used in insertion is chosen to test that this error does 
153
 
# in fact occur
154
 
--error ER_WARN_DATA_TRUNCATED 
155
 
INSERT INTO t1 VALUES ('-10.5555');
156
 
INSERT INTO t1 VALUES ('11');
157
 
INSERT INTO t1 VALUES ('1e+01');
 
723
INSERT INTO t1 VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01);
 
724
# Note that the +/-10.5555 is inserted as +/-10.55, not +/-10.56 !
 
725
INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');
158
726
 
159
727
# The 2 following inserts should generate a warning, but doesn't yet
160
728
# because NUMERIC works like DECIMAL
161
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
729
--error 1264
162
730
INSERT INTO t1 VALUES (101.55);
163
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
731
--error 1264
164
732
INSERT INTO t1 VALUES (101);
165
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
733
--error 1264
166
734
INSERT INTO t1 VALUES (-101.55);
167
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
735
--error 1264
168
736
INSERT INTO t1 VALUES (1010.55);
169
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
737
--error 1264
170
738
INSERT INTO t1 VALUES (1010);
171
739
# The 2 following inserts should generate a warning, but doesn't yet
172
740
# because NUMERIC works like DECIMAL
173
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
741
--error 1264
174
742
INSERT INTO t1 VALUES ('101.55');
175
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
743
--error 1264
176
744
INSERT INTO t1 VALUES ('101');
177
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
745
--error 1264
178
746
INSERT INTO t1 VALUES ('-101.55');
179
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
747
--error 1264
180
748
INSERT INTO t1 VALUES ('-1010.55');
181
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
749
--error 1264
182
750
INSERT INTO t1 VALUES ('-100E+1');
183
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
751
--error 1366
184
752
INSERT INTO t1 VALUES ('-100E');
185
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
753
--error 1264
186
754
UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;
187
 
--error ER_DIVISION_BY_ZERO
 
755
--error 1365
188
756
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
189
 
--error ER_DIVISION_BY_ZERO
 
757
--error 1365
190
758
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
191
 
#--error ER_WARN_DATA_TRUNCATED
192
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
759
#--error 1265
 
760
--error 1366
193
761
INSERT INTO t1 (col1) VALUES ('');
194
 
#--error ER_WARN_DATA_TRUNCATED
195
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
762
#--error 1265
 
763
--error 1366
196
764
INSERT INTO t1 (col1) VALUES ('a59b');
197
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
765
--error 1366
198
766
INSERT INTO t1 (col1) VALUES ('1a');
199
767
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
200
 
--error ER_DIVISION_BY_ZERO
201
768
INSERT IGNORE INTO t1 values (1/0);
202
 
INSERT IGNORE INTO t1 VALUES (1000);
203
 
INSERT IGNORE INTO t1 VALUES (-1000);
204
 
INSERT IGNORE INTO t1 VALUES ('1000');
205
 
INSERT IGNORE INTO t1 VALUES ('-1000');
206
 
INSERT IGNORE INTO t1 VALUES (1000.0);
207
 
INSERT IGNORE INTO t1 VALUES (-1000.0);
 
769
INSERT IGNORE INTO t1 VALUES(1000),(-1000);
 
770
INSERT IGNORE INTO t1 VALUES('1000'),('-1000');
 
771
INSERT IGNORE INTO t1 VALUES(1000.0),(-1000.0);
208
772
UPDATE IGNORE t1 SET col1=1/NULL where col1=0;
209
 
--sorted_result
 
773
SELECT * FROM t1;
 
774
DROP TABLE t1;
 
775
 
 
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
210
843
SELECT * FROM t1;
211
844
DROP TABLE t1;
212
845
 
213
846
# Testing INSERT with CHAR/VARCHAR
214
847
 
215
848
CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6));
216
 
INSERT INTO t1 VALUES ('hello', 'hello');
217
 
INSERT INTO t1 VALUES ('he', 'he');
218
 
--error ER_DATA_TOO_LONG
219
 
INSERT INTO t1 VALUES ('hello   ', 'hello ');
220
 
--error ER_DATA_TOO_LONG
 
849
INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello   ', 'hello ');
 
850
--error 1406
221
851
INSERT INTO t1 (col1) VALUES ('hellobob');
222
 
--error ER_DATA_TOO_LONG
 
852
--error 1406
223
853
INSERT INTO t1 (col2) VALUES ('hellobob');
224
 
--error ER_DATA_TOO_LONG
225
854
INSERT INTO t1 (col2) VALUES ('hello  ');
226
 
--error ER_DATA_TOO_LONG
 
855
--error 1406
227
856
UPDATE t1 SET col1 ='hellobob' WHERE col1 ='he';
228
 
--error ER_DATA_TOO_LONG
 
857
--error 1406
229
858
UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he';
230
859
INSERT IGNORE INTO t1 VALUES ('hellobob', 'hellobob');
231
860
UPDATE IGNORE t1 SET col2 ='hellotrudy' WHERE col2 ='he';
232
 
--sorted_result
233
861
SELECT * FROM t1;
234
862
DROP TABLE t1;
235
863
 
236
864
# Testing INSERT with ENUM
237
865
 
238
866
CREATE TABLE t1 (col1 enum('red','blue','green'));
239
 
INSERT INTO t1 VALUES ('red');
240
 
INSERT INTO t1 VALUES ('blue');
241
 
INSERT INTO t1 VALUES ('green');
242
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
867
INSERT INTO t1 VALUES ('red'),('blue'),('green');
 
868
--error 1265
243
869
INSERT INTO t1 (col1) VALUES ('yellow');
244
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
870
--error 1265
245
871
INSERT INTO t1 (col1) VALUES ('redd');
246
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
872
--error 1265
247
873
INSERT INTO t1 VALUES ('');
248
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
874
--error 1265
249
875
UPDATE t1 SET col1 ='yellow' WHERE col1 ='green';
250
 
--error ER_INVALID_ENUM_VALUE # Bad enum
251
876
INSERT IGNORE INTO t1 VALUES ('yellow');
252
 
--error ER_INVALID_ENUM_VALUE # Bad enum
253
877
UPDATE IGNORE t1 SET col1 ='yellow' WHERE col1 ='blue';
254
878
SELECT * FROM t1;
255
879
DROP TABLE t1;
259
883
CREATE TABLE t1 (col1 INT NOT NULL, col2 CHAR(5) NOT NULL, col3 DATE NOT NULL);
260
884
INSERT INTO t1 VALUES (100, 'hello', '2004-08-20');
261
885
INSERT INTO t1 (col1,col2,col3) VALUES (101, 'hell2', '2004-08-21');
262
 
--error ER_BAD_NULL_ERROR
 
886
--error 1048
263
887
INSERT INTO t1 (col1,col2,col3) VALUES (NULL, '', '2004-01-01');
264
 
--error ER_BAD_NULL_ERROR
 
888
--error 1048
265
889
INSERT INTO t1 (col1,col2,col3) VALUES (102, NULL, '2004-01-01');
266
 
--error ER_BAD_NULL_ERROR
 
890
--error 1048
267
891
INSERT INTO t1 VALUES (103,'',NULL);
268
 
--error ER_BAD_NULL_ERROR
 
892
--error 1048
269
893
UPDATE t1 SET col1=NULL WHERE col1 =100;
270
 
--error ER_BAD_NULL_ERROR
 
894
--error 1048
271
895
UPDATE t1 SET col2 =NULL WHERE col2 ='hello';
272
 
--error ER_BAD_NULL_ERROR
 
896
--error 1048
273
897
UPDATE t1 SET col2 =NULL where col3 IS NOT NULL;
274
898
INSERT IGNORE INTO t1 values (NULL,NULL,NULL);
275
899
SELECT * FROM t1;
278
902
# Testing of default values
279
903
 
280
904
CREATE TABLE t1 (col1 INT NOT NULL default 99, col2 CHAR(6) NOT NULL);
281
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
282
905
SHOW CREATE TABLE t1;
283
906
INSERT INTO t1 VALUES (1, 'hello');
284
907
INSERT INTO t1 (col2) VALUES ('hello2');
285
 
--error ER_BAD_NULL_ERROR
 
908
--error 1048
286
909
INSERT INTO t1 (col2) VALUES (NULL);
287
 
--error ER_NO_DEFAULT_FOR_FIELD
 
910
--error 1364
288
911
INSERT INTO t1 (col1) VALUES (2);
289
 
--error ER_NO_DEFAULT_FOR_FIELD
 
912
--error 1364
290
913
INSERT INTO t1 VALUES(default(col1),default(col2));
291
 
--error ER_NO_DEFAULT_FOR_FIELD
 
914
--error 1364
292
915
INSERT INTO t1 (col1) SELECT 1;
293
 
--error ER_BAD_NULL_ERROR
 
916
--error 1048
294
917
INSERT INTO t1 SELECT 1,NULL;
295
918
INSERT IGNORE INTO t1 values (NULL,NULL);
296
 
--error ER_NO_DEFAULT_FOR_FIELD
297
919
INSERT IGNORE INTO t1 (col1) values (3);
298
 
--error ER_NO_DEFAULT_FOR_FIELD
299
920
INSERT IGNORE INTO t1 () values ();
300
921
SELECT * FROM t1;
301
922
DROP TABLE t1;
304
925
# Bug #9029 Traditional: Wrong SQLSTATE returned for string truncation
305
926
#
306
927
 
 
928
set sql_mode='traditional';
307
929
create table t1 (charcol char(255), varcharcol varchar(255),
308
 
       varbinarycol varbinary(255));
309
 
--error ER_DATA_TOO_LONG
 
930
binarycol binary(255), varbinarycol varbinary(255), tinytextcol tinytext,
 
931
tinyblobcol tinyblob);
 
932
--error 1406
310
933
insert into t1 (charcol) values (repeat('x',256));
311
 
--error ER_DATA_TOO_LONG
 
934
--error 1406
312
935
insert into t1 (varcharcol) values (repeat('x',256));
313
 
--error ER_DATA_TOO_LONG
 
936
--error 1406
 
937
insert into t1 (binarycol) values (repeat('x',256));
 
938
--error 1406
314
939
insert into t1 (varbinarycol) values (repeat('x',256));
315
 
select * from t1;
 
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
 
316
979
drop table t1;
317
980
 
318
981
#
320
983
#
321
984
 
322
985
create table t1 (col1 char(3), col2 integer);
323
 
--error ER_TRUNCATED_WRONG_VALUE
 
986
--error 1292
324
987
insert into t1 (col1) values (cast(1000 as char(3)));
325
 
--error ER_TRUNCATED_WRONG_VALUE
 
988
--error 1292
326
989
insert into t1 (col1) values (cast(1000E+0 as char(3)));
327
 
--error ER_TRUNCATED_WRONG_VALUE
 
990
--error 1292
328
991
insert into t1 (col1) values (cast(1000.0 as char(3)));
329
 
--error ER_TRUNCATED_WRONG_VALUE
330
 
insert into t1 (col2) values (cast('abc' as DECIMAL));
331
 
--error ER_TRUNCATED_WRONG_VALUE
 
992
--error 1292
 
993
insert into t1 (col2) values (cast('abc' as signed integer));
 
994
--error 1292
332
995
insert into t1 (col2) values (10E+0 + 'a');
333
 
--error ER_WARN_DATA_TRUNCATED
334
 
insert into t1 (col2) values ('10a');
335
 
insert into t1 (col2) values (cast('10a' as DECIMAL));
336
 
insert into t1 (col2) values (cast('10' as DECIMAL));
337
 
insert into t1 (col2) values (cast('10' as DECIMAL));
 
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));
338
1000
insert into t1 (col2) values (10E+0 + '0 ');
339
1001
select * from t1;
340
1002
drop table t1;
341
1003
 
 
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
 
342
1058
# Test fields with no default value that are NOT NULL (Bug #5986)
 
1059
SET @@sql_mode = 'traditional';
343
1060
CREATE TABLE t1 (i int not null);
344
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1061
--error 1364
345
1062
INSERT INTO t1 VALUES ();
346
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1063
--error 1364
347
1064
INSERT INTO t1 VALUES (DEFAULT);
348
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1065
--error 1364
349
1066
INSERT INTO t1 VALUES (DEFAULT(i));
350
1067
ALTER TABLE t1 ADD j int;
351
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1068
--error 1364
352
1069
INSERT INTO t1 SET j = 1;
353
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1070
--error 1364
354
1071
INSERT INTO t1 SET j = 1, i = DEFAULT;
355
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1072
--error 1364
356
1073
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
357
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1074
--error 1364
358
1075
INSERT INTO t1 VALUES (DEFAULT,1);
359
1076
DROP TABLE t1;
 
1077
SET @@sql_mode = '';
360
1078
CREATE TABLE t1 (i int not null);
361
 
--error ER_NO_DEFAULT_FOR_FIELD
362
1079
INSERT INTO t1 VALUES ();
363
 
--error ER_NO_DEFAULT_FOR_FIELD
364
1080
INSERT INTO t1 VALUES (DEFAULT);
365
1081
# DEFAULT(i) is an error even with the default sql_mode
366
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1082
--error 1364
367
1083
INSERT INTO t1 VALUES (DEFAULT(i));
368
1084
ALTER TABLE t1 ADD j int;
369
 
--error ER_NO_DEFAULT_FOR_FIELD
370
1085
INSERT INTO t1 SET j = 1;
371
 
--error ER_NO_DEFAULT_FOR_FIELD
372
1086
INSERT INTO t1 SET j = 1, i = DEFAULT;
373
 
--error ER_NO_DEFAULT_FOR_FIELD
 
1087
--error 1364
374
1088
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
375
 
--error ER_NO_DEFAULT_FOR_FIELD
376
1089
INSERT INTO t1 VALUES (DEFAULT,1);
377
1090
DROP TABLE t1;
378
1091
 
380
1093
# Bugs #8295 and #8296: varchar and varbinary conversion
381
1094
#
382
1095
 
383
 
--error ER_TOO_BIG_FIELDLENGTH
 
1096
set @@sql_mode='traditional';
 
1097
--error 1074
384
1098
create table t1(a varchar(65537));
385
 
--error ER_TOO_BIG_FIELDLENGTH
 
1099
--error 1074
386
1100
create table t1(a varbinary(65537));
387
1101
 
388
1102
#
389
1103
# Bug #9881: problem with altering table
390
1104
#
391
1105
 
 
1106
set @@sql_mode='traditional';
392
1107
create table t1(a int, b date not null);                                       
393
1108
alter table t1 modify a bigint not null;
394
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
395
1109
show create table t1;
396
1110
drop table t1;
397
1111
 
398
1112
#
 
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
#
399
1128
# Bug #11964: alter table with timestamp field
400
1129
#
401
1130
 
 
1131
set @@sql_mode='traditional';
402
1132
create table t1(a int, b timestamp);
403
1133
alter table t1 add primary key(a);
404
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
405
1134
show create table t1;
406
1135
drop table t1;
407
1136
create table t1(a int, b timestamp default 20050102030405);
408
1137
alter table t1 add primary key(a);
409
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
410
1138
show create table t1;
411
1139
drop table t1;
412
1140
 
 
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;
413
1151
 
414
1152
#
415
1153
# Bug#17626 CREATE TABLE ... SELECT failure with TRADITIONAL SQL mode
416
1154
#
 
1155
set sql_mode='traditional';
417
1156
create table t1 (date date not null);
418
1157
create table t2 select date from t1;
419
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
420
1158
show create table t2;
421
1159
drop table t2,t1;
 
1160
set @@sql_mode= @org_mode;
422
1161
 
 
1162
set names utf8;
423
1163
create table t1 (i int)
424
 
comment='123456789*123456789*123456789*123456789*123456789*123456789*';
425
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
1164
comment '123456789*123456789*123456789*123456789*123456789*123456789*';
426
1165
show create table t1;
427
1166
drop table t1;
428
1167
 
429
1168
#
430
1169
# Bug #26359: Strings becoming truncated and converted to numbers under STRICT mode
431
1170
#
432
 
 
 
1171
set sql_mode= 'traditional';
433
1172
create table t1(col1 int, col2 int, 
434
1173
  col3 int, col4 int,
 
1174
  col5 mediumint, col6 mediumint,
435
1175
  col7 int, col8 int,
436
1176
  col9 bigint, col10 bigint);
437
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1177
--error 1366
438
1178
insert into t1(col1) values('-');
439
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1179
--error 1366
440
1180
insert into t1(col2) values('+');
441
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1181
--error 1366
442
1182
insert into t1(col3) values('-');
443
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1183
--error 1366
444
1184
insert into t1(col4) values('+');
445
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1185
--error 1366
 
1186
insert into t1(col5) values('-');
 
1187
--error 1366
 
1188
insert into t1(col6) values('+');
 
1189
--error 1366
446
1190
insert into t1(col7) values('-');
447
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1191
--error 1366
448
1192
insert into t1(col8) values('+');
449
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1193
--error 1366
450
1194
insert into t1(col9) values('-');
451
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
1195
--error 1366
452
1196
insert into t1(col10) values('+');
453
1197
drop table t1;
454
1198
 
 
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;
455
1215
 
456
1216
#
457
1217
# Bug#27069 set with identical elements are created
458
1218
#
459
 
--error ER_DUPLICATED_VALUE_IN_TYPE
 
1219
set sql_mode='traditional';
 
1220
--error 1291
 
1221
create table t1 (f1 set('a','a'));
 
1222
--error 1291
460
1223
create table t1 (f1 enum('a','a'));
461
1224
 
 
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
 
462
1233
--echo End of 5.0 tests