~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/r/type_blob.result

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1,t2,t3,t4,t5,t6,t7;
 
2
CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
 
3
show columns from t1;
 
4
Field   Type    Null    Key     Default Extra
 
5
a       blob    YES             NULL    
 
6
b       text    YES             NULL    
 
7
c       tinyblob        YES             NULL    
 
8
d       mediumtext      YES             NULL    
 
9
e       longtext        YES             NULL    
 
10
CREATE TABLE t2 (a char(255), b varbinary(70000), c varchar(70000000));
 
11
Warnings:
 
12
Note    1246    Converting column 'b' from VARBINARY to BLOB
 
13
Note    1246    Converting column 'c' from VARCHAR to TEXT
 
14
CREATE TABLE t4 (c varchar(65530) character set utf8 not null);
 
15
Warnings:
 
16
Note    1246    Converting column 'c' from VARCHAR to TEXT
 
17
show columns from t2;
 
18
Field   Type    Null    Key     Default Extra
 
19
a       char(255)       YES             NULL    
 
20
b       mediumblob      YES             NULL    
 
21
c       longtext        YES             NULL    
 
22
create table t3 (a long, b long byte);
 
23
show create TABLE t3;
 
24
Table   Create Table
 
25
t3      CREATE TABLE `t3` (
 
26
  `a` mediumtext,
 
27
  `b` mediumblob
 
28
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
29
show create TABLE t4;
 
30
Table   Create Table
 
31
t4      CREATE TABLE `t4` (
 
32
  `c` mediumtext CHARACTER SET utf8 NOT NULL
 
33
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
34
drop table t1,t2,t3,t4;
 
35
CREATE TABLE t1 (a char(257) default "hello");
 
36
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
 
37
CREATE TABLE t2 (a char(256));
 
38
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
 
39
CREATE TABLE t1 (a varchar(70000) default "hello");
 
40
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
 
41
CREATE TABLE t2 (a blob default "hello");
 
42
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
 
43
drop table if exists t1,t2;
 
44
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
 
45
insert into t1 values (null,"a","A");
 
46
insert into t1 values (null,"bbb","BBB");
 
47
insert into t1 values (null,"ccc","CCC");
 
48
select last_insert_id();
 
49
last_insert_id()
 
50
3
 
51
select * from t1,t1 as t2;
 
52
nr      b       str     nr      b       str
 
53
1       a       A       1       a       A
 
54
2       bbb     BBB     1       a       A
 
55
3       ccc     CCC     1       a       A
 
56
1       a       A       2       bbb     BBB
 
57
2       bbb     BBB     2       bbb     BBB
 
58
3       ccc     CCC     2       bbb     BBB
 
59
1       a       A       3       ccc     CCC
 
60
2       bbb     BBB     3       ccc     CCC
 
61
3       ccc     CCC     3       ccc     CCC
 
62
drop table t1;
 
63
create table t1 (a text);
 
64
insert into t1 values ('where');
 
65
update t1 set a='Where';
 
66
select * from t1;
 
67
a
 
68
Where
 
69
drop table t1;
 
70
create table t1 (t text,c char(10),b blob, d varbinary(10));
 
71
insert into t1 values (NULL,NULL,NULL,NULL);
 
72
insert into t1 values ("","","","");
 
73
insert into t1 values ("hello","hello","hello","hello");
 
74
insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
 
75
insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
 
76
insert into t1 values ("a","a","a","a");
 
77
insert into t1 values (1,1,1,1);
 
78
insert into t1 values (NULL,NULL,NULL,NULL);
 
79
update t1 set c="",b=null where c="1";
 
80
lock tables t1 READ;
 
81
show full fields from t1;
 
82
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
83
t       text    latin1_swedish_ci       YES             NULL            #       
 
84
c       char(10)        latin1_swedish_ci       YES             NULL            #       
 
85
b       blob    NULL    YES             NULL            #       
 
86
d       varbinary(10)   NULL    YES             NULL            #       
 
87
lock tables t1 WRITE;
 
88
show full fields from t1;
 
89
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
90
t       text    latin1_swedish_ci       YES             NULL            #       
 
91
c       char(10)        latin1_swedish_ci       YES             NULL            #       
 
92
b       blob    NULL    YES             NULL            #       
 
93
d       varbinary(10)   NULL    YES             NULL            #       
 
94
unlock tables;
 
95
select t from t1 where t like "hello";
 
96
t
 
97
hello
 
98
HELLO
 
99
select c from t1 where c like "hello";
 
100
c
 
101
hello
 
102
HELLO
 
103
select b from t1 where b like "hello";
 
104
b
 
105
hello
 
106
select d from t1 where d like "hello";
 
107
d
 
108
hello
 
109
select c from t1 having c like "hello";
 
110
c
 
111
hello
 
112
HELLO
 
113
select d from t1 having d like "hello";
 
114
d
 
115
hello
 
116
select t from t1 where t like "%HELLO%";
 
117
t
 
118
hello
 
119
HELLO
 
120
HELLO MY
 
121
select c from t1 where c like "%HELLO%";
 
122
c
 
123
hello
 
124
HELLO
 
125
HELLO MY
 
126
select b from t1 where b like "%HELLO%";
 
127
b
 
128
HELLO
 
129
HELLO MY
 
130
select d from t1 where d like "%HELLO%";
 
131
d
 
132
HELLO
 
133
HELLO MY
 
134
select c from t1 having c like "%HELLO%";
 
135
c
 
136
hello
 
137
HELLO
 
138
HELLO MY
 
139
select d from t1 having d like "%HELLO%";
 
140
d
 
141
HELLO
 
142
HELLO MY
 
143
select d from t1 having d like "%HE%LLO%";
 
144
d
 
145
HELLO
 
146
HELLO MY
 
147
select t from t1 order by t;
 
148
t
 
149
NULL
 
150
NULL
 
151
 
 
152
1
 
153
a
 
154
hello
 
155
HELLO
 
156
HELLO MY
 
157
select c from t1 order by c;
 
158
c
 
159
NULL
 
160
NULL
 
161
 
 
162
 
 
163
a
 
164
hello
 
165
HELLO
 
166
HELLO MY
 
167
select b from t1 order by b;
 
168
b
 
169
NULL
 
170
NULL
 
171
NULL
 
172
 
 
173
HELLO
 
174
HELLO MY
 
175
a
 
176
hello
 
177
select d from t1 order by d;
 
178
d
 
179
NULL
 
180
NULL
 
181
 
 
182
1
 
183
HELLO
 
184
HELLO MY
 
185
a
 
186
hello
 
187
select distinct t from t1;
 
188
t
 
189
NULL
 
190
 
 
191
hello
 
192
HELLO MY
 
193
a
 
194
1
 
195
select distinct b from t1;
 
196
b
 
197
NULL
 
198
 
 
199
hello
 
200
HELLO
 
201
HELLO MY
 
202
a
 
203
select distinct t from t1 order by t;
 
204
t
 
205
NULL
 
206
 
 
207
1
 
208
a
 
209
hello
 
210
HELLO MY
 
211
select distinct b from t1 order by b;
 
212
b
 
213
NULL
 
214
 
 
215
HELLO
 
216
HELLO MY
 
217
a
 
218
hello
 
219
select t from t1 group by t;
 
220
t
 
221
NULL
 
222
 
 
223
1
 
224
a
 
225
hello
 
226
HELLO MY
 
227
select b from t1 group by b;
 
228
b
 
229
NULL
 
230
 
 
231
HELLO
 
232
HELLO MY
 
233
a
 
234
hello
 
235
set option sql_big_tables=1;
 
236
select distinct t from t1;
 
237
t
 
238
NULL
 
239
 
 
240
hello
 
241
HELLO MY
 
242
a
 
243
1
 
244
select distinct b from t1;
 
245
b
 
246
NULL
 
247
 
 
248
hello
 
249
HELLO
 
250
HELLO MY
 
251
a
 
252
select distinct t from t1 order by t;
 
253
t
 
254
NULL
 
255
 
 
256
1
 
257
a
 
258
hello
 
259
HELLO MY
 
260
select distinct b from t1 order by b;
 
261
b
 
262
NULL
 
263
 
 
264
HELLO
 
265
HELLO MY
 
266
a
 
267
hello
 
268
select distinct c from t1;
 
269
c
 
270
NULL
 
271
 
 
272
hello
 
273
HELLO MY
 
274
a
 
275
select distinct d from t1;
 
276
d
 
277
NULL
 
278
 
 
279
hello
 
280
HELLO
 
281
HELLO MY
 
282
a
 
283
1
 
284
select distinct c from t1 order by c;
 
285
c
 
286
NULL
 
287
 
 
288
a
 
289
hello
 
290
HELLO MY
 
291
select distinct d from t1 order by d;
 
292
d
 
293
NULL
 
294
 
 
295
1
 
296
HELLO
 
297
HELLO MY
 
298
a
 
299
hello
 
300
select c from t1 group by c;
 
301
c
 
302
NULL
 
303
 
 
304
a
 
305
hello
 
306
HELLO MY
 
307
select d from t1 group by d;
 
308
d
 
309
NULL
 
310
 
 
311
1
 
312
HELLO
 
313
HELLO MY
 
314
a
 
315
hello
 
316
set option sql_big_tables=0;
 
317
select distinct * from t1;
 
318
t       c       b       d
 
319
NULL    NULL    NULL    NULL
 
320
                        
 
321
hello   hello   hello   hello
 
322
HELLO   HELLO   HELLO   HELLO
 
323
HELLO MY        HELLO MY        HELLO MY        HELLO MY
 
324
a       a       a       a
 
325
1               NULL    1
 
326
select t,count(*) from t1 group by t;
 
327
t       count(*)
 
328
NULL    2
 
329
        1
 
330
1       1
 
331
a       1
 
332
hello   2
 
333
HELLO MY        1
 
334
select b,count(*) from t1 group by b;
 
335
b       count(*)
 
336
NULL    3
 
337
        1
 
338
HELLO   1
 
339
HELLO MY        1
 
340
a       1
 
341
hello   1
 
342
select c,count(*) from t1 group by c;
 
343
c       count(*)
 
344
NULL    2
 
345
        2
 
346
a       1
 
347
hello   2
 
348
HELLO MY        1
 
349
select d,count(*) from t1 group by d;
 
350
d       count(*)
 
351
NULL    2
 
352
        1
 
353
1       1
 
354
HELLO   1
 
355
HELLO MY        1
 
356
a       1
 
357
hello   1
 
358
drop table t1;
 
359
create table t1 (a text, unique (a(2100)));
 
360
ERROR 42000: Specified key was too long; max key length is 1332 bytes
 
361
create table t1 (a text, key (a(2100)));
 
362
Warnings:
 
363
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
364
show create table t1;
 
365
Table   Create Table
 
366
t1      CREATE TABLE `t1` (
 
367
  `a` text,
 
368
  KEY `a` (`a`(1332))
 
369
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
370
drop table t1;
 
371
CREATE TABLE t1 (
 
372
t1_id bigint(21) NOT NULL auto_increment,
 
373
_field_72 varchar(128) DEFAULT '' NOT NULL,
 
374
_field_95 varchar(32),
 
375
_field_115 tinyint(4) DEFAULT '0' NOT NULL,
 
376
_field_122 tinyint(4) DEFAULT '0' NOT NULL,
 
377
_field_126 tinyint(4),
 
378
_field_134 tinyint(4),
 
379
PRIMARY KEY (t1_id),
 
380
UNIQUE _field_72 (_field_72),
 
381
KEY _field_115 (_field_115),
 
382
KEY _field_122 (_field_122)
 
383
);
 
384
INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
 
385
INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
 
386
INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
 
387
CREATE TABLE t2 (
 
388
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
 
389
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
 
390
PRIMARY KEY (seq_0_id,seq_1_id)
 
391
);
 
392
INSERT INTO t2 VALUES (1,1);
 
393
INSERT INTO t2 VALUES (2,1);
 
394
INSERT INTO t2 VALUES (2,2);
 
395
CREATE TABLE t3 (
 
396
t3_id bigint(21) NOT NULL auto_increment,
 
397
_field_131 varchar(128),
 
398
_field_133 tinyint(4) DEFAULT '0' NOT NULL,
 
399
_field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
 
400
_field_137 tinyint(4),
 
401
_field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
 
402
_field_140 blob,
 
403
_field_142 tinyint(4) DEFAULT '0' NOT NULL,
 
404
_field_145 tinyint(4) DEFAULT '0' NOT NULL,
 
405
_field_148 tinyint(4) DEFAULT '0' NOT NULL,
 
406
PRIMARY KEY (t3_id),
 
407
KEY _field_133 (_field_133),
 
408
KEY _field_135 (_field_135),
 
409
KEY _field_139 (_field_139),
 
410
KEY _field_142 (_field_142),
 
411
KEY _field_145 (_field_145),
 
412
KEY _field_148 (_field_148)
 
413
);
 
414
INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
 
415
INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
 
416
CREATE TABLE t4 (
 
417
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
 
418
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
 
419
PRIMARY KEY (seq_0_id,seq_1_id)
 
420
);
 
421
INSERT INTO t4 VALUES (1,1);
 
422
INSERT INTO t4 VALUES (2,1);
 
423
CREATE TABLE t5 (
 
424
t5_id bigint(21) NOT NULL auto_increment,
 
425
_field_149 tinyint(4),
 
426
_field_156 varchar(128) DEFAULT '' NOT NULL,
 
427
_field_157 varchar(128) DEFAULT '' NOT NULL,
 
428
_field_158 varchar(128) DEFAULT '' NOT NULL,
 
429
_field_159 varchar(128) DEFAULT '' NOT NULL,
 
430
_field_160 varchar(128) DEFAULT '' NOT NULL,
 
431
_field_161 varchar(128) DEFAULT '' NOT NULL,
 
432
PRIMARY KEY (t5_id),
 
433
KEY _field_156 (_field_156),
 
434
KEY _field_157 (_field_157),
 
435
KEY _field_158 (_field_158),
 
436
KEY _field_159 (_field_159),
 
437
KEY _field_160 (_field_160),
 
438
KEY _field_161 (_field_161)
 
439
);
 
440
INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
 
441
INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
 
442
CREATE TABLE t6 (
 
443
seq_0_id bigint(21) DEFAULT '0' NOT NULL,
 
444
seq_1_id bigint(21) DEFAULT '0' NOT NULL,
 
445
PRIMARY KEY (seq_0_id,seq_1_id)
 
446
);
 
447
INSERT INTO t6 VALUES (1,1);
 
448
INSERT INTO t6 VALUES (1,2);
 
449
INSERT INTO t6 VALUES (2,2);
 
450
CREATE TABLE t7 (
 
451
t7_id bigint(21) NOT NULL auto_increment,
 
452
_field_143 tinyint(4),
 
453
_field_165 varchar(32),
 
454
_field_166 smallint(6) DEFAULT '0' NOT NULL,
 
455
PRIMARY KEY (t7_id),
 
456
KEY _field_166 (_field_166)
 
457
);
 
458
INSERT INTO t7 VALUES (1,0,'High',1);
 
459
INSERT INTO t7 VALUES (2,0,'Medium',2);
 
460
INSERT INTO t7 VALUES (3,0,'Low',3);
 
461
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;
 
462
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_id
 
463
test^M
 
464
job^M
 
465
1       1       test job 1      0000-00-00 00:00:00     1999-02-25 22:43:32     0       High    admin   0       tomato  test^M
 
466
job^M
 
467
1       1
 
468
drop table t1,t2,t3,t4,t5,t6,t7;
 
469
create table t1 (a blob);
 
470
insert into t1 values ("empty"),("");
 
471
select a,reverse(a) from t1;
 
472
a       reverse(a)
 
473
empty   ytpme
 
474
        
 
475
drop table t1;
 
476
create table t1 (a blob, key (a(10)));
 
477
insert into t1 values ("bye"),("hello"),("hello"),("hello word");
 
478
select * from t1 where a like "hello%";
 
479
a
 
480
hello
 
481
hello
 
482
hello word
 
483
drop table t1;
 
484
CREATE TABLE t1 (
 
485
f1 int(11) DEFAULT '0' NOT NULL,
 
486
f2 varchar(16) DEFAULT '' NOT NULL,
 
487
f5 text,
 
488
KEY index_name (f1,f2,f5(16))
 
489
);
 
490
INSERT INTO t1 VALUES (0,'traktor','1111111111111');
 
491
INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111');
 
492
select count(*) from t1 where f2='traktor';
 
493
count(*)
 
494
2
 
495
drop table t1;
 
496
create table t1 (foobar tinyblob not null, boggle smallint not null, key (foobar(32), boggle));
 
497
insert into t1 values ('fish', 10),('bear', 20);
 
498
select foobar, boggle from t1 where foobar = 'fish';
 
499
foobar  boggle
 
500
fish    10
 
501
select foobar, boggle from t1 where foobar = 'fish' and boggle = 10;
 
502
foobar  boggle
 
503
fish    10
 
504
drop table t1;
 
505
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default '');
 
506
Warnings:
 
507
Warning 1101    BLOB/TEXT column 'imagem' can't have a default value
 
508
insert into t1 (id) values (1);
 
509
select
 
510
charset(load_file('../std_data_ln/words.dat')),
 
511
collation(load_file('../std_data_ln/words.dat')),
 
512
coercibility(load_file('../std_data_ln/words.dat'));
 
513
charset(load_file('../std_data_ln/words.dat'))  collation(load_file('../std_data_ln/words.dat'))        coercibility(load_file('../std_data_ln/words.dat'))
 
514
binary  binary  4
 
515
explain extended select
 
516
charset(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')),
 
517
collation(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')),
 
518
coercibility(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'));
 
519
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
520
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
521
Warnings:
 
522
Note    1003    select charset(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `charset(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`,collation(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `collation(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`,coercibility(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat')) AS `coercibility(load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat'))`
 
523
update t1 set imagem=load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat') where id=1;
 
524
select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
 
525
if(imagem is null, "ERROR", "OK")       length(imagem)
 
526
OK      581
 
527
drop table t1;
 
528
create table t1 select load_file('MYSQLTEST_VARDIR/std_data_ln/words.dat') l;
 
529
show full fields from t1;
 
530
Field   Type    Collation       Null    Key     Default Extra   Privileges      Comment
 
531
l       longblob        NULL    YES             NULL            #       
 
532
drop table t1;
 
533
create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20)));
 
534
insert into t1 (txt) values ('Chevy'), ('Chevy ');
 
535
ERROR 23000: Duplicate entry 'Chevy ' for key 'txt_index'
 
536
insert into t1 (txt) values ('Chevy'), ('CHEVY');
 
537
ERROR 23000: Duplicate entry 'Chevy' for key 'txt_index'
 
538
alter table t1 drop index txt_index, add index txt_index (txt(20));
 
539
insert into t1 (txt) values ('Chevy ');
 
540
select * from t1 where txt='Chevy';
 
541
id      txt
 
542
1       Chevy
 
543
2       Chevy 
 
544
select * from t1 where txt='Chevy ';
 
545
id      txt
 
546
1       Chevy
 
547
2       Chevy 
 
548
select * from t1 where txt='Chevy ' or txt='Chevy';
 
549
id      txt
 
550
1       Chevy
 
551
2       Chevy 
 
552
select * from t1 where txt='Chevy' or txt='Chevy ';
 
553
id      txt
 
554
1       Chevy
 
555
2       Chevy 
 
556
select * from t1 where id='1' or id='2';
 
557
id      txt
 
558
1       Chevy
 
559
2       Chevy 
 
560
insert into t1 (txt) values('Ford');
 
561
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
 
562
id      txt
 
563
1       Chevy
 
564
2       Chevy 
 
565
3       Ford
 
566
select * from t1 where txt='Chevy' or txt='Chevy ';
 
567
id      txt
 
568
1       Chevy
 
569
2       Chevy 
 
570
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
 
571
id      txt
 
572
1       Chevy
 
573
2       Chevy 
 
574
select * from t1 where txt in ('Chevy ','Chevy');
 
575
id      txt
 
576
1       Chevy
 
577
2       Chevy 
 
578
select * from t1 where txt in ('Chevy');
 
579
id      txt
 
580
1       Chevy
 
581
2       Chevy 
 
582
select * from t1 where txt between 'Chevy' and 'Chevy';
 
583
id      txt
 
584
1       Chevy
 
585
2       Chevy 
 
586
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
 
587
id      txt
 
588
1       Chevy
 
589
2       Chevy 
 
590
select * from t1 where txt between 'Chevy' and 'Chevy ';
 
591
id      txt
 
592
1       Chevy
 
593
2       Chevy 
 
594
select * from t1 where txt < 'Chevy ';
 
595
id      txt
 
596
select * from t1 where txt <= 'Chevy';
 
597
id      txt
 
598
1       Chevy
 
599
2       Chevy 
 
600
select * from t1 where txt > 'Chevy';
 
601
id      txt
 
602
3       Ford
 
603
select * from t1 where txt >= 'Chevy';
 
604
id      txt
 
605
1       Chevy
 
606
2       Chevy 
 
607
3       Ford
 
608
drop table t1;
 
609
create table t1 (id integer primary key auto_increment, txt text, index txt_index (txt (20)));
 
610
insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
 
611
select * from t1 where txt='Chevy' or txt is NULL;
 
612
id      txt
 
613
1       Chevy
 
614
2       Chevy 
 
615
3       NULL
 
616
explain select * from t1 where txt='Chevy' or txt is NULL;
 
617
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
618
1       SIMPLE  t1      ref_or_null     txt_index       txt_index       23      const   2       Using where
 
619
select * from t1 where txt='Chevy ';
 
620
id      txt
 
621
1       Chevy
 
622
2       Chevy 
 
623
select * from t1 where txt='Chevy ' or txt='Chevy';
 
624
id      txt
 
625
1       Chevy
 
626
2       Chevy 
 
627
select * from t1 where txt='Chevy' or txt='Chevy ';
 
628
id      txt
 
629
1       Chevy
 
630
2       Chevy 
 
631
select * from t1 where id='1' or id='2';
 
632
id      txt
 
633
1       Chevy
 
634
2       Chevy 
 
635
insert into t1 (txt) values('Ford');
 
636
select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford';
 
637
id      txt
 
638
1       Chevy
 
639
2       Chevy 
 
640
4       Ford
 
641
select * from t1 where txt='Chevy' or txt='Chevy ';
 
642
id      txt
 
643
1       Chevy
 
644
2       Chevy 
 
645
select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy';
 
646
id      txt
 
647
1       Chevy
 
648
2       Chevy 
 
649
select * from t1 where txt in ('Chevy ','Chevy');
 
650
id      txt
 
651
1       Chevy
 
652
2       Chevy 
 
653
select * from t1 where txt in ('Chevy');
 
654
id      txt
 
655
1       Chevy
 
656
2       Chevy 
 
657
select * from t1 where txt between 'Chevy' and 'Chevy';
 
658
id      txt
 
659
1       Chevy
 
660
2       Chevy 
 
661
select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy ';
 
662
id      txt
 
663
1       Chevy
 
664
2       Chevy 
 
665
select * from t1 where txt between 'Chevy' and 'Chevy ';
 
666
id      txt
 
667
1       Chevy
 
668
2       Chevy 
 
669
select * from t1 where txt < 'Chevy ';
 
670
id      txt
 
671
select * from t1 where txt < 'Chevy ' or txt is NULL;
 
672
id      txt
 
673
3       NULL
 
674
select * from t1 where txt <= 'Chevy';
 
675
id      txt
 
676
1       Chevy
 
677
2       Chevy 
 
678
select * from t1 where txt > 'Chevy';
 
679
id      txt
 
680
4       Ford
 
681
select * from t1 where txt >= 'Chevy';
 
682
id      txt
 
683
1       Chevy
 
684
2       Chevy 
 
685
4       Ford
 
686
alter table t1 modify column txt blob;
 
687
explain select * from t1 where txt='Chevy' or txt is NULL;
 
688
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
689
1       SIMPLE  t1      ref_or_null     txt_index       txt_index       23      const   2       Using where
 
690
select * from t1 where txt='Chevy' or txt is NULL;
 
691
id      txt
 
692
1       Chevy
 
693
3       NULL
 
694
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
 
695
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
696
1       SIMPLE  t1      ref_or_null     txt_index       txt_index       23      const   2       Using where; Using filesort
 
697
select * from t1 where txt='Chevy' or txt is NULL order by txt;
 
698
id      txt
 
699
3       NULL
 
700
1       Chevy
 
701
drop table t1;
 
702
CREATE TABLE t1 ( i int(11) NOT NULL default '0',    c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY  (i), KEY (c(1),d));
 
703
INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,'');
 
704
select max(i) from t1 where c = '';
 
705
max(i)
 
706
4
 
707
drop table t1;
 
708
create table t1 (a int, b int, c tinyblob, d int, e int);
 
709
alter table t1 add primary key (a,b,c(255),d);
 
710
alter table t1 add key (a,b,d,e);
 
711
show create table t1;
 
712
Table   Create Table
 
713
t1      CREATE TABLE `t1` (
 
714
  `a` int(11) NOT NULL DEFAULT '0',
 
715
  `b` int(11) NOT NULL DEFAULT '0',
 
716
  `c` tinyblob NOT NULL,
 
717
  `d` int(11) NOT NULL DEFAULT '0',
 
718
  `e` int(11) DEFAULT NULL,
 
719
  PRIMARY KEY (`a`,`b`,`c`(255),`d`),
 
720
  KEY `a` (`a`,`b`,`d`,`e`)
 
721
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
722
drop table t1;
 
723
CREATE table t1 (a blob);
 
724
insert into t1 values ('b'),('a\0'),('a'),('a '),('aa'),(NULL);
 
725
select hex(a) from t1 order by a;
 
726
hex(a)
 
727
NULL
 
728
61
 
729
6100
 
730
6120
 
731
6161
 
732
62
 
733
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
 
734
b
 
735
NULL
 
736
6100
 
737
610000
 
738
612000
 
739
616100
 
740
6200
 
741
alter table t1 modify a varbinary(5);
 
742
select hex(a) from t1 order by a;
 
743
hex(a)
 
744
NULL
 
745
61
 
746
6100
 
747
6120
 
748
6161
 
749
62
 
750
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
 
751
b
 
752
NULL
 
753
6100
 
754
610000
 
755
612000
 
756
616100
 
757
6200
 
758
alter table t1 modify a char(5);
 
759
select hex(a) from t1 order by a;
 
760
hex(a)
 
761
NULL
 
762
6100
 
763
61
 
764
61
 
765
6161
 
766
62
 
767
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
 
768
b
 
769
NULL
 
770
610000
 
771
6100
 
772
6100
 
773
616100
 
774
6200
 
775
alter table t1 modify a binary(5);
 
776
select hex(a) from t1 order by a;
 
777
hex(a)
 
778
NULL
 
779
6100000000
 
780
6100000000
 
781
6100000000
 
782
6161000000
 
783
6200000000
 
784
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
 
785
b
 
786
NULL
 
787
610000000000
 
788
610000000000
 
789
610000000000
 
790
616100000000
 
791
620000000000
 
792
drop table t1;
 
793
create table t1 (a text default '');
 
794
Warnings:
 
795
Warning 1101    BLOB/TEXT column 'a' can't have a default value
 
796
show create table t1;
 
797
Table   Create Table
 
798
t1      CREATE TABLE `t1` (
 
799
  `a` text
 
800
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
801
insert into t1 values (default);
 
802
select * from t1;
 
803
a
 
804
NULL
 
805
drop table t1;
 
806
set @@sql_mode='TRADITIONAL';
 
807
create table t1 (a text default '');
 
808
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
 
809
set @@sql_mode='';
 
810
CREATE TABLE t (c TEXT CHARSET ASCII);
 
811
INSERT INTO t (c) VALUES (REPEAT('1',65537));
 
812
Warnings:
 
813
Warning 1265    Data truncated for column 'c' at row 1
 
814
INSERT INTO t (c) VALUES (REPEAT('2',65536));
 
815
Warnings:
 
816
Warning 1265    Data truncated for column 'c' at row 1
 
817
INSERT INTO t (c) VALUES (REPEAT('3',65535));
 
818
SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
 
819
LENGTH(c)       CHAR_LENGTH(c)
 
820
65535   65535
 
821
65535   65535
 
822
65535   65535
 
823
DROP TABLE t;
 
824
End of 5.0 tests