~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
# This test can't be run with running server (--extern) as this uses
2
# load_file() on a file in the tree.
3
#
4
5
#
6
# Basic cleanup
7
#
8
--disable_warnings
9
drop table if exists t1,t2,t3,t4,t5,t6,t7;
10
--enable_warnings
11
12
13
#
14
# Check syntax for creating BLOB/TEXT
15
#
16
498 by Brian Aker
Remove dead tests and enable a few more tests.
17
CREATE TABLE t1 (a blob, b text, c blob, d text, e text);
1 by brian
clean slate
18
show columns from t1;
19
# PS doesn't give errors on prepare yet
498 by Brian Aker
Remove dead tests and enable a few more tests.
20
CREATE TABLE t2 (a varchar(255), b blob, c blob);
21
CREATE TABLE t4 (c varchar(16383) not null);
1 by brian
clean slate
22
show columns from t2;
498 by Brian Aker
Remove dead tests and enable a few more tests.
23
create table t3 (a int, b int);
942.3.1 by Vladimir Kolesnikov
test generalizations
24
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
25
show create TABLE t3;
942.3.1 by Vladimir Kolesnikov
test generalizations
26
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
27
show create TABLE t4;
28
drop table t1,t2,t3,t4;
29
30
#
31
# Check errors with blob
32
#
33
896.3.4 by Stewart Smith
Create default_values record from proto instead of reading from FRM. assert if different to FRM.
34
--error 1101
498 by Brian Aker
Remove dead tests and enable a few more tests.
35
CREATE TABLE t1 (a blob default "hello");
36
CREATE TABLE t2 (a varchar(256));
896.3.4 by Stewart Smith
Create default_values record from proto instead of reading from FRM. assert if different to FRM.
37
drop table t2;
1 by brian
clean slate
38
--error 1074
39
CREATE TABLE t1 (a varchar(70000) default "hello");
896.3.4 by Stewart Smith
Create default_values record from proto instead of reading from FRM. assert if different to FRM.
40
--error 1101
1 by brian
clean slate
41
CREATE TABLE t2 (a blob default "hello");
42
43
# Safety to be able to continue with other tests if above fails
44
--disable_warnings
45
drop table if exists t1,t2;
46
--enable_warnings
47
48
#
49
# test of full join with blob
50
#
51
498 by Brian Aker
Remove dead tests and enable a few more tests.
52
create table t1 (nr int not null auto_increment,b blob,str char(10), primary key (nr));
1 by brian
clean slate
53
insert into t1 values (null,"a","A");
54
insert into t1 values (null,"bbb","BBB");
55
insert into t1 values (null,"ccc","CCC");
56
select last_insert_id();
57
select * from t1,t1 as t2;
58
59
drop table t1;
60
61
#
62
# Test of changing TEXT column
63
#
64
65
create table t1 (a text);
66
insert into t1 values ('where');
67
update t1 set a='Where'; 
68
select * from t1;
69
drop table t1;
70
71
#
498 by Brian Aker
Remove dead tests and enable a few more tests.
72
# test of blob, text, and char
1 by brian
clean slate
73
#
498 by Brian Aker
Remove dead tests and enable a few more tests.
74
create table t1 (t text,c varchar(10),b blob, d blob);
1 by brian
clean slate
75
insert into t1 values (NULL,NULL,NULL,NULL);
76
insert into t1 values ("","","","");
77
insert into t1 values ("hello","hello","hello","hello");
78
insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
79
insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
80
insert into t1 values ("a","a","a","a");
81
insert into t1 values (1,1,1,1);
82
insert into t1 values (NULL,NULL,NULL,NULL);
83
update t1 set c="",b=null where c="1";
84
85
select t from t1 where t like "hello";
86
select c from t1 where c like "hello";
87
select b from t1 where b like "hello";
88
select d from t1 where d like "hello";
89
select c from t1 having c like "hello";
90
select d from t1 having d like "hello";
91
select t from t1 where t like "%HELLO%";
92
select c from t1 where c like "%HELLO%";
93
select b from t1 where b like "%HELLO%";
94
select d from t1 where d like "%HELLO%";
95
select c from t1 having c like "%HELLO%";
96
select d from t1 having d like "%HELLO%";
97
select d from t1 having d like "%HE%LLO%";
98
select t from t1 order by t;
99
select c from t1 order by c;
100
select b from t1 order by b;
101
select d from t1 order by d;
102
select distinct t from t1;
103
select distinct b from t1;
104
select distinct t from t1 order by t;
105
select distinct b from t1 order by b;
106
select t from t1 group by t;
107
select b from t1 group by b;
108
select distinct t from t1;
109
select distinct b from t1;
110
select distinct t from t1 order by t;
111
select distinct b from t1 order by b;
112
select distinct c from t1;
113
select distinct d from t1;
114
select distinct c from t1 order by c;
115
select distinct d from t1 order by d;
116
select c from t1 group by c;
117
select d from t1 group by d;
118
select distinct * from t1;
119
select t,count(*) from t1 group by t;
120
select b,count(*) from t1 group by b;
121
select c,count(*) from t1 group by c;
122
select d,count(*) from t1 group by d;
123
drop table t1;
124
125
-- error 1071
126
create table t1 (a text, unique (a(2100))); # should give an error
127
create table t1 (a text, key (a(2100)));    # key is auto-truncated
942.3.1 by Vladimir Kolesnikov
test generalizations
128
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
129
show create table t1;
130
drop table t1;
131
132
#
133
# Test of join with blobs and min
134
#
135
136
CREATE TABLE t1 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
137
  t1_id bigint NOT NULL auto_increment,
1 by brian
clean slate
138
  _field_72 varchar(128) DEFAULT '' NOT NULL,
139
  _field_95 varchar(32),
498 by Brian Aker
Remove dead tests and enable a few more tests.
140
  _field_115 int DEFAULT '0' NOT NULL,
141
  _field_122 int DEFAULT '0' NOT NULL,
142
  _field_126 int,
143
  _field_134 int,
1 by brian
clean slate
144
  PRIMARY KEY (t1_id),
145
  UNIQUE _field_72 (_field_72),
146
  KEY _field_115 (_field_115),
147
  KEY _field_122 (_field_122)
148
);
149
150
151
INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
152
INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
153
INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
154
155
156
CREATE TABLE t2 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
157
  seq_0_id bigint DEFAULT '0' NOT NULL,
158
  seq_1_id bigint DEFAULT '0' NOT NULL,
1 by brian
clean slate
159
  PRIMARY KEY (seq_0_id,seq_1_id)
160
);
161
162
163
INSERT INTO t2 VALUES (1,1);
164
INSERT INTO t2 VALUES (2,1);
165
INSERT INTO t2 VALUES (2,2);
166
167
CREATE TABLE t3 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
168
  t3_id bigint NOT NULL auto_increment,
1 by brian
clean slate
169
  _field_131 varchar(128),
498 by Brian Aker
Remove dead tests and enable a few more tests.
170
  _field_133 int DEFAULT '0' NOT NULL,
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
171
  _field_135 datetime,
498 by Brian Aker
Remove dead tests and enable a few more tests.
172
  _field_137 int,
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
173
  _field_139 datetime,
1 by brian
clean slate
174
  _field_140 blob,
498 by Brian Aker
Remove dead tests and enable a few more tests.
175
  _field_142 int DEFAULT '0' NOT NULL,
176
  _field_145 int DEFAULT '0' NOT NULL,
177
  _field_148 int DEFAULT '0' NOT NULL,
1 by brian
clean slate
178
  PRIMARY KEY (t3_id),
179
  KEY _field_133 (_field_133),
180
  KEY _field_135 (_field_135),
181
  KEY _field_139 (_field_139),
182
  KEY _field_142 (_field_142),
183
  KEY _field_145 (_field_145),
184
  KEY _field_148 (_field_148)
185
);
186
187
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
188
INSERT INTO t3 VALUES (1,'test job 1',0,NULL,0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
189
INSERT INTO t3 VALUES (2,'test job 2',0,NULL,0,'1999-02-26 21:08:04','',0,0,0);
1 by brian
clean slate
190
191
192
CREATE TABLE t4 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
193
  seq_0_id bigint DEFAULT '0' NOT NULL,
194
  seq_1_id bigint DEFAULT '0' NOT NULL,
1 by brian
clean slate
195
  PRIMARY KEY (seq_0_id,seq_1_id)
196
);
197
198
199
INSERT INTO t4 VALUES (1,1);
200
INSERT INTO t4 VALUES (2,1);
201
202
CREATE TABLE t5 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
203
  t5_id bigint NOT NULL auto_increment,
204
  _field_149 int,
1 by brian
clean slate
205
  _field_156 varchar(128) DEFAULT '' NOT NULL,
206
  _field_157 varchar(128) DEFAULT '' NOT NULL,
207
  _field_158 varchar(128) DEFAULT '' NOT NULL,
208
  _field_159 varchar(128) DEFAULT '' NOT NULL,
209
  _field_160 varchar(128) DEFAULT '' NOT NULL,
210
  _field_161 varchar(128) DEFAULT '' NOT NULL,
211
  PRIMARY KEY (t5_id),
212
  KEY _field_156 (_field_156),
213
  KEY _field_157 (_field_157),
214
  KEY _field_158 (_field_158),
215
  KEY _field_159 (_field_159),
216
  KEY _field_160 (_field_160),
217
  KEY _field_161 (_field_161)
218
);
219
220
221
INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
222
INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
223
224
CREATE TABLE t6 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
225
  seq_0_id bigint DEFAULT '0' NOT NULL,
226
  seq_1_id bigint DEFAULT '0' NOT NULL,
1 by brian
clean slate
227
  PRIMARY KEY (seq_0_id,seq_1_id)
228
);
229
230
INSERT INTO t6 VALUES (1,1);
231
INSERT INTO t6 VALUES (1,2);
232
INSERT INTO t6 VALUES (2,2);
233
234
CREATE TABLE t7 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
235
  t7_id bigint NOT NULL auto_increment,
236
  _field_143 int,
1 by brian
clean slate
237
  _field_165 varchar(32),
498 by Brian Aker
Remove dead tests and enable a few more tests.
238
  _field_166 int DEFAULT '0' NOT NULL,
1 by brian
clean slate
239
  PRIMARY KEY (t7_id),
240
  KEY _field_166 (_field_166)
241
);
242
243
244
INSERT INTO t7 VALUES (1,0,'High',1);
245
INSERT INTO t7 VALUES (2,0,'Medium',2);
246
INSERT INTO t7 VALUES (3,0,'Low',3);
247
248
select replace(t3._field_140, "\r","^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
249
250
drop table t1,t2,t3,t4,t5,t6,t7;
251
252
#
253
# Test of reverse with empty blob
254
#
255
256
create table t1 (a blob);
257
insert into t1 values ("empty"),("");
258
select a,reverse(a) from t1;
259
drop table t1;
260
261
#
262
# Test of BLOB:s with NULL keys.
263
#
264
265
create table t1 (a blob, key (a(10)));
266
insert into t1 values ("bye"),("hello"),("hello"),("hello word");
267
select * from t1 where a like "hello%";
268
drop table t1;
269
270
#
271
# Test of found bug in group on text key
272
#
273
274
CREATE TABLE t1 (
498 by Brian Aker
Remove dead tests and enable a few more tests.
275
       f1 int DEFAULT '0' NOT NULL,
1 by brian
clean slate
276
       f2 varchar(16) DEFAULT '' NOT NULL,
277
       f5 text,
278
       KEY index_name (f1,f2,f5(16))
279
    );
280
INSERT INTO t1 VALUES (0,'traktor','1111111111111');
281
INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111');
282
select count(*) from t1 where f2='traktor';
283
drop table t1;
284
285
#
286
# Test of found bug when blob is first key part
287
#
288
396 by Brian Aker
Cleanup tiny and small int.
289
create table t1 (foobar tinyblob not null, boggle int not null, key (foobar(32), boggle));
1 by brian
clean slate
290
insert into t1 values ('fish', 10),('bear', 20);
291
select foobar, boggle from t1 where foobar = 'fish';
292
select foobar, boggle from t1 where foobar = 'fish' and boggle = 10;
293
drop table t1;
294
295
#
296
# Test blob's with end space (Bug #1651)
297
# This is a bit changed since we now have true varchar
298
#
299
520.4.13 by Monty Taylor
Cleaned up two remaining test cases.
300
#FIXME: The following test needs to be fixed for Drizzle
301
#create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20)));
302
#--error ER_DUP_ENTRY
303
#insert into t1 (txt) values ('Chevy'), ('Chevy ');
304
#--error ER_DUP_ENTRY
305
#insert into t1 (txt) values ('Chevy'), ('CHEVY');
306
#alter table t1 drop index txt_index, add index txt_index (txt(20));
307
#insert into t1 (txt) values ('Chevy ');
308
#select * from t1 where txt='Chevy';
309
#select * from t1 where txt='Chevy ';
310
#select * from t1 where txt='Chevy ' or txt='Chevy';
311
#select * from t1 where txt='Chevy' or txt='Chevy ';
312
#select * from t1 where id='1' or id='2';
313
#insert into t1 (txt) values('Ford');
314
#select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
315
#select * from t1 where txt='Chevy' or txt='Chevy ';
316
#select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
317
#select * from t1 where txt in ('Chevy ','Chevy');
318
#select * from t1 where txt in ('Chevy');
319
#select * from t1 where txt between 'Chevy' and 'Chevy';
320
#select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
321
#select * from t1 where txt between 'Chevy' and 'Chevy ';
322
#select * from t1 where txt < 'Chevy ';
323
#select * from t1 where txt <= 'Chevy';
324
#select * from t1 where txt > 'Chevy';
325
#select * from t1 where txt >= 'Chevy';
326
#drop table t1;
1 by brian
clean slate
327
328
create table t1 (id integer primary key auto_increment, txt text, index txt_index (txt (20)));
329
insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
330
select * from t1 where txt='Chevy' or txt is NULL;
331
explain select * from t1 where txt='Chevy' or txt is NULL;
332
select * from t1 where txt='Chevy ';
333
select * from t1 where txt='Chevy ' or txt='Chevy';
334
select * from t1 where txt='Chevy' or txt='Chevy ';
335
select * from t1 where id='1' or id='2';
336
insert into t1 (txt) values('Ford');
337
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
338
select * from t1 where txt='Chevy' or txt='Chevy ';
339
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
340
select * from t1 where txt in ('Chevy ','Chevy');
341
select * from t1 where txt in ('Chevy');
342
select * from t1 where txt between 'Chevy' and 'Chevy';
343
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
344
select * from t1 where txt between 'Chevy' and 'Chevy ';
345
select * from t1 where txt < 'Chevy ';
346
select * from t1 where txt < 'Chevy ' or txt is NULL;
347
select * from t1 where txt <= 'Chevy';
348
select * from t1 where txt > 'Chevy';
349
select * from t1 where txt >= 'Chevy';
350
alter table t1 modify column txt blob;
351
explain select * from t1 where txt='Chevy' or txt is NULL;
352
select * from t1 where txt='Chevy' or txt is NULL;
353
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
354
select * from t1 where txt='Chevy' or txt is NULL order by txt;
355
drop table t1;
356
498 by Brian Aker
Remove dead tests and enable a few more tests.
357
CREATE TABLE t1 ( i int NOT NULL default '0',    c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY  (i), KEY (c(1),d));
1 by brian
clean slate
358
INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,'');
359
select max(i) from t1 where c = '';
360
drop table t1;
361
362
# End of 4.1 tests
363
364
#
365
# Bug#11657: Creation of secondary index fails
366
#
367
create table t1 (a int, b int, c tinyblob, d int, e int);
368
alter table t1 add primary key (a,b,c(255),d);
369
alter table t1 add key (a,b,d,e);
942.3.1 by Vladimir Kolesnikov
test generalizations
370
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
371
show create table t1;
372
drop table t1;
373
374
#
498 by Brian Aker
Remove dead tests and enable a few more tests.
375
# Test that blobs are sorted according to length
1 by brian
clean slate
376
#
377
378
CREATE table t1 (a blob);
379
insert into t1 values ('b'),('a\0'),('a'),('a '),('aa'),(NULL);
380
select hex(a) from t1 order by a;
381
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
498 by Brian Aker
Remove dead tests and enable a few more tests.
382
alter table t1 modify a blob;
1 by brian
clean slate
383
select hex(a) from t1 order by a;
384
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
385
alter table t1 modify a char(5);
386
select hex(a) from t1 order by a;
387
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
388
drop table t1;
389
390
#
391
# Bug #19489: Inconsistent support for DEFAULT in TEXT columns
392
#
393
create table t1 (a text default '');
942.3.1 by Vladimir Kolesnikov
test generalizations
394
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
395
show create table t1;
396
insert into t1 values (default);
397
select * from t1;
398
drop table t1;
399
create table t1 (a text default '');
1119.4.8 by Stewart Smith
make type_blob test not leave tables behind
400
drop table t1;
1 by brian
clean slate
401
402
#
403
# Bug #32282: TEXT silently truncates when value is exactly 65536 bytes
404
#
405
498 by Brian Aker
Remove dead tests and enable a few more tests.
406
CREATE TABLE t (c TEXT);
1 by brian
clean slate
407
INSERT INTO t (c) VALUES (REPEAT('1',65537));
408
INSERT INTO t (c) VALUES (REPEAT('2',65536));
409
INSERT INTO t (c) VALUES (REPEAT('3',65535));
410
SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
411
DROP TABLE t;
412
413
--echo End of 5.0 tests