~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/haildb/tests/t/type_blob.test

  • Committer: Olaf van der Spek
  • Date: 2011-08-04 08:13:04 UTC
  • mfrom: (2384 drizzle)
  • mto: This revision was merged to the branch mainline in revision 2385.
  • Revision ID: olafvdspek@gmail.com-20110804081304-rlejjpvoos17bjdf
Merge trunk

Show diffs side-by-side

added added

removed removed

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