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