3
3
-- source include/have_innodb.inc
5
set @org_mode=@@sql_mode;
6
set @@sql_mode='ansi,traditional';
10
DROP TABLE IF EXISTS t1, t2;
13
# Test INSERT with DATE
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');
19
# All test cases expected to fail should return
20
# SQLSTATE 22007 <invalid date value>
22
INSERT INTO t1 VALUES('2004-0-31');
24
INSERT INTO t1 VALUES('2004-01-02'),('2004-0-31');
26
INSERT INTO t1 VALUES('2004-10-0');
28
INSERT INTO t1 VALUES('2004-09-31');
30
INSERT INTO t1 VALUES('2004-10-32');
32
INSERT INTO t1 VALUES('2003-02-29');
34
INSERT INTO t1 VALUES('2004-13-15');
36
INSERT INTO t1 VALUES('0000-00-00');
37
# Standard says we should return SQLSTATE 22018
39
INSERT INTO t1 VALUES ('59');
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';
46
INSERT INTO t1 VALUES('2004-0-30');
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';
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');
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');
66
# Test difference in behaviour with InnoDB and MyISAM tables
68
set @@sql_mode='strict_trans_tables';
69
CREATE TABLE t1 (col1 date) engine=myisam;
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');
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');
82
set @@sql_mode='strict_trans_tables';
83
CREATE TABLE t1 (col1 date) engine=innodb;
85
INSERT INTO t1 VALUES('2004-13-31'),('2004-1-1');
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');
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');
96
set @@sql_mode='ansi,traditional';
98
# Test INSERT with DATETIME
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');
104
# All test cases expected to fail should return
105
# SQLSTATE 22007 <invalid datetime value>
107
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
109
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
111
INSERT INTO t1 VALUES('2004-09-31 15:30:00');
113
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
115
INSERT INTO t1 VALUES('2003-02-29 15:30:00');
117
INSERT INTO t1 VALUES('2004-13-15 15:30:00');
119
INSERT INTO t1 VALUES('0000-00-00 15:30:00');
120
# Standard says we should return SQLSTATE 22018
122
INSERT INTO t1 VALUES ('59');
126
# Test INSERT with TIMESTAMP
128
CREATE TABLE t1 (col1 timestamp);
129
INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
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
135
INSERT INTO t1 VALUES('0000-10-31 15:30:00');
137
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
139
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
141
INSERT INTO t1 VALUES('2004-09-31 15:30:00');
143
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
145
INSERT INTO t1 VALUES('2003-02-29 15:30:00');
147
INSERT INTO t1 VALUES('2004-13-15 15:30:00');
149
INSERT INTO t1 VALUES('2004-02-29 25:30:00');
151
INSERT INTO t1 VALUES('2004-02-29 15:65:00');
153
INSERT INTO t1 VALUES('2004-02-29 15:31:61');
155
INSERT INTO t1 VALUES('0000-00-00 15:30:00');
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
161
INSERT INTO t1 VALUES ('59');
163
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
165
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
167
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
169
INSERT INTO t1 VALUES('2004-10-32 15:30:00');
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';
177
INSERT INTO t1 VALUES('0000-00-00 00:00:00');
178
set @@sql_mode='ansi,traditional';
183
#### Test INSERT with STR_TO_DATE into DATE/DATETIME/TIMESTAMP
185
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
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'));
191
## Test INSERT with STR_TO_DATE into DATE
192
# All test cases expected to fail should return
193
# SQLSTATE 22007 <invalid date value>
195
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
198
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
200
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
202
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
204
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
206
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
208
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
210
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
212
## Test INSERT with STR_TO_DATE into DATETIME
213
# All test cases expected to fail should return
214
# SQLSTATE 22007 <invalid datetime value>
216
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
219
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
221
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
223
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
225
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
227
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
229
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
231
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
233
## Test INSERT with STR_TO_DATE into TIMESTAMP
234
# All test cases expected to fail should return
235
# SQLSTATE 22007 <invalid datetime value>
238
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
240
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
242
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
244
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
246
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
248
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
250
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
252
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
257
#### Test INSERT with CAST AS DATE/DATETIME into DATE/DATETIME/TIMESTAMP
259
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
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));
266
## Test INSERT with CAST AS DATE into DATE
267
# All test cases expected to fail should return
268
# SQLSTATE 22007 <invalid date value>
270
INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
273
INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE));
275
INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE));
277
# deactivated because of Bug#8294
278
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
280
# INSERT INTO t1 (col1) VALUES(CAST('2004-9-31' AS DATE));
282
# INSERT INTO t1 (col1) VALUES(CAST('2004-10-32' AS DATE));
284
# INSERT INTO t1 (col1) VALUES(CAST('2003-02-29' AS DATE));
286
# INSERT INTO t1 (col1) VALUES(CAST('2004-13-15' AS DATE));
288
# deactivated because of Bug#6145
289
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
291
INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
293
## Test INSERT with CAST AS DATETIME into DATETIME
294
# All test cases expected to fail should return
295
# SQLSTATE 22007 <invalid datetime value>
297
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
300
INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
302
INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
304
# deactivated because of Bug#8294
305
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
307
#INSERT INTO t1 (col2) VALUES(CAST('2004-9-31 15:30' AS DATETIME));
309
#INSERT INTO t1 (col2) VALUES(CAST('2004-10-32 15:30' AS DATETIME));
311
#INSERT INTO t1 (col2) VALUES(CAST('2003-02-29 15:30' AS DATETIME));
313
#INSERT INTO t1 (col2) VALUES(CAST('2004-13-15 15:30' AS DATETIME));
315
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
317
INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME));
319
## Test INSERT with CAST AS DATETIME into TIMESTAMP
320
# All test cases expected to fail should return
321
# SQLSTATE 22007 <invalid datetime value>
323
INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
325
# We accept this to be a failure
328
INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
330
INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
331
# should return SQLSTATE 22007 <invalid datetime value>
333
# deactivated because of Bug#8294
334
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
336
#INSERT INTO t1 (col3) VALUES(CAST('2004-9-31 15:30' AS DATETIME));
338
#INSERT INTO t1 (col3) VALUES(CAST('2004-10-32 15:30' AS DATETIME));
340
#INSERT INTO t1 (col3) VALUES(CAST('2003-02-29 15:30' AS DATETIME));
342
#INSERT INTO t1 (col3) VALUES(CAST('2004-13-15 15:30' AS DATETIME));
344
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
346
INSERT INTO t1 (col3) VALUES(CAST('0000-00-00' AS DATETIME));
351
#### Test INSERT with CONVERT to DATE/DATETIME into DATE/DATETIME/TIMESTAMP
353
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
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));
360
## Test INSERT with CONVERT to DATE into DATE
361
# All test cases expected to fail should return
362
# SQLSTATE 22007 <invalid date value>
364
INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
367
INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
369
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
371
# deactivated because of Bug#8294
372
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
374
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-9-31' , DATE));
376
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-32' , DATE));
378
#INSERT INTO t1 (col1) VALUES(CONVERT('2003-02-29' , DATE));
380
#INSERT INTO t1 (col1) VALUES(CONVERT('2004-13-15',DATE));
382
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
384
INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
386
## Test INSERT with CONVERT to DATETIME into DATETIME
387
# All test cases expected to fail should return
388
# SQLSTATE 22007 <invalid datetime value>
390
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
393
INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
395
INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
397
# deactivated because of Bug#8294
398
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
400
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-9-31 15:30',DATETIME));
402
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-32 15:30',DATETIME));
404
#INSERT INTO t1 (col2) VALUES(CONVERT('2003-02-29 15:30',DATETIME));
406
#INSERT INTO t1 (col2) VALUES(CONVERT('2004-13-15 15:30',DATETIME));
408
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
410
INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME));
412
## Test INSERT with CONVERT to DATETIME into DATETIME
413
# All test cases expected to fail should return
414
# SQLSTATE 22007 <invalid datetime value>
416
INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
418
# We accept this to be a failure
421
INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
423
INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
425
# deactivated because of Bug#8294
426
# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE
428
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-9-31 15:30',DATETIME));
430
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-32 15:30',DATETIME));
432
#INSERT INTO t1 (col3) VALUES(CONVERT('2003-02-29 15:30',DATETIME));
434
#INSERT INTO t1 (col3) VALUES(CONVERT('2004-13-15 15:30',DATETIME));
436
# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values
438
INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME));
443
# Test INSERT with TINYINT
445
CREATE TABLE t1(col1 TINYINT, col2 TINYINT 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;
462
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
464
UPDATE t1 SET col2=col2 + 50 WHERE col2 > 0;
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
473
INSERT INTO t1 (col1) VALUES ('');
475
INSERT INTO t1 (col1) VALUES ('a59b');
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;
490
# Test INSERT with SMALLINT
492
CREATE TABLE t1(col1 SMALLINT, col2 SMALLINT UNSIGNED);
493
INSERT INTO t1 VALUES(-32768,0),(0,0),(32767,65535),('-32768','0'),('32767','65535'),(-32768.0,0.0),(32767.0,65535.0);
496
INSERT INTO t1 (col1) VALUES(-32769);
498
INSERT INTO t1 (col1) VALUES(32768);
500
INSERT INTO t1 (col2) VALUES(-1);
502
INSERT INTO t1 (col2) VALUES(65536);
504
INSERT INTO t1 (col1) VALUES('-32769');
506
INSERT INTO t1 (col1) VALUES('32768');
508
INSERT INTO t1 (col2) VALUES('-1');
510
INSERT INTO t1 (col2) VALUES('65536');
512
INSERT INTO t1 (col1) VALUES(-32769.0);
514
INSERT INTO t1 (col1) VALUES(32768.0);
516
INSERT INTO t1 (col2) VALUES(-1.0);
518
INSERT INTO t1 (col2) VALUES(65536.0);
520
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
522
UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
524
UPDATE t1 SET col1 = col1 / 0 WHERE col1 > 0;
526
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
528
INSERT INTO t1 (col1) VALUES ('');
530
INSERT INTO t1 (col1) VALUES ('a59b');
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;
543
# Test INSERT with MEDIUMINT
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);
548
INSERT INTO t1 (col1) VALUES(-8388609);
550
INSERT INTO t1 (col1) VALUES(8388608);
552
INSERT INTO t1 (col2) VALUES(-1);
554
INSERT INTO t1 (col2) VALUES(16777216);
556
INSERT INTO t1 (col1) VALUES('-8388609');
558
INSERT INTO t1 (col1) VALUES('8388608');
560
INSERT INTO t1 (col2) VALUES('-1');
562
INSERT INTO t1 (col2) VALUES('16777216');
564
INSERT INTO t1 (col1) VALUES(-8388609.0);
566
INSERT INTO t1 (col1) VALUES(8388608.0);
568
INSERT INTO t1 (col2) VALUES(-1.0);
570
INSERT INTO t1 (col2) VALUES(16777216.0);
573
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
575
UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;
577
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
579
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
581
INSERT INTO t1 (col1) VALUES ('');
583
INSERT INTO t1 (col1) VALUES ('a59b');
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;
596
5
# Test INSERT with INT
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);
7
CREATE TABLE t1 (col1 INT);
8
INSERT INTO t1 VALUES(-2147483648),(0),(2147483647),('-2147483648'),('2147483647'),(-2147483648.0),(2147483647.0);
9
--error ER_WARN_DATA_OUT_OF_RANGE
601
10
INSERT INTO t1 (col1) VALUES(-2147483649);
11
--error ER_WARN_DATA_OUT_OF_RANGE
603
12
INSERT INTO t1 (col1) VALUES(2147643648);
605
INSERT INTO t1 (col2) VALUES(-1);
607
INSERT INTO t1 (col2) VALUES(4294967296);
13
--error ER_WARN_DATA_OUT_OF_RANGE
609
14
INSERT INTO t1 (col1) VALUES('-2147483649');
15
--error ER_WARN_DATA_OUT_OF_RANGE
611
16
INSERT INTO t1 (col1) VALUES('2147643648');
613
INSERT INTO t1 (col2) VALUES('-1');
615
INSERT INTO t1 (col2) VALUES('4294967296');
17
--error ER_WARN_DATA_OUT_OF_RANGE
617
18
INSERT INTO t1 (col1) VALUES(-2147483649.0);
19
--error ER_WARN_DATA_OUT_OF_RANGE
619
20
INSERT INTO t1 (col1) VALUES(2147643648.0);
621
INSERT INTO t1 (col2) VALUES(-1.0);
623
INSERT INTO t1 (col2) VALUES(4294967296.0);
22
--error ER_WARN_DATA_OUT_OF_RANGE
626
23
UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;
628
UPDATE t1 SET col2 =col2 + 50 WHERE col2 > 0;
24
--error ER_DIVISION_BY_ZERO
630
25
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
26
--error ER_DIVISION_BY_ZERO
632
27
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
28
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
634
29
INSERT INTO t1 (col1) VALUES ('');
30
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
636
31
INSERT INTO t1 (col1) VALUES ('a59b');
638
33
INSERT INTO t1 (col1) VALUES ('1a');
639
34
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;
35
INSERT IGNORE INTO t1 values (1/0);
36
INSERT IGNORE INTO t1 values (-2147483649),(2147643648);
37
INSERT IGNORE INTO t1 values ('-2147483649'),('2147643648');
38
INSERT IGNORE INTO t1 values (-2147483649.0),(2147643648.0);