1
drop table if exists t1;
2
select 'a' = 'a', 'a' = 'a ', 'a ' = 'a';
3
'a' = 'a' 'a' = 'a ' 'a ' = 'a'
5
select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a';
6
'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a'
8
select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0';
9
'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0'
11
select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a ';
12
'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a '
14
select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0';
15
'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0'
17
select 'a a' > 'a', 'a \0' < 'a';
18
'a a' > 'a' 'a \0' < 'a'
20
select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a';
21
binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a'
23
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1));
24
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
26
Table Op Msg_type Msg_text
27
test.t1 check status OK
28
select * from t1 ignore key (key1) where text1='teststring' or
29
text1 like 'teststring_%' ORDER BY text1;
33
select * from t1 where text1='teststring' or text1 like 'teststring_%';
37
select * from t1 where text1='teststring' or text1 > 'teststring\t';
40
select * from t1 order by text1;
45
explain select * from t1 order by text1;
46
id select_type table type possible_keys key key_len ref rows Extra
47
1 SIMPLE t1 index NULL key1 34 NULL 3 Using index
48
alter table t1 modify text1 char(32) binary not null;
50
Table Op Msg_type Msg_text
51
test.t1 check status OK
52
select * from t1 ignore key (key1) where text1='teststring' or
53
text1 like 'teststring_%' ORDER BY text1;
57
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
58
concat('|', text1, '|')
61
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
62
concat('|', text1, '|')
64
select text1, length(text1) from t1 order by text1;
69
select text1, length(text1) from t1 order by binary text1;
74
alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20));
75
insert into t1 values ('teststring ');
76
select concat('|', text1, '|') from t1 order by text1;
77
concat('|', text1, '|')
82
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
83
concat('|', text1, '|')
86
select concat('|', text1, '|') from t1 where text1='teststring';
87
concat('|', text1, '|')
89
select concat('|', text1, '|') from t1 where text1='teststring ';
90
concat('|', text1, '|')
92
alter table t1 modify text1 text not null, pack_keys=1;
93
select concat('|', text1, '|') from t1 where text1='teststring';
94
concat('|', text1, '|')
97
select concat('|', text1, '|') from t1 where text1='teststring ';
98
concat('|', text1, '|')
101
explain select concat('|', text1, '|') from t1 where text1='teststring ';
102
id select_type table type possible_keys key key_len ref rows Extra
103
1 SIMPLE t1 ref key1 key1 22 const 2 Using where
104
select concat('|', text1, '|') from t1 where text1 like 'teststring_%';
105
concat('|', text1, '|')
108
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
109
concat('|', text1, '|')
113
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
114
concat('|', text1, '|')
117
select concat('|', text1, '|') from t1 order by text1;
118
concat('|', text1, '|')
124
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) pack_keys=0;
125
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
126
select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
127
concat('|', text1, '|')
130
select concat('|', text1, '|') from t1 where text1='teststring' or text1 >= 'teststring\t';
131
concat('|', text1, '|')
135
create table t1 (text1 varchar(32) not NULL, KEY key1 using BTREE (text1)) engine=heap;
136
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
137
select * from t1 ignore key (key1) where text1='teststring' or
138
text1 like 'teststring_%' ORDER BY text1;
142
select * from t1 where text1='teststring' or text1 like 'teststring_%';
146
select * from t1 where text1='teststring' or text1 >= 'teststring\t';
150
select * from t1 order by text1;
155
explain select * from t1 order by text1;
156
id select_type table type possible_keys key key_len ref rows Extra
157
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
158
alter table t1 modify text1 char(32) binary not null;
159
select * from t1 order by text1;
165
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb;
166
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
168
Table Op Msg_type Msg_text
169
test.t1 check status OK
170
select * from t1 where text1='teststring' or text1 like 'teststring_%';
174
select * from t1 where text1='teststring' or text1 > 'teststring\t';
177
select * from t1 order by text1;
182
explain select * from t1 order by text1;
183
id select_type table type possible_keys key key_len ref rows Extra
184
1 SIMPLE t1 index NULL key1 34 NULL 3 Using index
185
alter table t1 modify text1 char(32) binary not null;
186
select * from t1 order by text1;
191
alter table t1 modify text1 blob not null, drop key key1, add key key1 (text1(20));
192
insert into t1 values ('teststring ');
193
select concat('|', text1, '|') from t1 order by text1;
194
concat('|', text1, '|')
199
alter table t1 modify text1 text not null, pack_keys=1;
200
select * from t1 where text1 like 'teststring_%';
204
select text1, length(text1) from t1 where text1='teststring' or text1 like 'teststring_%';
209
select text1, length(text1) from t1 where text1='teststring' or text1 >= 'teststring\t';
214
select concat('|', text1, '|') from t1 order by text1;
215
concat('|', text1, '|')