~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to mysql-test/t/binary.test

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
Virgin 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# test sort,min and max on binary fields
 
3
#
 
4
--disable_warnings
 
5
drop table if exists t1,t2;
 
6
--enable_warnings
 
7
 
 
8
create table t1 (name char(20) not null, primary key (name));
 
9
create table t2 (name char(20) binary not null, primary key (name));
 
10
insert into t1 values ("�");
 
11
insert into t1 values ("�");
 
12
insert into t1 values ("�");
 
13
insert into t2 select * from t1;
 
14
 
 
15
select * from t1 order by name;
 
16
select concat("*",name,"*") from t1 order by 1;
 
17
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
 
18
select * from t2 order by name;
 
19
select concat("*",name,"*") from t2 order by 1;
 
20
select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
 
21
select name from t1 where name between '�' and '�';
 
22
select name from t2 where name between '�' and '�';
 
23
select name from t2 where name between '�' and '�';
 
24
 
 
25
drop table t1,t2;
 
26
 
 
27
#
 
28
# Test of binary and normal strings
 
29
#
 
30
 
 
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 ");
 
33
select concat("-",a,"-",b,"-") from t1 where a="hello";
 
34
select concat("-",a,"-",b,"-") from t1 where a="hello ";
 
35
select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
 
36
select concat("-",a,"-",b,"-") from t1 where b="hello";
 
37
select concat("-",a,"-",b,"-") from t1 where b="hello ";
 
38
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
 
39
# blob test
 
40
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
 
41
select concat("-",a,"-",b,"-") from t1;
 
42
select concat("-",a,"-",b,"-") from t1 where b="hello ";
 
43
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
 
44
drop table t1;
 
45
 
 
46
#
 
47
# Test of binary and NULL
 
48
#
 
49
create table t1 (b char(8));
 
50
insert into t1 values(NULL);
 
51
select b from t1 where binary b like '';
 
52
select b from t1 group by binary b like '';
 
53
select b from t1 having binary b like '';
 
54
drop table t1;
 
55
 
 
56
#
 
57
# Test of binary and upper/lower
 
58
#
 
59
create table t1 (a char(3) binary, b binary(3));
 
60
insert into t1 values ('aaa','bbb'),('AAA','BBB');
 
61
select upper(a),upper(b) from t1;
 
62
select lower(a),lower(b) from t1;
 
63
select * from t1 where upper(a)='AAA';
 
64
select * from t1 where lower(a)='aaa';
 
65
select * from t1 where upper(b)='BBB';
 
66
select * from t1 where lower(b)='bbb';
 
67
select charset(a), charset(b), charset(binary 'ccc') from t1 limit 1;
 
68
select collation(a), collation(b), collation(binary 'ccc') from t1 limit 1;
 
69
drop table t1;
 
70
 
 
71
#
 
72
# Bug5134: WHERE x = 'bar' AND x LIKE BINARY 'bar' returns wrong results
 
73
#
 
74
 
 
75
create table t1( firstname char(20), lastname char(20));
 
76
insert into t1 values ("john","doe"),("John","Doe");
 
77
select * from t1 where firstname='john' and firstname like binary 'john';
 
78
select * from t1 where firstname='john' and binary 'john' = firstname;
 
79
select * from t1 where firstname='john' and firstname = binary 'john';
 
80
select * from t1 where firstname='John' and firstname like binary 'john';
 
81
select * from t1 where firstname='john' and firstname like binary 'John';
 
82
drop table t1;
 
83
 
 
84
#
 
85
# Bug #6552 CHAR column w/o length is legal, BINARY w/o length is not
 
86
#
 
87
create table t1 (a binary);
 
88
show create table t1;
 
89
drop table t1;
 
90
 
 
91
# End of 4.1 tests
 
92
 
 
93
#
 
94
# Bug#16857
 
95
#
 
96
create table t1 (col1 binary(4));
 
97
insert into t1 values ('a'),('a ');
 
98
select hex(col1) from t1;
 
99
alter table t1 modify col1 binary(10);
 
100
select hex(col1) from t1;
 
101
insert into t1 values ('b'),('b ');
 
102
select hex(col1) from t1;
 
103
drop table t1;