~drizzle-trunk/drizzle/development

1 by brian
clean slate
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;
104
105
#
106
# Bug #29087: assertion abort for a search in a BINARY non-nullable index 
107
#             by a key with trailing spaces 
108
#
109
110
CREATE TABLE t1 (
111
  a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 
112
  index idx(a)
113
);
114
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575');
115
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
116
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707');
117
118
SELECT hex(a) FROM t1 order by a;
119
EXPLAIN SELECT hex(a) FROM t1 order by a;
120
121
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
122
EXPLAIN
123
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
124
125
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908');
126
127
DROP TABLE t1;
128
129
CREATE TABLE t1 (
130
  id numeric(20) NOT NULL,
131
  lang varchar(8) NOT NULL,
132
  msg varchar(32) NOT NULL,
133
  PRIMARY KEY (id,lang)
134
);
135
INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz');
136
INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx');
137
INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy');
138
SELECT * FROM t1 WHERE id=32;
139
140
DROP TABLE t1;
141