~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/heap_btree.result

Reverted 1103

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1;
2
 
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=MEMORY comment="testing heaps";
 
2
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
3
3
insert into t1 values(1,1),(2,2),(3,3),(4,4);
4
4
delete from t1 where a=1 or a=0;
5
 
show table status like "t1";
6
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
7
 
#       test    t1      TEMPORARY       MEMORY  #       #       #       #       #
8
5
show keys from t1;
9
 
Table   Unique  Key_name        Seq_in_index    Column_name
10
 
t1      YES     PRIMARY 1       a
 
6
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
7
t1      0       PRIMARY 1       a       A       NULL    NULL    NULL            BTREE           
11
8
select * from t1;
12
9
a       b
13
10
2       2
24
21
2       2
25
22
3       3
26
23
4       6
27
 
alter table t1 add c int DEFAULT 42 not null, add key using BTREE (c,a);
 
24
alter table t1 add c int not null, add key using BTREE (c,a);
28
25
drop table t1;
29
 
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=MEMORY comment="testing heaps";
 
26
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
30
27
insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
31
28
delete from t1 where a > -3;
32
29
select * from t1;
33
30
a       b
34
31
drop table t1;
35
 
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=MEMORY comment="testing heaps";
 
32
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
36
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
37
34
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
38
 
show table status like "t1";
39
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
40
 
#       test    t1      TEMPORARY       InnoDB  #       #       #       #       #
41
35
select * from t1;
42
36
a       b
43
37
1       1
45
39
3       3
46
40
4       4
47
41
drop table t1;
48
 
create temporary table t1 (a int not null) engine=MEMORY;
 
42
create table t1 (a int not null) engine=heap;
49
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
50
44
select * from t1 where a > 736494;
51
45
a
54
48
alter table t1 add unique uniq_id using BTREE (a);
55
49
select * from t1 where a > 736494;
56
50
a
 
51
802616
57
52
869751
58
 
802616
59
53
select * from t1 where a = 736494;
60
54
a
61
55
736494
74
68
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
75
69
1       SIMPLE  t1      index   uniq_id uniq_id 4       NULL    5       Using where; Using index
76
70
drop table t1;
77
 
create temporary table t1 (x int not null, y int not null, key x  using BTREE (x,y), unique y  using BTREE (y))
78
 
engine=MEMORY;
 
71
create table t1 (x int not null, y int not null, key x  using BTREE (x,y), unique y  using BTREE (y))
 
72
engine=heap;
79
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
80
74
explain select * from t1 where x=1;
81
75
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
82
 
1       SIMPLE  t1      ALL     x       NULL    NULL    NULL    6       Using where
 
76
1       SIMPLE  t1      ref     x       x       4       const   1       
83
77
select * from t1 where x=1;
84
78
x       y
85
79
1       1
86
80
1       3
87
81
select * from t1,t1 as t2 where t1.x=t2.y;
88
 
ERROR HY000: Can't reopen table: 't1'
 
82
x       y       x       y
 
83
1       1       1       1
 
84
2       2       2       2
 
85
1       3       1       1
 
86
2       4       2       2
 
87
2       5       2       2
 
88
2       6       2       2
89
89
explain select * from t1,t1 as t2 where t1.x=t2.y;
90
 
ERROR HY000: Can't reopen table: 't1'
 
90
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
91
1       SIMPLE  t1      ALL     x       NULL    NULL    NULL    6       
 
92
1       SIMPLE  t2      eq_ref  y       y       4       test.t1.x       1       
91
93
drop table t1;
92
 
create temporary table t1 (a int) engine=MEMORY;
 
94
create table t1 (a int) engine=heap;
93
95
insert into t1 values(1);
94
96
select max(a) from t1;
95
97
max(a)
96
98
1
97
99
drop table t1;
98
 
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key  using BTREE (a,b),  key  using BTREE (b)  ) ENGINE=MEMORY;
99
 
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
100
 
select * from t1 where a=1;
101
 
a       b
102
 
1       1
103
 
1       2
104
 
1       3
105
 
1       4
106
 
1       5
107
 
1       6
108
 
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
109
 
select * from t1 where a=1;
110
 
a       b
111
 
1       1
112
 
1       2
113
 
1       3
114
 
1       4
115
 
1       5
116
 
1       6
117
 
1       1
118
 
1       2
119
 
1       3
120
 
1       4
121
 
1       5
 
100
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key  using BTREE (a,b),  key  using BTREE (b)  ) ENGINE=HEAP;
 
101
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
102
select * from t1 where a=1;
 
103
a       b
 
104
1       1
 
105
1       2
 
106
1       3
 
107
1       4
 
108
1       5
 
109
1       6
 
110
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
111
select * from t1 where a=1;
 
112
a       b
 
113
1       1
 
114
1       1
 
115
1       2
 
116
1       2
 
117
1       3
 
118
1       3
 
119
1       4
 
120
1       4
 
121
1       5
 
122
1       5
 
123
1       6
122
124
1       6
123
125
explain select * from tx where a=x order by a,b;
124
126
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
125
 
x       SIMPLE  tx      ALL     a       NULL    NULL    NULL    x       Using where; Using filesort
 
127
x       SIMPLE  tx      ref     a       a       x       const   x       Using where
126
128
explain select * from tx where a=x order by b;
127
129
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
128
 
x       SIMPLE  tx      ALL     a       NULL    NULL    NULL    x       Using where; Using filesort
 
130
x       SIMPLE  tx      ref     a       a       x       const   x       Using where
129
131
select * from t1 where b=1;
130
132
a       b
131
133
1       1
134
136
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
135
137
x       SIMPLE  tx      ref     b       b       x       const   x       
136
138
drop table t1;
137
 
create temporary table t1 (id int not null, primary key  using BTREE (id)) engine=MEMORY;
 
139
create table t1 (id int not null, primary key  using BTREE (id)) engine=HEAP;
138
140
insert into t1 values(1);
139
141
select max(id) from t1;
140
142
max(id)
145
147
2
146
148
replace into t1 values(1);
147
149
drop table t1;
148
 
create temporary table t1 (n int) engine=MEMORY;
 
150
create table t1 (n int) engine=heap;
149
151
drop table t1;
150
 
create temporary table t1 (n int) engine=MEMORY;
 
152
create table t1 (n int) engine=heap;
151
153
drop table if exists t1;
152
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
153
 
null,index(f2)) engine=MEMORY;
 
154
CREATE table t1(f1 int not null,f2 char(20) not 
 
155
null,index(f2)) engine=heap;
154
156
INSERT into t1 set f1=12,f2="bill";
155
157
INSERT into t1 set f1=13,f2="bill";
156
158
INSERT into t1 set f1=14,f2="bill";
169
171
12      ted
170
172
12      ted
171
173
drop table t1;
172
 
create temporary table t1 (btn char(10) not null, key using BTREE (btn)) engine=MEMORY;
 
174
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
173
175
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
174
176
explain select * from t1 where btn like "i%";
175
177
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
176
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
178
1       SIMPLE  t1      range   btn     btn     42      NULL    1       Using where
177
179
explain select * from t1 where btn like "h%";
178
180
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
179
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    #       Using where
 
181
1       SIMPLE  t1      range   btn     btn     42      NULL    #       Using where
180
182
explain select * from t1 where btn like "a%";
181
183
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
182
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
184
1       SIMPLE  t1      range   btn     btn     42      NULL    1       Using where
183
185
explain select * from t1 where btn like "b%";
184
186
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
185
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
187
1       SIMPLE  t1      range   btn     btn     42      NULL    1       Using where
186
188
select * from t1 where btn like "ff%";
187
189
btn
188
190
select * from t1 where btn like " %";
189
191
btn
190
192
select * from t1 where btn like "q%";
191
193
btn
192
 
alter table t1 add column new_col char(1) DEFAULT "Y" not null, add key using BTREE (btn,new_col), drop key btn;
 
194
alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn;
193
195
update t1 set new_col=left(btn,1);
194
196
explain select * from t1 where btn="a";
195
197
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
196
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
198
1       SIMPLE  t1      ref     btn     btn     42      const   1       Using where
197
199
explain select * from t1 where btn="a" and new_col="a";
198
200
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
199
 
1       SIMPLE  t1      ref     btn     btn     48      const,const     2       Using where
 
201
1       SIMPLE  t1      ref     btn     btn     48      const,const     1       Using where
200
202
drop table t1;
201
 
CREATE TEMPORARY TABLE t1 (
 
203
CREATE TABLE t1 (
202
204
a int default NULL,
203
205
b int default NULL,
204
206
KEY a using BTREE (a),
205
207
UNIQUE b using BTREE (b)
206
 
) engine=MEMORY;
 
208
) engine=heap;
207
209
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
208
210
SELECT * FROM t1 WHERE a=NULL;
209
211
a       b
210
212
explain SELECT * FROM t1 WHERE a IS NULL;
211
213
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
212
 
1       SIMPLE  t1      ref     a       a       5       const   2       Using where
 
214
1       SIMPLE  t1      ref     a       a       5       const   1       Using where
213
215
SELECT * FROM t1 WHERE a<=>NULL;
214
216
a       b
215
217
NULL    99
224
226
INSERT INTO t1 VALUES (1,3);
225
227
ERROR 23000: Duplicate entry '3' for key 'b'
226
228
DROP TABLE t1;
227
 
CREATE TEMPORARY TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=MEMORY;
 
229
CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap;
228
230
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
229
231
SELECT * FROM t1 WHERE a=1 and b IS NULL;
230
232
a       b       c
238
240
a       b       c
239
241
1       NULL    NULL
240
242
DROP TABLE t1;
241
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key using BTREE (a)) engine=MEMORY;
 
243
CREATE TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap;
242
244
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
243
245
DELETE from t1 where a < 100;
244
246
SELECT * from t1;
245
247
a
246
248
DROP TABLE t1;
247
 
create temporary table t1(a int not null, key using btree(a)) engine=MEMORY;
 
249
create table t1(a int not null, key using btree(a)) engine=heap;
248
250
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
249
251
select a from t1 where a > 2 order by a;
250
252
a
278
280
1
279
281
1
280
282
drop table t1;
281
 
CREATE TEMPORARY TABLE t1 (
 
283
CREATE TABLE t1 (
282
284
c1 CHAR(3),
283
285
c2 INTEGER,
284
286
KEY USING BTREE(c1),
293
295
B       0
294
296
C       0
295
297
DROP TABLE t1;
296
 
CREATE TEMPORARY TABLE t1 (
 
298
CREATE TABLE t1 (
297
299
c1 ENUM('1', '2'),
298
300
UNIQUE USING BTREE(c1)
299
301
) ENGINE= MEMORY;
300
302
INSERT INTO t1 VALUES('1'), ('2');
301
303
DROP TABLE t1;
302
 
CREATE TEMPORARY TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
 
304
CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
303
305
INSERT INTO t1 VALUES(1),(2),(2);
304
306
DELETE FROM t1 WHERE a=2;
305
307
SELECT * FROM t1;
307
309
1
308
310
DROP TABLE t1;
309
311
End of 4.1 tests
310
 
CREATE TEMPORARY TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
 
312
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
 
313
INSERT INTO t1 VALUES(0);
 
314
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
 
315
INDEX_LENGTH
 
316
21
 
317
UPDATE t1 SET val=1;
 
318
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
 
319
INDEX_LENGTH
 
320
21
 
321
DROP TABLE t1;
 
322
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
311
323
INSERT INTO t1 VALUES(NULL),(NULL);
312
324
DROP TABLE t1;
313
 
create temporary table t1(a varchar(255), b varchar(255), 
 
325
create table t1(a varchar(255), b varchar(255), 
314
326
key using btree (a,b)) engine=memory;
315
327
insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0);
316
328
select * from t1 where a is null;
317
329
a       b
 
330
NULL    NULL
318
331
NULL    1
319
 
NULL    NULL
320
332
drop table t1;
321
333
End of 5.0 tests