~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
685.2.2 by Monty Taylor
Fixed binary.
8
# Conflicts between å and ä. Bug#308841
9
#create table t1 (name char(20) not null, primary key (name));
10
#create table t2 (name char(20) binary not null, primary key (name));
11
#insert into t1 values ("å");
12
#insert into t1 values ("ä");
13
#insert into t1 values ("ö");
14
#insert into t2 select * from t1;
15
#
16
#select * from t1 order by name;
17
#select concat("*",name,"*") from t1 order by 1;
18
#select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
19
#select * from t2 order by name;
20
#select concat("*",name,"*") from t2 order by 1;
21
#select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
22
#select name from t1 where name between 'Ä' and 'Ö';
23
#select name from t2 where name between 'ä' and 'ö';
24
#select name from t2 where name between 'Ä' and 'Ö';
25
#
26
#drop table t1,t2;
1 by brian
clean slate
27
28
#
29
# Test of binary and normal strings
30
#
31
32
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
33
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
34
select concat("-",a,"-",b,"-") from t1 where a="hello";
35
select concat("-",a,"-",b,"-") from t1 where a="hello ";
36
select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
37
select concat("-",a,"-",b,"-") from t1 where b="hello";
38
select concat("-",a,"-",b,"-") from t1 where b="hello ";
39
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
40
# blob test
41
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
42
select concat("-",a,"-",b,"-") from t1;
43
select concat("-",a,"-",b,"-") from t1 where b="hello ";
44
select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
45
drop table t1;
46
47
#
48
# Test of binary and NULL
49
#
50
create table t1 (b char(8));
51
insert into t1 values(NULL);
52
select b from t1 where binary b like '';
53
select b from t1 group by binary b like '';
54
select b from t1 having binary b like '';
55
drop table t1;
56
57
#
58
# Test of binary and upper/lower
59
#
685.2.2 by Monty Taylor
Fixed binary.
60
create table t1 (a char(3) binary, b varbinary(3));
1 by brian
clean slate
61
insert into t1 values ('aaa','bbb'),('AAA','BBB');
62
select upper(a),upper(b) from t1;
63
select lower(a),lower(b) from t1;
64
select * from t1 where upper(a)='AAA';
65
select * from t1 where lower(a)='aaa';
66
select * from t1 where upper(b)='BBB';
67
select * from t1 where lower(b)='bbb';
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
#
685.2.2 by Monty Taylor
Fixed binary.
87
create table t1 (a char);
1 by brian
clean slate
88
show create table t1;
89
drop table t1;
685.2.2 by Monty Taylor
Fixed binary.
90
--error 1064
91
create table t2 (a varbinary);
1 by brian
clean slate
92
93
# End of 4.1 tests
94
95
#
96
# Bug#16857
97
#
685.2.2 by Monty Taylor
Fixed binary.
98
create table t1 (col1 char(4));
1 by brian
clean slate
99
insert into t1 values ('a'),('a ');
100
select hex(col1) from t1;
685.2.2 by Monty Taylor
Fixed binary.
101
alter table t1 modify col1 char(10);
1 by brian
clean slate
102
select hex(col1) from t1;
103
insert into t1 values ('b'),('b ');
104
select hex(col1) from t1;
105
drop table t1;
106
107
#
108
# Bug #29087: assertion abort for a search in a BINARY non-nullable index 
109
#             by a key with trailing spaces 
110
#
111
112
CREATE TABLE t1 (
685.2.2 by Monty Taylor
Fixed binary.
113
  a varbinary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 
1 by brian
clean slate
114
  index idx(a)
115
);
116
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575');
117
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
118
INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707');
119
120
SELECT hex(a) FROM t1 order by a;
121
EXPLAIN SELECT hex(a) FROM t1 order by a;
122
123
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
124
EXPLAIN
125
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
126
127
SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908');
128
129
DROP TABLE t1;
130
131
CREATE TABLE t1 (
132
  id numeric(20) NOT NULL,
133
  lang varchar(8) NOT NULL,
134
  msg varchar(32) NOT NULL,
135
  PRIMARY KEY (id,lang)
136
);
137
INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz');
138
INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx');
139
INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy');
140
SELECT * FROM t1 WHERE id=32;
141
142
DROP TABLE t1;
143