1
by brian
clean slate |
1 |
# Initialise |
2 |
--disable_warnings |
|
3 |
drop table if exists t1,t2,t3; |
|
4 |
--enable_warnings |
|
5 |
||
6 |
disable_query_log; |
|
7 |
select "--- Testing varchar ---"; |
|
8 |
enable_query_log; |
|
9 |
||
10 |
#
|
|
11 |
# Simple basic test that endspace is saved |
|
12 |
#
|
|
13 |
||
14 |
create table t1 (v varchar(10), c char(10), t text); |
|
15 |
insert into t1 values('+ ', '+ ', '+ '); |
|
16 |
set @a=repeat(' ',20); |
|
17 |
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); |
|
18 |
select concat('*',v,'*',c,'*',t,'*') from t1; |
|
19 |
||
20 |
# Check how columns are copied |
|
21 |
show create table t1; |
|
22 |
create table t2 like t1; |
|
23 |
show create table t2; |
|
24 |
create table t3 select * from t1; |
|
25 |
show create table t3; |
|
26 |
alter table t1 modify c varchar(10); |
|
27 |
show create table t1; |
|
28 |
alter table t1 modify v char(10); |
|
29 |
show create table t1; |
|
30 |
alter table t1 modify t varchar(10); |
|
31 |
show create table t1; |
|
32 |
select concat('*',v,'*',c,'*',t,'*') from t1; |
|
33 |
drop table t1,t2,t3; |
|
34 |
||
35 |
#
|
|
36 |
# Testing of keys |
|
37 |
#
|
|
38 |
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10))); |
|
39 |
show create table t1; |
|
40 |
disable_query_log; |
|
910.4.13
by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker. |
41 |
begin; |
1
by brian
clean slate |
42 |
let $1=10; |
43 |
while ($1) |
|
44 |
{
|
|
45 |
let $2=27; |
|
46 |
eval set @space=repeat(' ',10-$1); |
|
47 |
while ($2) |
|
48 |
{
|
|
49 |
eval set @char=char(ascii('a')+$2-1); |
|
50 |
insert into t1 values(concat(@char,@space),concat(@char,@space),concat(@char,@space)); |
|
51 |
dec $2; |
|
52 |
}
|
|
53 |
dec $1; |
|
54 |
}
|
|
910.4.13
by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker. |
55 |
commit; |
1
by brian
clean slate |
56 |
enable_query_log; |
57 |
select count(*) from t1; |
|
58 |
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); |
|
59 |
select count(*) from t1 where v='a'; |
|
60 |
select count(*) from t1 where c='a'; |
|
61 |
select count(*) from t1 where t='a'; |
|
62 |
select count(*) from t1 where v='a '; |
|
63 |
select count(*) from t1 where c='a '; |
|
64 |
select count(*) from t1 where t='a '; |
|
65 |
select count(*) from t1 where v between 'a' and 'a '; |
|
66 |
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
|
67 |
select count(*) from t1 where v like 'a%'; |
|
68 |
select count(*) from t1 where c like 'a%'; |
|
69 |
select count(*) from t1 where t like 'a%'; |
|
70 |
select count(*) from t1 where v like 'a %'; |
|
71 |
# Test results differ for BDB, see comments in bdb.test |
|
72 |
# and they are also different from MySAM test results. |
|
73 |
--replace_column 9 # |
|
74 |
explain select count(*) from t1 where v='a '; |
|
75 |
--replace_column 9 # |
|
76 |
explain select count(*) from t1 where c='a '; |
|
77 |
--replace_column 9 # |
|
78 |
explain select count(*) from t1 where t='a '; |
|
79 |
--replace_column 9 # |
|
80 |
explain select count(*) from t1 where v like 'a%'; |
|
81 |
--replace_column 9 # |
|
82 |
explain select count(*) from t1 where v between 'a' and 'a '; |
|
83 |
--replace_column 9 # |
|
84 |
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
|
85 |
||
86 |
--error ER_DUP_ENTRY |
|
87 |
alter table t1 add unique(v); |
|
88 |
alter table t1 add key(v); |
|
89 |
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; |
|
90 |
--replace_column 6 # 9 # |
|
91 |
explain select * from t1 where v='a'; |
|
92 |
||
93 |
# GROUP BY |
|
94 |
||
95 |
select v,count(*) from t1 group by v limit 10; |
|
96 |
select v,count(t) from t1 group by v limit 10; |
|
97 |
select v,count(c) from t1 group by v limit 10; |
|
98 |
select sql_big_result v,count(t) from t1 group by v limit 10; |
|
99 |
select sql_big_result v,count(c) from t1 group by v limit 10; |
|
100 |
select c,count(*) from t1 group by c limit 10; |
|
101 |
select c,count(t) from t1 group by c limit 10; |
|
102 |
select sql_big_result c,count(t) from t1 group by c limit 10; |
|
103 |
select t,count(*) from t1 group by t limit 10; |
|
104 |
select t,count(t) from t1 group by t limit 10; |
|
105 |
select sql_big_result t,count(t) from t1 group by t limit 10; |
|
106 |
||
107 |
#
|
|
108 |
# Test varchar > 255 bytes |
|
109 |
#
|
|
110 |
||
111 |
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); |
|
112 |
show create table t1; |
|
113 |
select count(*) from t1 where v='a'; |
|
114 |
select count(*) from t1 where v='a '; |
|
115 |
select count(*) from t1 where v between 'a' and 'a '; |
|
116 |
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
|
117 |
select count(*) from t1 where v like 'a%'; |
|
118 |
select count(*) from t1 where v like 'a %'; |
|
119 |
--replace_column 9 # |
|
120 |
explain select count(*) from t1 where v='a '; |
|
121 |
--replace_column 9 # |
|
122 |
explain select count(*) from t1 where v like 'a%'; |
|
123 |
--replace_column 9 # |
|
124 |
explain select count(*) from t1 where v between 'a' and 'a '; |
|
125 |
--replace_column 9 # |
|
126 |
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
|
127 |
--replace_column 9 # |
|
128 |
explain select * from t1 where v='a'; |
|
129 |
||
130 |
# GROUP BY |
|
131 |
||
132 |
select v,count(*) from t1 group by v limit 10; |
|
133 |
select v,count(t) from t1 group by v limit 10; |
|
134 |
select sql_big_result v,count(t) from t1 group by v limit 10; |
|
135 |
||
136 |
#
|
|
137 |
# Test varchar > 255 bytes, key < 255 |
|
138 |
#
|
|
139 |
||
140 |
alter table t1 drop key v, add key v (v(30)); |
|
141 |
show create table t1; |
|
142 |
select count(*) from t1 where v='a'; |
|
143 |
select count(*) from t1 where v='a '; |
|
144 |
select count(*) from t1 where v between 'a' and 'a '; |
|
145 |
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
|
146 |
select count(*) from t1 where v like 'a%'; |
|
147 |
select count(*) from t1 where v like 'a %'; |
|
148 |
--replace_column 9 # |
|
149 |
explain select count(*) from t1 where v='a '; |
|
150 |
--replace_column 9 # |
|
151 |
explain select count(*) from t1 where v like 'a%'; |
|
152 |
--replace_column 9 # |
|
153 |
explain select count(*) from t1 where v between 'a' and 'a '; |
|
154 |
--replace_column 9 # |
|
155 |
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
|
156 |
--replace_column 9 # |
|
157 |
explain select * from t1 where v='a'; |
|
158 |
||
159 |
# GROUP BY |
|
160 |
||
161 |
select v,count(*) from t1 group by v limit 10; |
|
162 |
select v,count(t) from t1 group by v limit 10; |
|
163 |
select sql_big_result v,count(t) from t1 group by v limit 10; |
|
164 |
||
165 |
#
|
|
166 |
# Test varchar > 512 (special case for GROUP BY becasue of |
|
167 |
# CONVERT_IF_BIGGER_TO_BLOB define) |
|
168 |
#
|
|
169 |
||
170 |
alter table t1 modify v varchar(600), drop key v, add key v (v); |
|
171 |
show create table t1; |
|
172 |
select v,count(*) from t1 group by v limit 10; |
|
173 |
select v,count(t) from t1 group by v limit 10; |
|
174 |
select sql_big_result v,count(t) from t1 group by v limit 10; |
|
175 |
||
176 |
drop table t1; |
|
177 |
||
178 |
#
|
|
179 |
# Test unique keys |
|
180 |
#
|
|
181 |
||
182 |
create table t1 (a char(10), unique (a)); |
|
183 |
insert into t1 values ('a '); |
|
184 |
--error ER_DUP_ENTRY |
|
185 |
insert into t1 values ('a '); |
|
186 |
||
187 |
alter table t1 modify a varchar(10); |
|
188 |
--error ER_DUP_ENTRY |
|
189 |
insert into t1 values ('a '),('a '),('a '),('a '); |
|
190 |
--error ER_DUP_ENTRY |
|
191 |
insert into t1 values ('a '); |
|
192 |
--error ER_DUP_ENTRY |
|
193 |
insert into t1 values ('a '); |
|
194 |
--error ER_DUP_ENTRY |
|
195 |
insert into t1 values ('a '); |
|
196 |
update t1 set a='a ' where a like 'a%'; |
|
197 |
select concat(a,'.') from t1; |
|
198 |
update t1 set a='abc ' where a like 'a '; |
|
199 |
select concat(a,'.') from t1; |
|
200 |
update t1 set a='a ' where a like 'a %'; |
|
201 |
select concat(a,'.') from t1; |
|
202 |
update t1 set a='a ' where a like 'a '; |
|
203 |
select concat(a,'.') from t1; |
|
204 |
drop table t1; |
|
205 |
||
206 |
#
|
|
207 |
# test show create table |
|
208 |
#
|
|
209 |
||
210 |
create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5))); |
|
211 |
show create table t1; |
|
212 |
drop table t1; |
|
685.4.4
by Jay Pipes
Re-enabled and fixed the mix2_myisam test. |
213 |
create table t1 (v char(10)); |
1
by brian
clean slate |
214 |
show create table t1; |
215 |
drop table t1; |
|
216 |
||
217 |
create table t1 (v varchar(10), c char(10)) row_format=fixed; |
|
218 |
show create table t1; |
|
219 |
insert into t1 values('a','a'),('a ','a '); |
|
220 |
select concat('*',v,'*',c,'*') from t1; |
|
221 |
drop table t1; |
|
222 |
||
223 |
#
|
|
224 |
# Test long varchars |
|
225 |
#
|
|
685.4.4
by Jay Pipes
Re-enabled and fixed the mix2_myisam test. |
226 |
# @TODO The below fails because it assumes latin1 |
227 |
# as the charset. Possibly re-enable a similar test |
|
228 |
# for UTF8-only in future |
|
229 |
#create table t1 (v varchar(65530), key(v(10))); |
|
230 |
#insert into t1 values(repeat('a',65530)); |
|
231 |
#select length(v) from t1 where v=repeat('a',65530); |
|
232 |
#drop table t1; |
|
1
by brian
clean slate |
233 |
|
234 |
#
|
|
235 |
# Bug #9489: problem with hash indexes |
|
236 |
# Bug #10802: Index is not used if table using BDB engine on HP-UX |
|
237 |
#
|
|
238 |
||
239 |
create table t1(a int, b varchar(12), key ba(b, a)); |
|
240 |
insert into t1 values (1, 'A'), (20, NULL); |
|
241 |
explain select * from t1 where a=20 and b is null; |
|
242 |
select * from t1 where a=20 and b is null; |
|
243 |
drop table t1; |