| 1 |
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; |
| 2 |
insert into t1 values(1,1),(2,2),(3,3),(4,4); |
| 3 |
delete from t1 where a=1 or a=0; |
| 4 |
show keys from t1; |
| 5 |
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored |
| 6 |
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH NO |
| 7 |
select * from t1; |
| 8 |
a b |
| 9 |
2 2 |
| 10 |
3 3 |
| 11 |
4 4 |
| 12 |
select * from t1 where a=4; |
| 13 |
a b |
| 14 |
4 4 |
| 15 |
update t1 set b=5 where a=4; |
| 16 |
update t1 set b=b+1 where a>=3; |
| 17 |
replace t1 values (3,3); |
| 18 |
select * from t1; |
| 19 |
a b |
| 20 |
2 2 |
| 21 |
3 3 |
| 22 |
4 6 |
| 23 |
alter table t1 add c int not null, add key using HASH (c,a); |
| 24 |
drop table t1; |
| 25 |
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps"; |
| 26 |
insert into t1 values(1,1),(2,2),(3,3),(4,4); |
| 27 |
delete from t1 where a > 0; |
| 28 |
select * from t1; |
| 29 |
a b |
| 30 |
drop table t1; |
| 31 |
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps"; |
| 32 |
insert into t1 values(1,1),(2,2),(3,3),(4,4); |
| 33 |
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table"; |
| 34 |
select * from t1; |
| 35 |
a b |
| 36 |
1 1 |
| 37 |
2 2 |
| 38 |
3 3 |
| 39 |
4 4 |
| 40 |
drop table t1; |
| 41 |
create table t1 (a int not null) engine=heap; |
| 42 |
insert into t1 values (869751),(736494),(226312),(802616),(728912); |
| 43 |
select * from t1 where a > 736494; |
| 44 |
a |
| 45 |
869751 |
| 46 |
802616 |
| 47 |
alter table t1 add unique uniq_id using HASH (a); |
| 48 |
select * from t1 where a > 736494; |
| 49 |
a |
| 50 |
869751 |
| 51 |
802616 |
| 52 |
select * from t1 where a = 736494; |
| 53 |
a |
| 54 |
736494 |
| 55 |
select * from t1 where a=869751 or a=736494; |
| 56 |
a |
| 57 |
736494 |
| 58 |
869751 |
| 59 |
select * from t1 where a in (869751,736494,226312,802616); |
| 60 |
a |
| 61 |
226312 |
| 62 |
736494 |
| 63 |
802616 |
| 64 |
869751 |
| 65 |
alter table t1 engine=myisam; |
| 66 |
explain select * from t1 where a in (869751,736494,226312,802616); |
| 67 |
id select_type table type possible_keys key key_len ref rows Extra |
| 68 |
1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where |
| 69 |
drop table t1; |
| 70 |
create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y)) |
| 71 |
engine=heap; |
| 72 |
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); |
| 73 |
select * from t1 where x=1; |
| 74 |
x y |
| 75 |
1 3 |
| 76 |
1 1 |
| 77 |
select * from t1,t1 as t2 where t1.x=t2.y; |
| 78 |
x y x y |
| 79 |
1 1 1 1 |
| 80 |
2 2 2 2 |
| 81 |
1 3 1 1 |
| 82 |
2 4 2 2 |
| 83 |
2 5 2 2 |
| 84 |
2 6 2 2 |
| 85 |
explain select * from t1,t1 as t2 where t1.x=t2.y; |
| 86 |
id select_type table type possible_keys key key_len ref rows Extra |
| 87 |
1 SIMPLE t1 ALL x NULL NULL NULL 6 |
| 88 |
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1 |
| 89 |
drop table t1; |
| 90 |
create table t1 (a int) engine=heap; |
| 91 |
insert into t1 values(1); |
| 92 |
select max(a) from t1; |
| 93 |
max(a) |
| 94 |
1 |
| 95 |
drop table t1; |
| 96 |
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) ENGINE=HEAP; |
| 97 |
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); |
| 98 |
select * from t1 where a=1; |
| 99 |
a b |
| 100 |
1 6 |
| 101 |
1 5 |
| 102 |
1 4 |
| 103 |
1 3 |
| 104 |
1 2 |
| 105 |
1 1 |
| 106 |
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); |
| 107 |
select * from t1 where a=1; |
| 108 |
a b |
| 109 |
1 6 |
| 110 |
1 5 |
| 111 |
1 4 |
| 112 |
1 3 |
| 113 |
1 2 |
| 114 |
1 1 |
| 115 |
1 6 |
| 116 |
1 5 |
| 117 |
1 4 |
| 118 |
1 3 |
| 119 |
1 2 |
| 120 |
1 1 |
| 121 |
drop table t1; |
| 122 |
create table t1 (id int unsigned not null, primary key using HASH (id)) engine=HEAP; |
| 123 |
insert into t1 values(1); |
| 124 |
select max(id) from t1; |
| 125 |
max(id) |
| 126 |
1 |
| 127 |
insert into t1 values(2); |
| 128 |
select max(id) from t1; |
| 129 |
max(id) |
| 130 |
2 |
| 131 |
replace into t1 values(1); |
| 132 |
drop table t1; |
| 133 |
create table t1 (n int) engine=heap; |
| 134 |
drop table t1; |
| 135 |
create table t1 (n int) engine=heap; |
| 136 |
drop table if exists t1; |
| 137 |
CREATE table t1(f1 int not null,f2 char(20) not |
| 138 |
null,index(f2)) engine=heap; |
| 139 |
INSERT into t1 set f1=12,f2="bill"; |
| 140 |
INSERT into t1 set f1=13,f2="bill"; |
| 141 |
INSERT into t1 set f1=14,f2="bill"; |
| 142 |
INSERT into t1 set f1=15,f2="bill"; |
| 143 |
INSERT into t1 set f1=16,f2="ted"; |
| 144 |
INSERT into t1 set f1=12,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 |
delete from t1 where f2="bill"; |
| 149 |
select * from t1; |
| 150 |
f1 f2 |
| 151 |
16 ted |
| 152 |
12 ted |
| 153 |
12 ted |
| 154 |
12 ted |
| 155 |
12 ted |
| 156 |
drop table t1; |
| 157 |
create table t1 (btn char(10) not null, key using HASH (btn)) engine=heap; |
| 158 |
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); |
| 159 |
explain select * from t1 where btn like "q%"; |
| 160 |
id select_type table type possible_keys key key_len ref rows Extra |
| 161 |
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where |
| 162 |
select * from t1 where btn like "q%"; |
| 163 |
btn |
| 164 |
alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn; |
| 165 |
update t1 set new_col=left(btn,1); |
| 166 |
explain select * from t1 where btn="a"; |
| 167 |
id select_type table type possible_keys key key_len ref rows Extra |
| 168 |
1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where |
| 169 |
explain select * from t1 where btn="a" and new_col="a"; |
| 170 |
id select_type table type possible_keys key key_len ref rows Extra |
| 171 |
1 SIMPLE t1 ref btn btn 44 const,const 2 Using where |
| 172 |
drop table t1; |
| 173 |
CREATE TABLE t1 ( |
| 174 |
a int default NULL, |
| 175 |
b int default NULL, |
| 176 |
KEY a using HASH (a), |
| 177 |
UNIQUE b using HASH (b) |
| 178 |
) engine=heap; |
| 179 |
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); |
| 180 |
SELECT * FROM t1 WHERE a=NULL; |
| 181 |
a b |
| 182 |
explain SELECT * FROM t1 WHERE a IS NULL; |
| 183 |
id select_type table type possible_keys key key_len ref rows Extra |
| 184 |
1 SIMPLE t1 ref a a 5 const 2 Using where |
| 185 |
SELECT * FROM t1 WHERE a<=>NULL; |
| 186 |
a b |
| 187 |
NULL 99 |
| 188 |
SELECT * FROM t1 WHERE b=NULL; |
| 189 |
a b |
| 190 |
explain SELECT * FROM t1 WHERE b IS NULL; |
| 191 |
id select_type table type possible_keys key key_len ref rows Extra |
| 192 |
1 SIMPLE t1 ref b b 5 const 1 Using where |
| 193 |
SELECT * FROM t1 WHERE b<=>NULL; |
| 194 |
a b |
| 195 |
99 NULL |
| 196 |
INSERT INTO t1 VALUES (1,3); |
| 197 |
ERROR 23000: Duplicate entry '3' for key 'b' |
| 198 |
DROP TABLE t1; |
| 199 |
CREATE TABLE t1 (a int not null, primary key using HASH (a)) engine=heap; |
| 200 |
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); |
| 201 |
DELETE from t1 where a < 100; |
| 202 |
SELECT * from t1; |
| 203 |
a |
| 204 |
DROP TABLE t1; |
| 205 |
create table t1 |
| 206 |
( |
| 207 |
a char(8) not null, |
| 208 |
b char(20) not null, |
| 209 |
c int not null, |
| 210 |
key (a) |
| 211 |
) engine=heap; |
| 212 |
insert into t1 values ('aaaa', 'prefill-hash=5',0); |
| 213 |
insert into t1 values ('aaab', 'prefill-hash=0',0); |
| 214 |
insert into t1 values ('aaac', 'prefill-hash=7',0); |
| 215 |
insert into t1 values ('aaad', 'prefill-hash=2',0); |
| 216 |
insert into t1 values ('aaae', 'prefill-hash=1',0); |
| 217 |
insert into t1 values ('aaaf', 'prefill-hash=4',0); |
| 218 |
insert into t1 values ('aaag', 'prefill-hash=3',0); |
| 219 |
insert into t1 values ('aaah', 'prefill-hash=6',0); |
| 220 |
explain select * from t1 where a='aaaa'; |
| 221 |
id select_type table type possible_keys key key_len ref rows Extra |
| 222 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 223 |
explain select * from t1 where a='aaab'; |
| 224 |
id select_type table type possible_keys key key_len ref rows Extra |
| 225 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 226 |
explain select * from t1 where a='aaac'; |
| 227 |
id select_type table type possible_keys key key_len ref rows Extra |
| 228 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 229 |
explain select * from t1 where a='aaad'; |
| 230 |
id select_type table type possible_keys key key_len ref rows Extra |
| 231 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 232 |
insert into t1 select * from t1; |
| 233 |
flush tables; |
| 234 |
explain select * from t1 where a='aaaa'; |
| 235 |
id select_type table type possible_keys key key_len ref rows Extra |
| 236 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 237 |
explain select * from t1 where a='aaab'; |
| 238 |
id select_type table type possible_keys key key_len ref rows Extra |
| 239 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 240 |
explain select * from t1 where a='aaac'; |
| 241 |
id select_type table type possible_keys key key_len ref rows Extra |
| 242 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 243 |
explain select * from t1 where a='aaad'; |
| 244 |
id select_type table type possible_keys key key_len ref rows Extra |
| 245 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 246 |
flush tables; |
| 247 |
explain select * from t1 where a='aaaa'; |
| 248 |
id select_type table type possible_keys key key_len ref rows Extra |
| 249 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 250 |
explain select * from t1 where a='aaab'; |
| 251 |
id select_type table type possible_keys key key_len ref rows Extra |
| 252 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 253 |
explain select * from t1 where a='aaac'; |
| 254 |
id select_type table type possible_keys key key_len ref rows Extra |
| 255 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 256 |
explain select * from t1 where a='aaad'; |
| 257 |
id select_type table type possible_keys key key_len ref rows Extra |
| 258 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 259 |
create table t2 as select * from t1; |
| 260 |
delete from t1; |
| 261 |
insert into t1 select * from t2; |
| 262 |
explain select * from t1 where a='aaaa'; |
| 263 |
id select_type table type possible_keys key key_len ref rows Extra |
| 264 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 265 |
explain select * from t1 where a='aaab'; |
| 266 |
id select_type table type possible_keys key key_len ref rows Extra |
| 267 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 268 |
explain select * from t1 where a='aaac'; |
| 269 |
id select_type table type possible_keys key key_len ref rows Extra |
| 270 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 271 |
explain select * from t1 where a='aaad'; |
| 272 |
id select_type table type possible_keys key key_len ref rows Extra |
| 273 |
1 SIMPLE t1 ref a a 32 const 2 Using where |
| 274 |
drop table t1, t2; |
| 275 |
create table t1 ( |
| 276 |
id int unsigned not null primary key auto_increment, |
| 277 |
name varchar(20) not null, |
| 278 |
index heap_idx(name), |
| 279 |
index btree_idx using btree(name) |
| 280 |
) engine=heap; |
| 281 |
create table t2 ( |
| 282 |
id int unsigned not null primary key auto_increment, |
| 283 |
name varchar(20) not null, |
| 284 |
index btree_idx using btree(name), |
| 285 |
index heap_idx(name) |
| 286 |
) engine=heap; |
| 287 |
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), |
| 288 |
('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'), |
| 289 |
('Emily'), ('Mike'); |
| 290 |
insert into t2 select * from t1; |
| 291 |
explain select * from t1 where name='matt'; |
| 292 |
id select_type table type possible_keys key key_len ref rows Extra |
| 293 |
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where |
| 294 |
explain select * from t2 where name='matt'; |
| 295 |
id select_type table type possible_keys key key_len ref rows Extra |
| 296 |
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where |
| 297 |
explain select * from t1 where name='Lilu'; |
| 298 |
id select_type table type possible_keys key key_len ref rows Extra |
| 299 |
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where |
| 300 |
explain select * from t2 where name='Lilu'; |
| 301 |
id select_type table type possible_keys key key_len ref rows Extra |
| 302 |
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where |
| 303 |
explain select * from t1 where name='Phil'; |
| 304 |
id select_type table type possible_keys key key_len ref rows Extra |
| 305 |
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where |
| 306 |
explain select * from t2 where name='Phil'; |
| 307 |
id select_type table type possible_keys key key_len ref rows Extra |
| 308 |
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where |
| 309 |
explain select * from t1 where name='Lilu'; |
| 310 |
id select_type table type possible_keys key key_len ref rows Extra |
| 311 |
1 SIMPLE t1 ref heap_idx,btree_idx btree_idx 82 const 1 Using where |
| 312 |
explain select * from t2 where name='Lilu'; |
| 313 |
id select_type table type possible_keys key key_len ref rows Extra |
| 314 |
1 SIMPLE t2 ref btree_idx,heap_idx btree_idx 82 const 1 Using where |
| 315 |
insert into t1 (name) select name from t2; |
| 316 |
insert into t1 (name) select name from t2; |
| 317 |
insert into t1 (name) select name from t2; |
| 318 |
insert into t1 (name) select name from t2; |
| 319 |
insert into t1 (name) select name from t2; |
| 320 |
insert into t1 (name) select name from t2; |
| 321 |
flush tables; |
| 322 |
select count(*) from t1 where name='Matt'; |
| 323 |
count(*) |
| 324 |
7 |
| 325 |
explain select * from t1 ignore index (btree_idx) where name='matt'; |
| 326 |
id select_type table type possible_keys key key_len ref rows Extra |
| 327 |
1 SIMPLE t1 ref heap_idx heap_idx 82 const 7 Using where |
| 328 |
show index from t1; |
| 329 |
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored |
| 330 |
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH NO |
| 331 |
t1 1 heap_idx 1 name NULL 13 NULL NULL HASH NO |
| 332 |
t1 1 btree_idx 1 name A NULL NULL NULL BTREE NO |
| 333 |
show index from t1; |
| 334 |
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored |
| 335 |
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH NO |
| 336 |
t1 1 heap_idx 1 name NULL 13 NULL NULL HASH NO |
| 337 |
t1 1 btree_idx 1 name A NULL NULL NULL BTREE NO |
| 338 |
create table t3 |
| 339 |
( |
| 340 |
a varchar(20) not null, |
| 341 |
b varchar(20) not null, |
| 342 |
key (a,b) |
| 343 |
) engine=heap; |
| 344 |
insert into t3 select name, name from t1; |
| 345 |
show index from t3; |
| 346 |
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored |
| 347 |
t3 1 a 1 a NULL NULL NULL NULL HASH NO |
| 348 |
t3 1 a 2 b NULL 13 NULL NULL HASH NO |
| 349 |
show index from t3; |
| 350 |
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored |
| 351 |
t3 1 a 1 a NULL NULL NULL NULL HASH NO |
| 352 |
t3 1 a 2 b NULL 13 NULL NULL HASH NO |
| 353 |
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name; |
| 354 |
id select_type table type possible_keys key key_len ref rows Extra |
| 355 |
1 SIMPLE t1 ref heap_idx heap_idx 82 const 7 Using where |
| 356 |
1 SIMPLE t3 ref a a 164 func,const 7 Using where |
| 357 |
drop table t1, t2, t3; |
| 358 |
create temporary table t1 ( a int, index (a) ) engine=memory; |
| 359 |
insert into t1 values (1),(2),(3),(4),(5); |
| 360 |
select a from t1 where a in (1,3); |
| 361 |
a |
| 362 |
1 |
| 363 |
3 |
| 364 |
explain select a from t1 where a in (1,3); |
| 365 |
id select_type table type possible_keys key key_len ref rows Extra |
| 366 |
1 SIMPLE t1 range a a 5 NULL 4 Using where |
| 367 |
drop table t1; |
| 368 |
End of 4.1 tests |
| 369 |
CREATE TABLE t1(col1 VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, |
| 370 |
col2 VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, |
| 371 |
UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY; |
| 372 |
INSERT INTO t1 VALUES('A', 'A'); |
| 373 |
INSERT INTO t1 VALUES('A ', 'A '); |
| 374 |
ERROR 23000: Duplicate entry 'A -A ' for key 'key1' |
| 375 |
DROP TABLE t1; |
| 376 |
CREATE TABLE t1(col1 VARCHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, |
| 377 |
col2 VARCHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, |
| 378 |
UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY; |
| 379 |
INSERT INTO t1 VALUES('A', 'A'); |
| 380 |
INSERT INTO t1 VALUES('A ', 'A '); |
| 381 |
ERROR 23000: Duplicate entry 'A -A ' for key 'key1' |
| 382 |
DROP TABLE t1; |
| 383 |
End of 5.0 tests |
| 384 |
# |
| 385 |
# MDEV-568 (AKA LP BUG#1007981, AKA MySQL bug#44771) |
| 386 |
# Wrong result for a hash index look-up if the index is unique and |
| 387 |
# the key is NULL |
| 388 |
# |
| 389 |
CREATE TABLE t1 ( pk INT PRIMARY KEY, val INT, UNIQUE KEY USING HASH(val)) ENGINE=MEMORY; |
| 390 |
INSERT INTO t1 VALUES (1, NULL); |
| 391 |
INSERT INTO t1 VALUES (2, NULL); |
| 392 |
INSERT INTO t1 VALUES (3, 1); |
| 393 |
INSERT INTO t1 VALUES (4, NULL); |
| 394 |
EXPLAIN SELECT * FROM t1 WHERE val IS NULL; |
| 395 |
id select_type table type possible_keys key key_len ref rows Extra |
| 396 |
1 SIMPLE t1 ref val val 5 const 1 Using where |
| 397 |
SELECT * FROM t1 WHERE val IS NULL; |
| 398 |
pk val |
| 399 |
4 NULL |
| 400 |
2 NULL |
| 401 |
1 NULL |
| 402 |
drop table t1; |
| 403 |
End of 5.2 tests |
| 404 |
# bit index in heap tables |
| 405 |
create table t1 (a bit(63) not null) engine=heap; |
| 406 |
insert into t1 values (869751),(736494),(226312),(802616),(728912); |
| 407 |
alter table t1 add unique uniq_id using HASH (a); |
| 408 |
select 0+a from t1 where a > 736494; |
| 409 |
0+a |
| 410 |
869751 |
| 411 |
802616 |
| 412 |
explain select 0+a from t1 where a > 736494; |
| 413 |
id select_type table type possible_keys key key_len ref rows Extra |
| 414 |
1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where |
| 415 |
select 0+a from t1 where a = 736494; |
| 416 |
0+a |
| 417 |
736494 |
| 418 |
explain select 0+a from t1 where a = 736494; |
| 419 |
id select_type table type possible_keys key key_len ref rows Extra |
| 420 |
1 SIMPLE t1 const uniq_id uniq_id 8 const 1 |
| 421 |
select 0+a from t1 where a=869751 or a=736494; |
| 422 |
0+a |
| 423 |
736494 |
| 424 |
869751 |
| 425 |
explain select 0+a from t1 where a=869751 or a=736494; |
| 426 |
id select_type table type possible_keys key key_len ref rows Extra |
| 427 |
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where |
| 428 |
select 0+a from t1 where a in (869751,736494,226312,802616,728912); |
| 429 |
0+a |
| 430 |
226312 |
| 431 |
728912 |
| 432 |
736494 |
| 433 |
802616 |
| 434 |
869751 |
| 435 |
explain select 0+a from t1 where a in (869751,736494,226312,802616,728912); |
| 436 |
id select_type table type possible_keys key key_len ref rows Extra |
| 437 |
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 5 Using where |
| 438 |
drop table t1; |
| 439 |
End of 5.3 tests |
| 440 |
# |
| 441 |
# Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c |
| 442 |
# on DELETE statement |
| 443 |
# |
| 444 |
CREATE TABLE t1 (col_int_nokey INT, |
| 445 |
col_int_key INT, |
| 446 |
INDEX(col_int_key) USING HASH) ENGINE = HEAP; |
| 447 |
INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1); |
| 448 |
DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2; |
| 449 |
DROP TABLE t1; |
| 450 |
# |
| 451 |
# Bug #1002564: Wrong result for a lookup query from a heap table |
| 452 |
# |
| 453 |
CREATE TABLE t1 (c1 VARCHAR(10) NOT NULL, KEY i1 (c1(3))) ENGINE=MEMORY DEFAULT CHARSET=latin1; |
| 454 |
INSERT INTO t1 VALUES ('foo1'), ('bar2'), ('baz3'); |
| 455 |
explain SELECT * FROM t1 WHERE c1='bar2'; |
| 456 |
id select_type table type possible_keys key key_len ref rows Extra |
| 457 |
1 SIMPLE t1 ref i1 i1 5 const 2 Using where |
| 458 |
SELECT * FROM t1 WHERE c1='bar2'; |
| 459 |
c1 |
| 460 |
bar2 |
| 461 |
ALTER TABLE t1 DROP KEY i1, ADD KEY il (c1(3)) using btree; |
| 462 |
explain SELECT * FROM t1 WHERE c1='bar2'; |
| 463 |
id select_type table type possible_keys key key_len ref rows Extra |
| 464 |
1 SIMPLE t1 ref il il 5 const 1 Using where |
| 465 |
SELECT * FROM t1 WHERE c1='bar2'; |
| 466 |
c1 |
| 467 |
bar2 |
| 468 |
DROP TABLE t1; |
| 469 |
# |
| 470 |
# End of 5.5 tests |
| 471 |
# |
| 472 |
# |
| 473 |
# MDEV-27406 Index on a HEAP table retains DESC attribute despite being hash |
| 474 |
# |
| 475 |
create table t1 (a int, key(a desc)) engine=memory; |
| 476 |
show index from t1; |
| 477 |
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored |
| 478 |
t1 1 a 1 a NULL 0 NULL NULL YES HASH NO |
| 479 |
show create table t1; |
| 480 |
Table Create Table |
| 481 |
t1 CREATE TABLE `t1` ( |
| 482 |
`a` int(11) DEFAULT NULL, |
| 483 |
KEY `a` (`a`) |
| 484 |
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 485 |
drop table t1; |
| 486 |
# |
| 487 |
# End of 10.8 tests |
| 488 |
# |