binary.test 2.41 KB
Newer Older
1 2 3
#
# test sort,min and max on binary fields
#
4
--disable_warnings
5
drop table if exists t1,t2;
6 7
--enable_warnings

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
create table t1 (name char(20) not null, primary key (name));
create table t2 (name char(20) binary not null, primary key (name));
insert into t1 values ("");
insert into t1 values ("");
insert into t1 values ("");
insert into t2 select * from t1;

select * from t1 order by name;
select concat("*",name,"*") from t1 order by 1;
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
select * from t2 order by name;
select concat("*",name,"*") from t2 order by 1;
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
select name from t1 where name between '' and '';
select name from t2 where name between '' and '';
select name from t2 where name between '' and '';

drop table t1,t2;

#
# Test of binary and normal strings
#

unknown's avatar
unknown committed
31
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
32
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
unknown's avatar
unknown committed
33 34 35 36 37 38
select concat("-",a,"-",b,"-") from t1 where a="hello";
select concat("-",a,"-",b,"-") from t1 where a="hello ";
select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
select concat("-",a,"-",b,"-") from t1 where b="hello";
select concat("-",a,"-",b,"-") from t1 where b="hello ";
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
unknown's avatar
unknown committed
39 40
# blob test
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
41
select concat("-",a,"-",b,"-") from t1;
unknown's avatar
unknown committed
42 43
select concat("-",a,"-",b,"-") from t1 where b="hello ";
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
44
drop table t1;
unknown's avatar
unknown committed
45 46 47 48 49 50 51 52 53 54

#
# Test of binary and NULL
#
create table t1 (b char(8));
insert into t1 values(NULL);
select b from t1 where binary b like '';
select b from t1 group by binary b like '';
select b from t1 having binary b like '';
drop table t1;
unknown's avatar
unknown committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

#
# Test of binary and upper/lower
#
create table t1 (a char(15) binary, b binary(15));
insert into t1 values ('aaa','bbb'),('AAA','BBB');
select upper(a),upper(b) from t1;
select lower(a),lower(b) from t1;
select * from t1 where upper(a)='AAA';
select * from t1 where lower(a)='aaa';
select * from t1 where upper(b)='BBB';
select * from t1 where lower(b)='bbb';
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
drop table t1;