~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to mysql-test/r/heap_hash.result

Merge with 4.0.3
Some simple optimzations, more comments and indentation changes.
Add ` around database in 'use database' in binary log.
Moved max_error_count and max_warning_count to variables struct.
Removed SHOW_WARNS_COUNT and SHOW_ERRORS_COUNT calls.
Changed string functions to use character set of first string argument as default return characterset
(Each string function can change the above assumption if needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1;
 
2
create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
 
3
insert into t1 values(1,1),(2,2),(3,3),(4,4);
 
4
delete from t1 where a=1 or a=0;
 
5
show keys from t1;
 
6
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment
 
7
t1      0       PRIMARY 1       a       NULL    NULL    NULL    NULL            HASH    
 
8
select * from t1;
 
9
a       b
 
10
2       2
 
11
3       3
 
12
4       4
 
13
select * from t1 where a=4;
 
14
a       b
 
15
4       4
 
16
update t1 set b=5 where a=4;
 
17
update t1 set b=b+1 where a>=3;
 
18
replace t1 values (3,3);
 
19
select * from t1;
 
20
a       b
 
21
2       2
 
22
3       3
 
23
4       6
 
24
alter table t1 add c int not null, add key using HASH (c,a);
 
25
drop table t1;
 
26
create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
 
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
 
28
delete from t1 where a > 0;
 
29
select * from t1;
 
30
a       b
 
31
drop table t1;
 
32
create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
 
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
 
34
alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
 
35
select * from t1;
 
36
a       b
 
37
1       1
 
38
2       2
 
39
3       3
 
40
4       4
 
41
drop table t1;
 
42
create table t1 (a int not null) type=heap;
 
43
insert into t1 values (869751),(736494),(226312),(802616);
 
44
select * from t1 where a > 736494;
 
45
a
 
46
869751
 
47
802616
 
48
alter table t1 add unique uniq_id using HASH (a);
 
49
select * from t1 where a > 736494;
 
50
a
 
51
869751
 
52
802616
 
53
select * from t1 where a = 736494;
 
54
a
 
55
736494
 
56
select * from t1 where a=869751 or a=736494;
 
57
a
 
58
736494
 
59
869751
 
60
select * from t1 where a in (869751,736494,226312,802616);
 
61
a
 
62
226312
 
63
736494
 
64
802616
 
65
869751
 
66
alter table t1 type=myisam;
 
67
explain select * from t1 where a in (869751,736494,226312,802616);
 
68
table   type    possible_keys   key     key_len ref     rows    Extra
 
69
t1      range   uniq_id uniq_id 4       NULL    4       where used; Using index
 
70
drop table t1;
 
71
create table t1 (x int not null, y int not null, key x  using HASH (x), unique y  using HASH (y))
 
72
type=heap;
 
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
 
74
select * from t1 where x=1;
 
75
x       y
 
76
1       3
 
77
1       1
 
78
select * from t1,t1 as t2 where t1.x=t2.y;
 
79
x       y       x       y
 
80
1       1       1       1
 
81
2       2       2       2
 
82
1       3       1       1
 
83
2       4       2       2
 
84
2       5       2       2
 
85
2       6       2       2
 
86
explain select * from t1,t1 as t2 where t1.x=t2.y;
 
87
table   type    possible_keys   key     key_len ref     rows    Extra
 
88
t1      ALL     x       NULL    NULL    NULL    6       
 
89
t2      eq_ref  y       y       4       t1.x    1       
 
90
drop table t1;
 
91
create table t1 (a int) type=heap;
 
92
insert into t1 values(1);
 
93
select max(a) from t1;
 
94
max(a)
 
95
1
 
96
drop table t1;
 
97
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key  using HASH (a),  key  using HASH (b)  ) TYPE=HEAP;
 
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
99
select * from t1 where a=1;
 
100
a       b
 
101
1       6
 
102
1       5
 
103
1       4
 
104
1       3
 
105
1       2
 
106
1       1
 
107
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
108
select * from t1 where a=1;
 
109
a       b
 
110
1       6
 
111
1       5
 
112
1       4
 
113
1       3
 
114
1       2
 
115
1       1
 
116
1       6
 
117
1       5
 
118
1       4
 
119
1       3
 
120
1       2
 
121
1       1
 
122
drop table t1;
 
123
create table t1 (id int unsigned not null, primary key  using HASH (id)) type=HEAP;
 
124
insert into t1 values(1);
 
125
select max(id) from t1;
 
126
max(id)
 
127
1
 
128
insert into t1 values(2);
 
129
select max(id) from t1;
 
130
max(id)
 
131
2
 
132
replace into t1 values(1);
 
133
drop table t1;
 
134
create table t1 (n int) type=heap;
 
135
drop table t1;
 
136
create table t1 (n int) type=heap;
 
137
drop table if exists t1;
 
138
CREATE table t1(f1 int not null,f2 char(20) not 
 
139
null,index(f2)) type=heap;
 
140
INSERT into t1 set f1=12,f2="bill";
 
141
INSERT into t1 set f1=13,f2="bill";
 
142
INSERT into t1 set f1=14,f2="bill";
 
143
INSERT into t1 set f1=15,f2="bill";
 
144
INSERT into t1 set f1=16,f2="ted";
 
145
INSERT into t1 set f1=12,f2="ted";
 
146
INSERT into t1 set f1=12,f2="ted";
 
147
INSERT into t1 set f1=12,f2="ted";
 
148
INSERT into t1 set f1=12,f2="ted";
 
149
delete from t1 where f2="bill";
 
150
select * from t1;
 
151
f1      f2
 
152
16      ted
 
153
12      ted
 
154
12      ted
 
155
12      ted
 
156
12      ted
 
157
drop table t1;
 
158
create table t1 (btn char(10) not null, key using HASH (btn)) type=heap;
 
159
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
 
160
explain select * from t1 where btn like "q%";
 
161
table   type    possible_keys   key     key_len ref     rows    Extra
 
162
t1      ALL     btn     NULL    NULL    NULL    14      where used
 
163
select * from t1 where btn like "q%";
 
164
btn
 
165
alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
 
166
update t1 set new_col=btn;
 
167
explain select * from t1 where btn="a";
 
168
table   type    possible_keys   key     key_len ref     rows    Extra
 
169
t1      ALL     btn     NULL    NULL    NULL    14      where used
 
170
explain select * from t1 where btn="a" and new_col="a";
 
171
table   type    possible_keys   key     key_len ref     rows    Extra
 
172
t1      ref     btn     btn     11      const,const     10      where used
 
173
drop table t1;
 
174
CREATE TABLE t1 (
 
175
a int default NULL,
 
176
b int default NULL,
 
177
KEY a using HASH (a),
 
178
UNIQUE b using HASH (b)
 
179
) type=heap;
 
180
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
 
181
SELECT * FROM t1 WHERE a=NULL;
 
182
a       b
 
183
explain SELECT * FROM t1 WHERE a IS NULL;
 
184
table   type    possible_keys   key     key_len ref     rows    Extra
 
185
t1      ref     a       a       5       const   10      where used
 
186
SELECT * FROM t1 WHERE a<=>NULL;
 
187
a       b
 
188
NULL    99
 
189
SELECT * FROM t1 WHERE b=NULL;
 
190
a       b
 
191
explain SELECT * FROM t1 WHERE b IS NULL;
 
192
table   type    possible_keys   key     key_len ref     rows    Extra
 
193
t1      ref     b       b       5       const   1       where used
 
194
SELECT * FROM t1 WHERE b<=>NULL;
 
195
a       b
 
196
99      NULL
 
197
INSERT INTO t1 VALUES (1,3);
 
198
Duplicate entry '3' for key 1
 
199
DROP TABLE t1;
 
200
CREATE TABLE t1 (a int not null, primary key using HASH (a)) type=heap;
 
201
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
 
202
DELETE from t1 where a < 100;
 
203
SELECT * from t1;
 
204
a
 
205
DROP TABLE t1;