~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/strict.test

  • Committer: Jay Pipes
  • Date: 2009-02-04 15:44:25 UTC
  • mfrom: (829 drizzle)
  • mto: This revision was merged to the branch mainline in revision 830.
  • Revision ID: jpipes@serialcoder-20090204154425-th8xfk2ujz2y8xwg
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
# Test INSERT with INT
6
6
 
7
 
--disable_warnings
8
 
DROP TABLE IF EXISTS t1;
9
 
--enable_warnings
10
7
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);
 
8
INSERT INTO t1 VALUES(-2147483648),(0),(2147483647),('-2147483648'),('2147483647'),(-2147483648.0),(2147483647.0);
18
9
--error ER_WARN_DATA_OUT_OF_RANGE
19
10
INSERT INTO t1 (col1) VALUES(-2147483649);
20
11
--error ER_WARN_DATA_OUT_OF_RANGE
42
33
INSERT INTO t1 (col1) VALUES ('1a');
43
34
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
44
35
INSERT IGNORE INTO t1 values (1/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);
 
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);
51
39
SELECT * FROM t1;
52
40
DROP TABLE t1;
53
41
 
56
44
# integers when it's too big/small (just like C)
57
45
 
58
46
CREATE TABLE t1 (col1 BIGINT);
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);
 
47
INSERT INTO t1 VALUES(-9223372036854775808),(0),(9223372036854775807);
 
48
INSERT INTO t1 VALUES('-9223372036854775808'),('9223372036854775807');
 
49
INSERT INTO t1 VALUES(-9223372036854774000.0),(9223372036854775700.0);
66
50
 
67
51
--error ER_WARN_DATA_OUT_OF_RANGE
68
52
INSERT INTO t1 (col1) VALUES(-9223372036854775809);
98
82
INSERT INTO t1 (col1) VALUES ('1a');
99
83
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
100
84
INSERT IGNORE INTO t1 values (1/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);
 
85
INSERT IGNORE INTO t1 VALUES(-9223372036854775809),(9223372036854775808);
 
86
INSERT IGNORE INTO t1 VALUES('-9223372036854775809'),('9223372036854775808');
 
87
INSERT IGNORE INTO t1 VALUES(-9223372036854785809.0),(9223372036854785808.0);
107
88
SELECT * FROM t1;
108
89
DROP TABLE t1;
109
90
 
110
91
# Test INSERT with NUMERIC
111
92
 
112
93
CREATE TABLE t1 (col1 NUMERIC(4,2));
113
 
# The following INSERT statements used to look as follows before 
114
 
# the fix for bug#337038 was implemented:
115
 
# INSERT INTO t1 
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.
119
 
 
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
123
 
# in fact occur
124
 
--error 1265 
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
130
 
# in fact occur
131
 
--error 1265
132
 
INSERT INTO t1 VALUES (-10.5555);
133
 
INSERT INTO t1 VALUES (11);
134
 
INSERT INTO t1 VALUES (1e+01);
135
 
 
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.
141
 
 
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
145
 
# in fact occur
146
 
--error 1265 
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 
151
 
# in fact occur
152
 
--error 1265 
153
 
INSERT INTO t1 VALUES ('-10.5555');
154
 
INSERT INTO t1 VALUES ('11');
155
 
INSERT INTO t1 VALUES ('1e+01');
 
94
INSERT INTO t1 VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01);
 
95
# Note that the +/-10.5555 is inserted as +/-10.55, not +/-10.56 !
 
96
INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');
156
97
 
157
98
# The 2 following inserts should generate a warning, but doesn't yet
158
99
# because NUMERIC works like DECIMAL
196
137
INSERT INTO t1 (col1) VALUES ('1a');
197
138
INSERT IGNORE INTO t1 (col1) VALUES ('2a');
198
139
INSERT IGNORE INTO t1 values (1/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);
 
140
INSERT IGNORE INTO t1 VALUES(1000),(-1000);
 
141
INSERT IGNORE INTO t1 VALUES('1000'),('-1000');
 
142
INSERT IGNORE INTO t1 VALUES(1000.0),(-1000.0);
205
143
UPDATE IGNORE t1 SET col1=1/NULL where col1=0;
206
 
--sorted_result
207
144
SELECT * FROM t1;
208
145
DROP TABLE t1;
209
146
 
210
147
# Testing INSERT with CHAR/VARCHAR
211
148
 
212
149
CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6));
213
 
INSERT INTO t1 VALUES ('hello', 'hello');
214
 
INSERT INTO t1 VALUES ('he', 'he');
215
 
INSERT INTO t1 VALUES ('hello   ', 'hello ');
 
150
INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello   ', 'hello ');
216
151
--error 1406
217
152
INSERT INTO t1 (col1) VALUES ('hellobob');
218
153
--error 1406
224
159
UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he';
225
160
INSERT IGNORE INTO t1 VALUES ('hellobob', 'hellobob');
226
161
UPDATE IGNORE t1 SET col2 ='hellotrudy' WHERE col2 ='he';
227
 
--sorted_result
228
162
SELECT * FROM t1;
229
163
DROP TABLE t1;
230
164
 
231
165
# Testing INSERT with ENUM
232
166
 
233
167
CREATE TABLE t1 (col1 enum('red','blue','green'));
234
 
INSERT INTO t1 VALUES ('red');
235
 
INSERT INTO t1 VALUES ('blue');
236
 
INSERT INTO t1 VALUES ('green');
237
 
--error 1691 # Bad enum
 
168
INSERT INTO t1 VALUES ('red'),('blue'),('green');
 
169
--error 1265
238
170
INSERT INTO t1 (col1) VALUES ('yellow');
239
 
--error 1691 # Bad enum
 
171
--error 1265
240
172
INSERT INTO t1 (col1) VALUES ('redd');
241
 
--error 1691 # Bad enum
 
173
--error 1265
242
174
INSERT INTO t1 VALUES ('');
243
 
--error 1691 # Bad enum
 
175
--error 1265
244
176
UPDATE t1 SET col1 ='yellow' WHERE col1 ='green';
245
 
--error 1691 # Bad enum
246
177
INSERT IGNORE INTO t1 VALUES ('yellow');
247
 
--error 1691 # Bad enum
248
178
UPDATE IGNORE t1 SET col1 ='yellow' WHERE col1 ='blue';
249
179
SELECT * FROM t1;
250
180
DROP TABLE t1;
273
203
# Testing of default values
274
204
 
275
205
CREATE TABLE t1 (col1 INT NOT NULL default 99, col2 CHAR(6) NOT NULL);
276
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
277
206
SHOW CREATE TABLE t1;
278
207
INSERT INTO t1 VALUES (1, 'hello');
279
208
INSERT INTO t1 (col2) VALUES ('hello2');
311
240
drop table t1;
312
241
 
313
242
#
 
243
# Bug #5902: STR_TO_DATE() didn't give errors in traditional mode
 
244
#
 
245
 
 
246
create table t1 (col1 datetime);
 
247
--error 1292
 
248
insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
 
249
--error 1411
 
250
insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
 
251
--error 1411
 
252
insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
 
253
--error 1411
 
254
insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
 
255
--error ER_TRUNCATED_WRONG_VALUE
 
256
insert into t1 values(STR_TO_DATE('31.10.2004 15.30 abc','%d.%m.%Y %H.%i'));
 
257
--error ER_WRONG_VALUE_FOR_TYPE
 
258
insert into t1 values(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
 
259
--error ER_WRONG_VALUE_FOR_TYPE
 
260
insert into t1 values(STR_TO_DATE('2004.12.12 22:22:33 AM','%Y.%m.%d %r'));
 
261
--error ER_WRONG_VALUE_FOR_TYPE
 
262
insert into t1 values(STR_TO_DATE('2004.12.12 abc','%Y.%m.%d %T'));
 
263
 
 
264
# Some correct values, just to test the functions
 
265
insert into t1 values(STR_TO_DATE('31.10.2004 15.30','%d.%m.%Y %H.%i'));
 
266
insert into t1 values(STR_TO_DATE('2004.12.12 11:22:33 AM','%Y.%m.%d %r'));
 
267
insert into t1 values(STR_TO_DATE('2004.12.12 10:22:59','%Y.%m.%d %T'));
 
268
 
 
269
select * from t1;
 
270
 
 
271
select count(*) from t1 where STR_TO_DATE('2004.12.12 10:22:61','%Y.%m.%d %T') IS NULL;
 
272
 
 
273
drop table t1;
 
274
 
 
275
#
314
276
# Check insert with wrong CAST() (Bug #5912)
315
277
#
316
278
 
386
348
 
387
349
create table t1(a int, b date not null);                                       
388
350
alter table t1 modify a bigint not null;
389
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
390
351
show create table t1;
391
352
drop table t1;
392
353
 
396
357
 
397
358
create table t1(a int, b timestamp);
398
359
alter table t1 add primary key(a);
399
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
400
360
show create table t1;
401
361
drop table t1;
402
362
create table t1(a int, b timestamp default 20050102030405);
403
363
alter table t1 add primary key(a);
404
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
405
364
show create table t1;
406
365
drop table t1;
407
366
 
411
370
#
412
371
create table t1 (date date not null);
413
372
create table t2 select date from t1;
414
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
415
373
show create table t2;
416
374
drop table t2,t1;
417
375
 
418
376
create table t1 (i int)
419
377
comment '123456789*123456789*123456789*123456789*123456789*123456789*';
420
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
421
378
show create table t1;
422
379
drop table t1;
423
380