8
8
DROP TABLE IF EXISTS t1;
10
10
CREATE TABLE t1 (col1 INT);
11
INSERT INTO t1 VALUES(-2147483648),(0),(2147483647),('-2147483648'),('2147483647'),(-2147483648.0),(2147483647.0);
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);
12
18
--error ER_WARN_DATA_OUT_OF_RANGE
13
19
INSERT INTO t1 (col1) VALUES(-2147483649);
14
20
--error ER_WARN_DATA_OUT_OF_RANGE
36
42
INSERT INTO t1 (col1) VALUES ('1a');
37
43
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
38
44
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);
45
INSERT IGNORE INTO t1 values (-2147483649);
46
INSERT IGNORE INTO t1 values (2147643648);
47
INSERT IGNORE INTO t1 values ('-2147483649');
48
INSERT IGNORE INTO t1 values ('2147643648');
49
INSERT IGNORE INTO t1 values (-2147483649.0);
50
INSERT IGNORE INTO t1 values (2147643648.0);
47
56
# integers when it's too big/small (just like C)
49
58
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);
59
INSERT INTO t1 VALUES (-9223372036854775808);
60
INSERT INTO t1 VALUES (0);
61
INSERT INTO t1 VALUES (9223372036854775807);
62
INSERT INTO t1 VALUES ('-9223372036854775808');
63
INSERT INTO t1 VALUES ('9223372036854775807');
64
INSERT INTO t1 VALUES (-9223372036854774000.0);
65
INSERT INTO t1 VALUES (9223372036854775700.0);
54
67
--error ER_WARN_DATA_OUT_OF_RANGE
55
68
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
85
98
INSERT INTO t1 (col1) VALUES ('1a');
86
99
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
87
100
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);
101
INSERT IGNORE INTO t1 VALUES (-9223372036854775809);
102
INSERT IGNORE INTO t1 VALUES (9223372036854775808);
103
INSERT IGNORE INTO t1 VALUES ('-9223372036854775809');
104
INSERT IGNORE INTO t1 VALUES ('9223372036854775808');
105
INSERT IGNORE INTO t1 VALUES (-9223372036854785809.0);
106
INSERT IGNORE INTO t1 VALUES (9223372036854785808.0);
94
110
# Test INSERT with NUMERIC
96
112
CREATE TABLE t1 (col1 NUMERIC(4,2));
97
INSERT INTO t1 VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01);
98
# Note that the +/-10.5555 is inserted as +/-10.55, not +/-10.56 !
99
INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');
113
# The following INSERT statements used to look as follows before
114
# the fix for bug#337038 was implemented:
116
# VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01);
117
# Now that decimal truncation gives an error instead of a warning, we will
118
# get an error on certain INSERT statements below about decimal truncation.
120
INSERT INTO t1 VALUES (10.55);
121
# this statement errors due to decimal truncation. The number
122
# used in insertion is chosen to test that this this error does
125
INSERT INTO t1 VALUES (10.5555);
126
INSERT INTO t1 VALUES (0);
127
INSERT INTO t1 VALUES (-10.55);
128
# this statement errors due to decimal truncation. The number
129
# used in insertion is chosen to test that this this error does
132
INSERT INTO t1 VALUES (-10.5555);
133
INSERT INTO t1 VALUES (11);
134
INSERT INTO t1 VALUES (1e+01);
136
# The following INSERT statements used to look as follows before
137
# the fix for bug#337038 was implemented:
138
# INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');
139
# Now that decimal truncation gives an error instead of a warning, we will
140
# get an error on certain INSERT statements below about decimal truncation.
142
INSERT INTO t1 VALUES ('10.55');
143
# this statement errors due to decimal truncation. The number
144
# used in insertion is chosen to test that this this error does
147
INSERT INTO t1 VALUES ('10.5555');
148
INSERT INTO t1 VALUES ('-10.55');
149
# this statement errors due to decimal truncation. The number
150
# used in insertion is chosen to test that this error does
153
INSERT INTO t1 VALUES ('-10.5555');
154
INSERT INTO t1 VALUES ('11');
155
INSERT INTO t1 VALUES ('1e+01');
101
157
# The 2 following inserts should generate a warning, but doesn't yet
102
158
# because NUMERIC works like DECIMAL
140
196
INSERT INTO t1 (col1) VALUES ('1a');
141
197
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
142
198
INSERT IGNORE INTO t1 values (1/0);
143
INSERT IGNORE INTO t1 VALUES(1000),(-1000);
144
INSERT IGNORE INTO t1 VALUES('1000'),('-1000');
145
INSERT IGNORE INTO t1 VALUES(1000.0),(-1000.0);
199
INSERT IGNORE INTO t1 VALUES (1000);
200
INSERT IGNORE INTO t1 VALUES (-1000);
201
INSERT IGNORE INTO t1 VALUES ('1000');
202
INSERT IGNORE INTO t1 VALUES ('-1000');
203
INSERT IGNORE INTO t1 VALUES (1000.0);
204
INSERT IGNORE INTO t1 VALUES (-1000.0);
146
205
UPDATE IGNORE t1 SET col1=1/NULL where col1=0;
148
207
SELECT * FROM t1;
151
210
# Testing INSERT with CHAR/VARCHAR
153
212
CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6));
154
INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello ', 'hello ');
213
INSERT INTO t1 VALUES ('hello', 'hello');
214
INSERT INTO t1 VALUES ('he', 'he');
215
INSERT INTO t1 VALUES ('hello ', 'hello ');
156
217
INSERT INTO t1 (col1) VALUES ('hellobob');