38
38
INSERT INTO t1 (col1) VALUES ('');
39
39
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
40
40
INSERT INTO t1 (col1) VALUES ('a59b');
41
--error ER_WARN_DATA_TRUNCATED
42
42
INSERT INTO t1 (col1) VALUES ('1a');
43
43
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
44
--error ER_DIVISION_BY_ZERO
45
44
INSERT IGNORE INTO t1 values (1/0);
46
45
INSERT IGNORE INTO t1 values (-2147483649);
47
46
INSERT IGNORE INTO t1 values (2147643648);
68
67
--error ER_WARN_DATA_OUT_OF_RANGE
69
68
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
70
# https://bugs.launchpad.net/drizzle/+bug/316221
71
--error ER_WARN_DATA_OUT_OF_RANGE
72
INSERT INTO t1 (col1) VALUES(9223372036854775808);
69
# DISABLED due to https://bugs.launchpad.net/drizzle/+bug/316221
70
# --error ER_WARN_DATA_OUT_OF_RANGE
71
# INSERT INTO t1 (col1) VALUES(9223372036854775808);
74
73
--error ER_WARN_DATA_OUT_OF_RANGE
75
74
INSERT INTO t1 (col1) VALUES('-9223372036854775809');
95
94
INSERT INTO t1 (col1) VALUES ('');
96
95
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
97
96
INSERT INTO t1 (col1) VALUES ('a59b');
98
--error ER_WARN_DATA_TRUNCATED
99
98
INSERT INTO t1 (col1) VALUES ('1a');
100
99
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
101
--error ER_DIVISION_BY_ZERO
102
100
INSERT IGNORE INTO t1 values (1/0);
103
101
INSERT IGNORE INTO t1 VALUES (-9223372036854775809);
104
102
INSERT IGNORE INTO t1 VALUES (9223372036854775808);
123
121
# this statement errors due to decimal truncation. The number
124
122
# used in insertion is chosen to test that this this error does
126
--error ER_WARN_DATA_TRUNCATED
127
125
INSERT INTO t1 VALUES (10.5555);
128
126
INSERT INTO t1 VALUES (0);
129
127
INSERT INTO t1 VALUES (-10.55);
130
128
# this statement errors due to decimal truncation. The number
131
129
# used in insertion is chosen to test that this this error does
133
--error ER_WARN_DATA_TRUNCATED
134
132
INSERT INTO t1 VALUES (-10.5555);
135
133
INSERT INTO t1 VALUES (11);
136
134
INSERT INTO t1 VALUES (1e+01);
145
143
# this statement errors due to decimal truncation. The number
146
144
# used in insertion is chosen to test that this this error does
148
--error ER_WARN_DATA_TRUNCATED
149
147
INSERT INTO t1 VALUES ('10.5555');
150
148
INSERT INTO t1 VALUES ('-10.55');
151
149
# this statement errors due to decimal truncation. The number
152
150
# used in insertion is chosen to test that this error does
154
--error ER_WARN_DATA_TRUNCATED
155
153
INSERT INTO t1 VALUES ('-10.5555');
156
154
INSERT INTO t1 VALUES ('11');
157
155
INSERT INTO t1 VALUES ('1e+01');
188
186
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
189
187
--error ER_DIVISION_BY_ZERO
190
188
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
191
#--error ER_WARN_DATA_TRUNCATED
192
190
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
193
191
INSERT INTO t1 (col1) VALUES ('');
194
#--error ER_WARN_DATA_TRUNCATED
195
193
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
196
194
INSERT INTO t1 (col1) VALUES ('a59b');
197
195
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
198
196
INSERT INTO t1 (col1) VALUES ('1a');
199
197
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
200
--error ER_DIVISION_BY_ZERO
201
198
INSERT IGNORE INTO t1 values (1/0);
202
199
INSERT IGNORE INTO t1 VALUES (1000);
203
200
INSERT IGNORE INTO t1 VALUES (-1000);
215
212
CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6));
216
213
INSERT INTO t1 VALUES ('hello', 'hello');
217
214
INSERT INTO t1 VALUES ('he', 'he');
218
--error ER_DATA_TOO_LONG
219
215
INSERT INTO t1 VALUES ('hello ', 'hello ');
220
--error ER_DATA_TOO_LONG
221
217
INSERT INTO t1 (col1) VALUES ('hellobob');
222
--error ER_DATA_TOO_LONG
223
219
INSERT INTO t1 (col2) VALUES ('hellobob');
224
--error ER_DATA_TOO_LONG
225
220
INSERT INTO t1 (col2) VALUES ('hello ');
226
--error ER_DATA_TOO_LONG
227
222
UPDATE t1 SET col1 ='hellobob' WHERE col1 ='he';
228
--error ER_DATA_TOO_LONG
229
224
UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he';
230
225
INSERT IGNORE INTO t1 VALUES ('hellobob', 'hellobob');
231
226
UPDATE IGNORE t1 SET col2 ='hellotrudy' WHERE col2 ='he';
239
234
INSERT INTO t1 VALUES ('red');
240
235
INSERT INTO t1 VALUES ('blue');
241
236
INSERT INTO t1 VALUES ('green');
242
--error ER_INVALID_ENUM_VALUE # Bad enum
237
--error 1691 # Bad enum
243
238
INSERT INTO t1 (col1) VALUES ('yellow');
244
--error ER_INVALID_ENUM_VALUE # Bad enum
239
--error 1691 # Bad enum
245
240
INSERT INTO t1 (col1) VALUES ('redd');
246
--error ER_INVALID_ENUM_VALUE # Bad enum
241
--error 1691 # Bad enum
247
242
INSERT INTO t1 VALUES ('');
248
--error ER_INVALID_ENUM_VALUE # Bad enum
243
--error 1691 # Bad enum
249
244
UPDATE t1 SET col1 ='yellow' WHERE col1 ='green';
250
--error ER_INVALID_ENUM_VALUE # Bad enum
245
--error 1691 # Bad enum
251
246
INSERT IGNORE INTO t1 VALUES ('yellow');
252
--error ER_INVALID_ENUM_VALUE # Bad enum
247
--error 1691 # Bad enum
253
248
UPDATE IGNORE t1 SET col1 ='yellow' WHERE col1 ='blue';
254
249
SELECT * FROM t1;
259
254
CREATE TABLE t1 (col1 INT NOT NULL, col2 CHAR(5) NOT NULL, col3 DATE NOT NULL);
260
255
INSERT INTO t1 VALUES (100, 'hello', '2004-08-20');
261
256
INSERT INTO t1 (col1,col2,col3) VALUES (101, 'hell2', '2004-08-21');
262
--error ER_BAD_NULL_ERROR
263
258
INSERT INTO t1 (col1,col2,col3) VALUES (NULL, '', '2004-01-01');
264
--error ER_BAD_NULL_ERROR
265
260
INSERT INTO t1 (col1,col2,col3) VALUES (102, NULL, '2004-01-01');
266
--error ER_BAD_NULL_ERROR
267
262
INSERT INTO t1 VALUES (103,'',NULL);
268
--error ER_BAD_NULL_ERROR
269
264
UPDATE t1 SET col1=NULL WHERE col1 =100;
270
--error ER_BAD_NULL_ERROR
271
266
UPDATE t1 SET col2 =NULL WHERE col2 ='hello';
272
--error ER_BAD_NULL_ERROR
273
268
UPDATE t1 SET col2 =NULL where col3 IS NOT NULL;
274
269
INSERT IGNORE INTO t1 values (NULL,NULL,NULL);
275
270
SELECT * FROM t1;
282
277
SHOW CREATE TABLE t1;
283
278
INSERT INTO t1 VALUES (1, 'hello');
284
279
INSERT INTO t1 (col2) VALUES ('hello2');
285
--error ER_BAD_NULL_ERROR
286
281
INSERT INTO t1 (col2) VALUES (NULL);
287
--error ER_NO_DEFAULT_FOR_FIELD
288
283
INSERT INTO t1 (col1) VALUES (2);
289
--error ER_NO_DEFAULT_FOR_FIELD
290
285
INSERT INTO t1 VALUES(default(col1),default(col2));
291
--error ER_NO_DEFAULT_FOR_FIELD
292
287
INSERT INTO t1 (col1) SELECT 1;
293
--error ER_BAD_NULL_ERROR
294
289
INSERT INTO t1 SELECT 1,NULL;
295
290
INSERT IGNORE INTO t1 values (NULL,NULL);
296
291
--error ER_NO_DEFAULT_FOR_FIELD
307
302
create table t1 (charcol char(255), varcharcol varchar(255),
308
303
varbinarycol varbinary(255));
309
--error ER_DATA_TOO_LONG
310
305
insert into t1 (charcol) values (repeat('x',256));
311
--error ER_DATA_TOO_LONG
312
307
insert into t1 (varcharcol) values (repeat('x',256));
313
--error ER_DATA_TOO_LONG
314
309
insert into t1 (varbinarycol) values (repeat('x',256));
315
310
select * from t1;
322
317
create table t1 (col1 char(3), col2 integer);
323
--error ER_TRUNCATED_WRONG_VALUE
324
319
insert into t1 (col1) values (cast(1000 as char(3)));
325
--error ER_TRUNCATED_WRONG_VALUE
326
321
insert into t1 (col1) values (cast(1000E+0 as char(3)));
327
--error ER_TRUNCATED_WRONG_VALUE
328
323
insert into t1 (col1) values (cast(1000.0 as char(3)));
329
--error ER_TRUNCATED_WRONG_VALUE
330
325
insert into t1 (col2) values (cast('abc' as DECIMAL));
331
--error ER_TRUNCATED_WRONG_VALUE
332
327
insert into t1 (col2) values (10E+0 + 'a');
333
--error ER_WARN_DATA_TRUNCATED
334
329
insert into t1 (col2) values ('10a');
335
330
insert into t1 (col2) values (cast('10a' as DECIMAL));
336
331
insert into t1 (col2) values (cast('10' as DECIMAL));
342
337
# Test fields with no default value that are NOT NULL (Bug #5986)
343
338
CREATE TABLE t1 (i int not null);
344
--error ER_NO_DEFAULT_FOR_FIELD
345
340
INSERT INTO t1 VALUES ();
346
--error ER_NO_DEFAULT_FOR_FIELD
347
342
INSERT INTO t1 VALUES (DEFAULT);
348
--error ER_NO_DEFAULT_FOR_FIELD
349
344
INSERT INTO t1 VALUES (DEFAULT(i));
350
345
ALTER TABLE t1 ADD j int;
351
--error ER_NO_DEFAULT_FOR_FIELD
352
347
INSERT INTO t1 SET j = 1;
353
--error ER_NO_DEFAULT_FOR_FIELD
354
349
INSERT INTO t1 SET j = 1, i = DEFAULT;
355
--error ER_NO_DEFAULT_FOR_FIELD
356
351
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
357
--error ER_NO_DEFAULT_FOR_FIELD
358
353
INSERT INTO t1 VALUES (DEFAULT,1);
360
355
CREATE TABLE t1 (i int not null);
361
--error ER_NO_DEFAULT_FOR_FIELD
362
357
INSERT INTO t1 VALUES ();
363
--error ER_NO_DEFAULT_FOR_FIELD
364
359
INSERT INTO t1 VALUES (DEFAULT);
365
360
# DEFAULT(i) is an error even with the default sql_mode
366
--error ER_NO_DEFAULT_FOR_FIELD
367
362
INSERT INTO t1 VALUES (DEFAULT(i));
368
363
ALTER TABLE t1 ADD j int;
369
--error ER_NO_DEFAULT_FOR_FIELD
370
365
INSERT INTO t1 SET j = 1;
371
--error ER_NO_DEFAULT_FOR_FIELD
372
367
INSERT INTO t1 SET j = 1, i = DEFAULT;
373
--error ER_NO_DEFAULT_FOR_FIELD
374
369
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
375
--error ER_NO_DEFAULT_FOR_FIELD
376
371
INSERT INTO t1 VALUES (DEFAULT,1);
380
375
# Bugs #8295 and #8296: varchar and varbinary conversion
383
--error ER_TOO_BIG_FIELDLENGTH
384
379
create table t1(a varchar(65537));
385
--error ER_TOO_BIG_FIELDLENGTH
386
381
create table t1(a varbinary(65537));