~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/strict.test

  • Committer: Monty Taylor
  • Date: 2009-03-16 16:56:48 UTC
  • mto: This revision was merged to the branch mainline in revision 938.
  • Revision ID: mordred@inaugust.com-20090316165648-0dsce73jne0qikk0
Addd -Wshadow to PROTOSKIP warnings and turned -Wstrict-aliasing off. Jumped the gun...

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
DROP TABLE IF EXISTS t1;
9
9
--enable_warnings
10
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);
 
11
INSERT INTO t1 VALUES(-2147483648),(0),(2147483647),('-2147483648'),('2147483647'),(-2147483648.0),(2147483647.0);
18
12
--error ER_WARN_DATA_OUT_OF_RANGE
19
13
INSERT INTO t1 (col1) VALUES(-2147483649);
20
14
--error ER_WARN_DATA_OUT_OF_RANGE
38
32
INSERT INTO t1 (col1) VALUES ('');
39
33
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
40
34
INSERT INTO t1 (col1) VALUES ('a59b');
41
 
--error ER_WARN_DATA_TRUNCATED
 
35
--error 1265
42
36
INSERT INTO t1 (col1) VALUES ('1a');
43
37
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
44
 
--error ER_DIVISION_BY_ZERO
45
38
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);
 
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);
52
42
SELECT * FROM t1;
53
43
DROP TABLE t1;
54
44
 
57
47
# integers when it's too big/small (just like C)
58
48
 
59
49
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);
 
50
INSERT INTO t1 VALUES(-9223372036854775808),(0),(9223372036854775807);
 
51
INSERT INTO t1 VALUES('-9223372036854775808'),('9223372036854775807');
 
52
INSERT INTO t1 VALUES(-9223372036854774000.0),(9223372036854775700.0);
67
53
 
68
54
--error ER_WARN_DATA_OUT_OF_RANGE
69
55
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);
 
56
# DISABLED due to https://bugs.launchpad.net/drizzle/+bug/316221
 
57
# --error ER_WARN_DATA_OUT_OF_RANGE
 
58
# INSERT INTO t1 (col1) VALUES(9223372036854775808);
73
59
 
74
60
--error ER_WARN_DATA_OUT_OF_RANGE
75
61
INSERT INTO t1 (col1) VALUES('-9223372036854775809');
95
81
INSERT INTO t1 (col1) VALUES ('');
96
82
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
97
83
INSERT INTO t1 (col1) VALUES ('a59b');
98
 
--error ER_WARN_DATA_TRUNCATED
 
84
--error 1265
99
85
INSERT INTO t1 (col1) VALUES ('1a');
100
86
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
101
 
--error ER_DIVISION_BY_ZERO
102
87
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);
 
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);
109
91
SELECT * FROM t1;
110
92
DROP TABLE t1;
111
93
 
112
94
# Test INSERT with NUMERIC
113
95
 
114
96
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');
 
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');
158
100
 
159
101
# The 2 following inserts should generate a warning, but doesn't yet
160
102
# because NUMERIC works like DECIMAL
188
130
UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;
189
131
--error ER_DIVISION_BY_ZERO
190
132
UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;
191
 
#--error ER_WARN_DATA_TRUNCATED
 
133
#--error 1265
192
134
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
193
135
INSERT INTO t1 (col1) VALUES ('');
194
 
#--error ER_WARN_DATA_TRUNCATED
 
136
#--error 1265
195
137
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
196
138
INSERT INTO t1 (col1) VALUES ('a59b');
197
139
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
198
140
INSERT INTO t1 (col1) VALUES ('1a');
199
141
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
200
 
--error ER_DIVISION_BY_ZERO
201
142
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);
 
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);
208
146
UPDATE IGNORE t1 SET col1=1/NULL where col1=0;
209
 
--sorted_result
210
147
SELECT * FROM t1;
211
148
DROP TABLE t1;
212
149
 
213
150
# Testing INSERT with CHAR/VARCHAR
214
151
 
215
152
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
 
153
INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello   ', 'hello ');
 
154
--error 1406
221
155
INSERT INTO t1 (col1) VALUES ('hellobob');
222
 
--error ER_DATA_TOO_LONG
 
156
--error 1406
223
157
INSERT INTO t1 (col2) VALUES ('hellobob');
224
 
--error ER_DATA_TOO_LONG
225
158
INSERT INTO t1 (col2) VALUES ('hello  ');
226
 
--error ER_DATA_TOO_LONG
 
159
--error 1406
227
160
UPDATE t1 SET col1 ='hellobob' WHERE col1 ='he';
228
 
--error ER_DATA_TOO_LONG
 
161
--error 1406
229
162
UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he';
230
163
INSERT IGNORE INTO t1 VALUES ('hellobob', 'hellobob');
231
164
UPDATE IGNORE t1 SET col2 ='hellotrudy' WHERE col2 ='he';
232
 
--sorted_result
233
165
SELECT * FROM t1;
234
166
DROP TABLE t1;
235
167
 
236
168
# Testing INSERT with ENUM
237
169
 
238
170
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
 
171
INSERT INTO t1 VALUES ('red'),('blue'),('green');
 
172
--error 1265
243
173
INSERT INTO t1 (col1) VALUES ('yellow');
244
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
174
--error 1265
245
175
INSERT INTO t1 (col1) VALUES ('redd');
246
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
176
--error 1265
247
177
INSERT INTO t1 VALUES ('');
248
 
--error ER_INVALID_ENUM_VALUE # Bad enum
 
178
--error 1265
249
179
UPDATE t1 SET col1 ='yellow' WHERE col1 ='green';
250
 
--error ER_INVALID_ENUM_VALUE # Bad enum
251
180
INSERT IGNORE INTO t1 VALUES ('yellow');
252
 
--error ER_INVALID_ENUM_VALUE # Bad enum
253
181
UPDATE IGNORE t1 SET col1 ='yellow' WHERE col1 ='blue';
254
182
SELECT * FROM t1;
255
183
DROP TABLE t1;
259
187
CREATE TABLE t1 (col1 INT NOT NULL, col2 CHAR(5) NOT NULL, col3 DATE NOT NULL);
260
188
INSERT INTO t1 VALUES (100, 'hello', '2004-08-20');
261
189
INSERT INTO t1 (col1,col2,col3) VALUES (101, 'hell2', '2004-08-21');
262
 
--error ER_BAD_NULL_ERROR
 
190
--error 1048
263
191
INSERT INTO t1 (col1,col2,col3) VALUES (NULL, '', '2004-01-01');
264
 
--error ER_BAD_NULL_ERROR
 
192
--error 1048
265
193
INSERT INTO t1 (col1,col2,col3) VALUES (102, NULL, '2004-01-01');
266
 
--error ER_BAD_NULL_ERROR
 
194
--error 1048
267
195
INSERT INTO t1 VALUES (103,'',NULL);
268
 
--error ER_BAD_NULL_ERROR
 
196
--error 1048
269
197
UPDATE t1 SET col1=NULL WHERE col1 =100;
270
 
--error ER_BAD_NULL_ERROR
 
198
--error 1048
271
199
UPDATE t1 SET col2 =NULL WHERE col2 ='hello';
272
 
--error ER_BAD_NULL_ERROR
 
200
--error 1048
273
201
UPDATE t1 SET col2 =NULL where col3 IS NOT NULL;
274
202
INSERT IGNORE INTO t1 values (NULL,NULL,NULL);
275
203
SELECT * FROM t1;
278
206
# Testing of default values
279
207
 
280
208
CREATE TABLE t1 (col1 INT NOT NULL default 99, col2 CHAR(6) NOT NULL);
281
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
282
209
SHOW CREATE TABLE t1;
283
210
INSERT INTO t1 VALUES (1, 'hello');
284
211
INSERT INTO t1 (col2) VALUES ('hello2');
285
 
--error ER_BAD_NULL_ERROR
 
212
--error 1048
286
213
INSERT INTO t1 (col2) VALUES (NULL);
287
 
--error ER_NO_DEFAULT_FOR_FIELD
 
214
--error 1364
288
215
INSERT INTO t1 (col1) VALUES (2);
289
 
--error ER_NO_DEFAULT_FOR_FIELD
 
216
--error 1364
290
217
INSERT INTO t1 VALUES(default(col1),default(col2));
291
 
--error ER_NO_DEFAULT_FOR_FIELD
 
218
--error 1364
292
219
INSERT INTO t1 (col1) SELECT 1;
293
 
--error ER_BAD_NULL_ERROR
 
220
--error 1048
294
221
INSERT INTO t1 SELECT 1,NULL;
295
222
INSERT IGNORE INTO t1 values (NULL,NULL);
296
223
--error ER_NO_DEFAULT_FOR_FIELD
306
233
 
307
234
create table t1 (charcol char(255), varcharcol varchar(255),
308
235
       varbinarycol varbinary(255));
309
 
--error ER_DATA_TOO_LONG
 
236
--error 1406
310
237
insert into t1 (charcol) values (repeat('x',256));
311
 
--error ER_DATA_TOO_LONG
 
238
--error 1406
312
239
insert into t1 (varcharcol) values (repeat('x',256));
313
 
--error ER_DATA_TOO_LONG
 
240
--error 1406
314
241
insert into t1 (varbinarycol) values (repeat('x',256));
315
242
select * from t1;
316
243
drop table t1;
320
247
#
321
248
 
322
249
create table t1 (col1 char(3), col2 integer);
323
 
--error ER_TRUNCATED_WRONG_VALUE
 
250
--error 1292
324
251
insert into t1 (col1) values (cast(1000 as char(3)));
325
 
--error ER_TRUNCATED_WRONG_VALUE
 
252
--error 1292
326
253
insert into t1 (col1) values (cast(1000E+0 as char(3)));
327
 
--error ER_TRUNCATED_WRONG_VALUE
 
254
--error 1292
328
255
insert into t1 (col1) values (cast(1000.0 as char(3)));
329
 
--error ER_TRUNCATED_WRONG_VALUE
 
256
--error 1292
330
257
insert into t1 (col2) values (cast('abc' as DECIMAL));
331
 
--error ER_TRUNCATED_WRONG_VALUE
 
258
--error 1292
332
259
insert into t1 (col2) values (10E+0 + 'a');
333
 
--error ER_WARN_DATA_TRUNCATED
 
260
--error 1265
334
261
insert into t1 (col2) values ('10a');
335
262
insert into t1 (col2) values (cast('10a' as DECIMAL));
336
263
insert into t1 (col2) values (cast('10' as DECIMAL));
341
268
 
342
269
# Test fields with no default value that are NOT NULL (Bug #5986)
343
270
CREATE TABLE t1 (i int not null);
344
 
--error ER_NO_DEFAULT_FOR_FIELD
 
271
--error 1364
345
272
INSERT INTO t1 VALUES ();
346
 
--error ER_NO_DEFAULT_FOR_FIELD
 
273
--error 1364
347
274
INSERT INTO t1 VALUES (DEFAULT);
348
 
--error ER_NO_DEFAULT_FOR_FIELD
 
275
--error 1364
349
276
INSERT INTO t1 VALUES (DEFAULT(i));
350
277
ALTER TABLE t1 ADD j int;
351
 
--error ER_NO_DEFAULT_FOR_FIELD
 
278
--error 1364
352
279
INSERT INTO t1 SET j = 1;
353
 
--error ER_NO_DEFAULT_FOR_FIELD
 
280
--error 1364
354
281
INSERT INTO t1 SET j = 1, i = DEFAULT;
355
 
--error ER_NO_DEFAULT_FOR_FIELD
 
282
--error 1364
356
283
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
357
 
--error ER_NO_DEFAULT_FOR_FIELD
 
284
--error 1364
358
285
INSERT INTO t1 VALUES (DEFAULT,1);
359
286
DROP TABLE t1;
360
287
CREATE TABLE t1 (i int not null);
361
 
--error ER_NO_DEFAULT_FOR_FIELD
 
288
--error 1364
362
289
INSERT INTO t1 VALUES ();
363
 
--error ER_NO_DEFAULT_FOR_FIELD
 
290
--error 1364
364
291
INSERT INTO t1 VALUES (DEFAULT);
365
292
# DEFAULT(i) is an error even with the default sql_mode
366
 
--error ER_NO_DEFAULT_FOR_FIELD
 
293
--error 1364
367
294
INSERT INTO t1 VALUES (DEFAULT(i));
368
295
ALTER TABLE t1 ADD j int;
369
 
--error ER_NO_DEFAULT_FOR_FIELD
 
296
--error 1364
370
297
INSERT INTO t1 SET j = 1;
371
 
--error ER_NO_DEFAULT_FOR_FIELD
 
298
--error 1364
372
299
INSERT INTO t1 SET j = 1, i = DEFAULT;
373
 
--error ER_NO_DEFAULT_FOR_FIELD
 
300
--error 1364
374
301
INSERT INTO t1 SET j = 1, i = DEFAULT(i);
375
 
--error ER_NO_DEFAULT_FOR_FIELD
 
302
--error 1364
376
303
INSERT INTO t1 VALUES (DEFAULT,1);
377
304
DROP TABLE t1;
378
305
 
380
307
# Bugs #8295 and #8296: varchar and varbinary conversion
381
308
#
382
309
 
383
 
--error ER_TOO_BIG_FIELDLENGTH
 
310
--error 1074
384
311
create table t1(a varchar(65537));
385
 
--error ER_TOO_BIG_FIELDLENGTH
 
312
--error 1074
386
313
create table t1(a varbinary(65537));
387
314
 
388
315
#
391
318
 
392
319
create table t1(a int, b date not null);                                       
393
320
alter table t1 modify a bigint not null;
394
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
395
321
show create table t1;
396
322
drop table t1;
397
323
 
401
327
 
402
328
create table t1(a int, b timestamp);
403
329
alter table t1 add primary key(a);
404
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
405
330
show create table t1;
406
331
drop table t1;
407
332
create table t1(a int, b timestamp default 20050102030405);
408
333
alter table t1 add primary key(a);
409
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
410
334
show create table t1;
411
335
drop table t1;
412
336
 
416
340
#
417
341
create table t1 (date date not null);
418
342
create table t2 select date from t1;
419
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
420
343
show create table t2;
421
344
drop table t2,t1;
422
345
 
423
346
create table t1 (i int)
424
 
comment='123456789*123456789*123456789*123456789*123456789*123456789*';
425
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
347
comment '123456789*123456789*123456789*123456789*123456789*123456789*';
426
348
show create table t1;
427
349
drop table t1;
428
350
 
456
378
#
457
379
# Bug#27069 set with identical elements are created
458
380
#
459
 
--error ER_DUPLICATED_VALUE_IN_TYPE
 
381
--error 1291
460
382
create table t1 (f1 enum('a','a'));
461
383
 
462
384
--echo End of 5.0 tests