| 1 |
# |
| 2 |
# Test of heap tables. |
| 3 |
# |
| 4 |
|
| 5 |
--source include/test_db_charset_latin1.inc |
| 6 |
|
| 7 |
--disable_warnings |
| 8 |
drop table if exists t1,t2,t3; |
| 9 |
--enable_warnings |
| 10 |
|
| 11 |
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; |
| 12 |
insert into t1 values(1,1),(2,2),(3,3),(4,4); |
| 13 |
delete from t1 where a=1 or a=0; |
| 14 |
#show table status like "t1"; |
| 15 |
show keys from t1; |
| 16 |
select * from t1; |
| 17 |
select * from t1 where a=4; |
| 18 |
update t1 set b=5 where a=4; |
| 19 |
update t1 set b=b+1 where a>=3; |
| 20 |
replace t1 values (3,3); |
| 21 |
select * from t1; |
| 22 |
alter table t1 add c int not null, add key (c,a); |
| 23 |
drop table t1; |
| 24 |
|
| 25 |
create table t1 (a int not null,b int not null, primary key (a)) engine=memory 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 |
drop table t1; |
| 30 |
|
| 31 |
create table t1 (a int not null,b int not null, primary key (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 |
#show table status like "t1"; |
| 35 |
select * from t1; |
| 36 |
drop table t1; |
| 37 |
|
| 38 |
create table t1 (a int not null) engine=heap; |
| 39 |
insert into t1 values (869751),(736494),(226312),(802616),(728912); |
| 40 |
select * from t1 where a > 736494; |
| 41 |
alter table t1 add unique uniq_id(a); |
| 42 |
select * from t1 where a > 736494; |
| 43 |
select * from t1 where a = 736494; |
| 44 |
select * from t1 where a=869751 or a=736494; |
| 45 |
select * from t1 where a in (869751,736494,226312,802616); |
| 46 |
alter table t1 engine=myisam; |
| 47 |
explain select * from t1 where a in (869751,736494,226312,802616); |
| 48 |
drop table t1; |
| 49 |
|
| 50 |
create table t1 (x int not null, y int not null, key x (x), unique y (y)) |
| 51 |
engine=heap; |
| 52 |
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); |
| 53 |
select * from t1 where x=1; |
| 54 |
select * from t1,t1 as t2 where t1.x=t2.y; |
| 55 |
explain select * from t1,t1 as t2 where t1.x=t2.y; |
| 56 |
drop table t1; |
| 57 |
|
| 58 |
create table t1 (a int) engine=heap; |
| 59 |
insert into t1 values(1); |
| 60 |
select max(a) from t1; |
| 61 |
drop table t1; |
| 62 |
|
| 63 |
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP; |
| 64 |
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); |
| 65 |
select * from t1 where a=1; |
| 66 |
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); |
| 67 |
select * from t1 where a=1; |
| 68 |
drop table t1; |
| 69 |
|
| 70 |
create table t1 (id int unsigned not null, primary key (id)) engine=HEAP; |
| 71 |
insert into t1 values(1); |
| 72 |
select max(id) from t1; |
| 73 |
insert into t1 values(2); |
| 74 |
select max(id) from t1; |
| 75 |
replace into t1 values(1); |
| 76 |
drop table t1; |
| 77 |
|
| 78 |
create table t1 (n int) engine=heap; |
| 79 |
drop table t1; |
| 80 |
|
| 81 |
create table t1 (n int) engine=heap; |
| 82 |
drop table if exists t1; |
| 83 |
|
| 84 |
# Test of non unique index |
| 85 |
|
| 86 |
CREATE table t1(f1 int not null,f2 char(20) not |
| 87 |
null,index(f2)) engine=heap; |
| 88 |
INSERT into t1 set f1=12,f2="bill"; |
| 89 |
INSERT into t1 set f1=13,f2="bill"; |
| 90 |
INSERT into t1 set f1=14,f2="bill"; |
| 91 |
INSERT into t1 set f1=15,f2="bill"; |
| 92 |
INSERT into t1 set f1=16,f2="ted"; |
| 93 |
INSERT into t1 set f1=12,f2="ted"; |
| 94 |
INSERT into t1 set f1=12,f2="ted"; |
| 95 |
INSERT into t1 set f1=12,f2="ted"; |
| 96 |
INSERT into t1 set f1=12,f2="ted"; |
| 97 |
delete from t1 where f2="bill"; |
| 98 |
select * from t1; |
| 99 |
drop table t1; |
| 100 |
|
| 101 |
# |
| 102 |
# Test when using part key searches |
| 103 |
# |
| 104 |
|
| 105 |
create table t1 (btn char(10) not null, key(btn)) engine=heap; |
| 106 |
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); |
| 107 |
explain select * from t1 where btn like "q%"; |
| 108 |
select * from t1 where btn like "q%"; |
| 109 |
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn; |
| 110 |
update t1 set new_col=left(btn,1); |
| 111 |
explain select * from t1 where btn="a"; |
| 112 |
explain select * from t1 where btn="a" and new_col="a"; |
| 113 |
drop table t1; |
| 114 |
|
| 115 |
# |
| 116 |
# Test of NULL keys |
| 117 |
# |
| 118 |
|
| 119 |
CREATE TABLE t1 ( |
| 120 |
a int default NULL, |
| 121 |
b int default NULL, |
| 122 |
KEY a (a), |
| 123 |
UNIQUE b (b) |
| 124 |
) engine=heap; |
| 125 |
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); |
| 126 |
SELECT * FROM t1 WHERE a=NULL; |
| 127 |
explain SELECT * FROM t1 WHERE a IS NULL; |
| 128 |
SELECT * FROM t1 WHERE a<=>NULL; |
| 129 |
SELECT * FROM t1 WHERE b=NULL; |
| 130 |
explain SELECT * FROM t1 WHERE b IS NULL; |
| 131 |
SELECT * FROM t1 WHERE b<=>NULL; |
| 132 |
|
| 133 |
--error ER_DUP_ENTRY |
| 134 |
INSERT INTO t1 VALUES (1,3); |
| 135 |
DROP TABLE t1; |
| 136 |
|
| 137 |
CREATE TABLE t1 ( |
| 138 |
a int default NULL, |
| 139 |
key a (a) |
| 140 |
) ENGINE=HEAP; |
| 141 |
INSERT INTO t1 VALUES (10), (10), (10); |
| 142 |
EXPLAIN SELECT * FROM t1 WHERE a=10; |
| 143 |
SELECT * FROM t1 WHERE a=10; |
| 144 |
DROP TABLE t1; |
| 145 |
|
| 146 |
# |
| 147 |
# Test when deleting all rows |
| 148 |
# |
| 149 |
|
| 150 |
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap; |
| 151 |
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); |
| 152 |
DELETE from t1 where a < 100; |
| 153 |
SELECT * from t1; |
| 154 |
DROP TABLE t1; |
| 155 |
|
| 156 |
# |
| 157 |
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty HEAP table |
| 158 |
# |
| 159 |
CREATE TABLE `job_titles` ( |
| 160 |
`job_title_id` int(6) unsigned NOT NULL default '0', |
| 161 |
`job_title` char(18) NOT NULL default '', |
| 162 |
PRIMARY KEY (`job_title_id`), |
| 163 |
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`) |
| 164 |
) ENGINE=HEAP; |
| 165 |
|
| 166 |
SELECT MAX(job_title_id) FROM job_titles; |
| 167 |
|
| 168 |
DROP TABLE job_titles; |
| 169 |
|
| 170 |
# |
| 171 |
# Test of delete with NOT NULL |
| 172 |
# (Bug #6082) |
| 173 |
# |
| 174 |
|
| 175 |
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP; |
| 176 |
INSERT INTO t1 VALUES(1,1), (1,NULL); |
| 177 |
SELECT * FROM t1 WHERE B is not null; |
| 178 |
DROP TABLE t1; |
| 179 |
|
| 180 |
# |
| 181 |
# Bug #6748 |
| 182 |
# heap_rfirst() doesn't work (and never did!) |
| 183 |
# |
| 184 |
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP; |
| 185 |
INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496); |
| 186 |
DELETE FROM t1 WHERE date<1101106546; |
| 187 |
SELECT * FROM t1; |
| 188 |
DROP TABLE t1; |
| 189 |
|
| 190 |
# |
| 191 |
# Bug #6878: a problem with small length records |
| 192 |
# |
| 193 |
|
| 194 |
create table t1(a char(2)) engine=memory; |
| 195 |
insert into t1 values (NULL), (NULL); |
| 196 |
delete from t1 where a is null; |
| 197 |
insert into t1 values ('2'), ('3'); |
| 198 |
select * from t1; |
| 199 |
drop table t1; |
| 200 |
|
| 201 |
# |
| 202 |
# Test varchar |
| 203 |
# We can't use varchar.inc becasue heap doesn't support blob's |
| 204 |
# |
| 205 |
|
| 206 |
let $default=`select @@default_storage_engine`; |
| 207 |
set default_storage_engine=HEAP; |
| 208 |
|
| 209 |
# |
| 210 |
# Simple basic test that endspace is saved |
| 211 |
# |
| 212 |
|
| 213 |
create table t1 (v varchar(10), c char(10), t varchar(50)); |
| 214 |
insert into t1 values('+ ', '+ ', '+ '); |
| 215 |
set @a=repeat(' ',20); |
| 216 |
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); |
| 217 |
select concat('*',v,'*',c,'*',t,'*') from t1; |
| 218 |
|
| 219 |
# Check how columns are copied |
| 220 |
show create table t1; |
| 221 |
create table t2 like t1; |
| 222 |
show create table t2; |
| 223 |
create table t3 select * from t1; |
| 224 |
show create table t3; |
| 225 |
alter table t1 modify c varchar(10); |
| 226 |
show create table t1; |
| 227 |
alter table t1 modify v char(10); |
| 228 |
show create table t1; |
| 229 |
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR |
| 230 |
alter table t1 modify t varchar(10); |
| 231 |
show create table t1; |
| 232 |
select concat('*',v,'*',c,'*',t,'*') from t1; |
| 233 |
drop table t1,t2,t3; |
| 234 |
|
| 235 |
# |
| 236 |
# Testing of keys |
| 237 |
# |
| 238 |
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10))); |
| 239 |
show create table t1; |
| 240 |
--disable_query_log |
| 241 |
begin; |
| 242 |
let $1=10; |
| 243 |
while ($1) |
| 244 |
{ |
| 245 |
let $2=27; |
| 246 |
eval set @space=repeat(' ',10-$1); |
| 247 |
while ($2) |
| 248 |
{ |
| 249 |
eval set @char=char(ascii('a')+$2-1); |
| 250 |
insert into t1 values(concat(@char,@space),concat(@char,@space),concat(@char,@space)); |
| 251 |
dec $2; |
| 252 |
} |
| 253 |
dec $1; |
| 254 |
} |
| 255 |
commit; |
| 256 |
--enable_query_log |
| 257 |
|
| 258 |
select count(*) from t1; |
| 259 |
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); |
| 260 |
select count(*) from t1 where v='a'; |
| 261 |
select count(*) from t1 where c='a'; |
| 262 |
select count(*) from t1 where t='a'; |
| 263 |
select count(*) from t1 where v='a '; |
| 264 |
select count(*) from t1 where c='a '; |
| 265 |
select count(*) from t1 where t='a '; |
| 266 |
select count(*) from t1 where v between 'a' and 'a '; |
| 267 |
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
| 268 |
select count(*) from t1 where v like 'a%'; |
| 269 |
select count(*) from t1 where c like 'a%'; |
| 270 |
select count(*) from t1 where t like 'a%'; |
| 271 |
select count(*) from t1 where v like 'a %'; |
| 272 |
explain select count(*) from t1 where v='a '; |
| 273 |
explain select count(*) from t1 where c='a '; |
| 274 |
explain select count(*) from t1 where t='a '; |
| 275 |
explain select count(*) from t1 where v like 'a%'; |
| 276 |
explain select count(*) from t1 where v between 'a' and 'a '; |
| 277 |
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
| 278 |
|
| 279 |
--error ER_DUP_ENTRY |
| 280 |
alter table t1 add unique(v); |
| 281 |
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); |
| 282 |
flush tables; |
| 283 |
explain select * from t1 where v='a'; |
| 284 |
|
| 285 |
# GROUP BY |
| 286 |
|
| 287 |
select v,count(*) from t1 group by v limit 10; |
| 288 |
select v,count(t) from t1 group by v limit 10; |
| 289 |
select v,count(c) from t1 group by v limit 10; |
| 290 |
select sql_big_result trim(v),count(t) from t1 group by v limit 10; |
| 291 |
select sql_big_result trim(v),count(c) from t1 group by v limit 10; |
| 292 |
select c,count(*) from t1 group by c limit 10; |
| 293 |
select c,count(t) from t1 group by c limit 10; |
| 294 |
select sql_big_result c,count(t) from t1 group by c limit 10; |
| 295 |
select t,count(*) from t1 group by t limit 10; |
| 296 |
select t,count(t) from t1 group by t limit 10; |
| 297 |
select sql_big_result trim(t),count(t) from t1 group by t limit 10; |
| 298 |
drop table t1; |
| 299 |
|
| 300 |
# |
| 301 |
# Test unique keys |
| 302 |
# |
| 303 |
|
| 304 |
create table t1 (a char(10), unique (a)); |
| 305 |
insert into t1 values ('a'); |
| 306 |
--error ER_DUP_ENTRY |
| 307 |
insert into t1 values ('a '); |
| 308 |
|
| 309 |
alter table t1 modify a varchar(10); |
| 310 |
--error ER_DUP_ENTRY |
| 311 |
insert into t1 values ('a '),('a '),('a '),('a '); |
| 312 |
--error ER_DUP_ENTRY |
| 313 |
insert into t1 values ('a '); |
| 314 |
--error ER_DUP_ENTRY |
| 315 |
insert into t1 values ('a '); |
| 316 |
--error ER_DUP_ENTRY |
| 317 |
insert into t1 values ('a '); |
| 318 |
update t1 set a='a ' where a like 'a '; |
| 319 |
update t1 set a='a ' where a like 'a '; |
| 320 |
drop table t1; |
| 321 |
|
| 322 |
# |
| 323 |
# Testing of btree keys |
| 324 |
# |
| 325 |
|
| 326 |
create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10))); |
| 327 |
show create table t1; |
| 328 |
--disable_query_log |
| 329 |
begin; |
| 330 |
let $1=10; |
| 331 |
while ($1) |
| 332 |
{ |
| 333 |
let $2=27; |
| 334 |
eval set @space=repeat(' ',10-$1); |
| 335 |
while ($2) |
| 336 |
{ |
| 337 |
eval set @char=char(ascii('a')+$2-1); |
| 338 |
insert into t1 values(concat(@char,@space),concat(@char,@space),concat(@char,@space)); |
| 339 |
dec $2; |
| 340 |
} |
| 341 |
dec $1; |
| 342 |
} |
| 343 |
delete from t1 where v like 'a%' and length(v) > 7; |
| 344 |
commit; |
| 345 |
--enable_query_log |
| 346 |
select count(*) from t1; |
| 347 |
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1))); |
| 348 |
select count(*) from t1 where v='a'; |
| 349 |
select count(*) from t1 where c='a'; |
| 350 |
select count(*) from t1 where t='a'; |
| 351 |
select count(*) from t1 where v='a '; |
| 352 |
select count(*) from t1 where c='a '; |
| 353 |
select count(*) from t1 where t='a '; |
| 354 |
select count(*) from t1 where v between 'a' and 'a '; |
| 355 |
--replace_column 9 # |
| 356 |
select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
| 357 |
--replace_column 9 # |
| 358 |
explain select count(*) from t1 where v='a '; |
| 359 |
--replace_column 9 # |
| 360 |
explain select count(*) from t1 where c='a '; |
| 361 |
--replace_column 9 # |
| 362 |
explain select count(*) from t1 where t='a '; |
| 363 |
--replace_column 9 # |
| 364 |
explain select count(*) from t1 where v like 'a%'; |
| 365 |
--replace_column 9 # |
| 366 |
explain select count(*) from t1 where v between 'a' and 'a '; |
| 367 |
--replace_column 9 # |
| 368 |
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n'; |
| 369 |
|
| 370 |
--error ER_DUP_ENTRY |
| 371 |
alter table t1 add unique(v); |
| 372 |
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*')); |
| 373 |
# Number of rows is not constant for b-trees keys |
| 374 |
--replace_column 9 # |
| 375 |
explain select * from t1 where v='a'; |
| 376 |
|
| 377 |
drop table t1; |
| 378 |
|
| 379 |
# |
| 380 |
# Test unique btree keys |
| 381 |
# |
| 382 |
|
| 383 |
create table t1 (a char(10), unique using btree (a)) engine=heap; |
| 384 |
insert into t1 values ('a'); |
| 385 |
--error ER_DUP_ENTRY |
| 386 |
insert into t1 values ('a '); |
| 387 |
|
| 388 |
alter table t1 modify a varchar(10); |
| 389 |
--error ER_DUP_ENTRY |
| 390 |
insert into t1 values ('a '),('a '),('a '),('a '); |
| 391 |
--error ER_DUP_ENTRY |
| 392 |
insert into t1 values ('a '); |
| 393 |
--error ER_DUP_ENTRY |
| 394 |
insert into t1 values ('a '); |
| 395 |
--error ER_DUP_ENTRY |
| 396 |
insert into t1 values ('a '); |
| 397 |
update t1 set a='a ' where a like 'a '; |
| 398 |
update t1 set a='a ' where a like 'a '; |
| 399 |
drop table t1; |
| 400 |
|
| 401 |
# |
| 402 |
# test show create table |
| 403 |
# |
| 404 |
|
| 405 |
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5))); |
| 406 |
show create table t1; |
| 407 |
drop table t1; |
| 408 |
|
| 409 |
create table t1 (v varchar(65530), key(v(10))); |
| 410 |
show create table t1; |
| 411 |
insert into t1 values(repeat('a',65530)); |
| 412 |
select length(v) from t1 where v=repeat('a',65530); |
| 413 |
drop table t1; |
| 414 |
|
| 415 |
# |
| 416 |
# Reset varchar test |
| 417 |
# |
| 418 |
eval set default_storage_engine=$default; |
| 419 |
|
| 420 |
# |
| 421 |
# Bug #8489: Strange auto_increment behaviour |
| 422 |
# |
| 423 |
|
| 424 |
create table t1 (a bigint unsigned auto_increment primary key, b int, |
| 425 |
key (b, a)) engine=heap; |
| 426 |
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1); |
| 427 |
select * from t1; |
| 428 |
drop table t1; |
| 429 |
|
| 430 |
create table t1 (a int not null, b int not null auto_increment, |
| 431 |
primary key(a, b), key(b)) engine=heap; |
| 432 |
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1); |
| 433 |
select * from t1; |
| 434 |
drop table t1; |
| 435 |
|
| 436 |
--error 1075 |
| 437 |
create table t1 (a int not null, b int not null auto_increment, |
| 438 |
primary key(a, b)) engine=heap; |
| 439 |
|
| 440 |
# |
| 441 |
# Bug #10566: Verify that we can create a prefixed key with length > 255 |
| 442 |
# |
| 443 |
create table t1 (c char(255), primary key(c(90))); |
| 444 |
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); |
| 445 |
--error ER_DUP_ENTRY |
| 446 |
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); |
| 447 |
drop table t1; |
| 448 |
|
| 449 |
# |
| 450 |
# Bug 12796: Record doesn't show when selecting through index |
| 451 |
# |
| 452 |
CREATE TABLE t1 (a int, key(a)) engine=heap; |
| 453 |
insert into t1 values (0); |
| 454 |
delete from t1; |
| 455 |
select * from t1; |
| 456 |
insert into t1 values (0), (1); |
| 457 |
select * from t1 where a = 0; |
| 458 |
drop table t1; |
| 459 |
|
| 460 |
# End of 4.1 tests |
| 461 |
|
| 462 |
# |
| 463 |
# Bug #3094: Row format of memory tables should always be reported as Fixed |
| 464 |
# |
| 465 |
create table t1 (c char(10)) engine=memory; |
| 466 |
create table t2 (c varchar(10)) engine=memory; |
| 467 |
--replace_column 8 # 12 # |
| 468 |
show table status like 't_'; |
| 469 |
drop table t1, t2; |
| 470 |
|
| 471 |
# |
| 472 |
# BUG#18233 - Memory tables INDEX USING HASH (a,b) returns 1 row on |
| 473 |
# SELECT WHERE a= AND b= |
| 474 |
# |
| 475 |
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256), |
| 476 |
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY; |
| 477 |
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256)); |
| 478 |
SELECT COUNT(*) FROM t1 WHERE a='a'; |
| 479 |
SELECT COUNT(*) FROM t1 WHERE b='aa'; |
| 480 |
SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256); |
| 481 |
DROP TABLE t1; |
| 482 |
|
| 483 |
# End of 5.0 tests |
| 484 |
|
| 485 |
# |
| 486 |
# BUG#26080 - Memory Storage engine not working properly |
| 487 |
# |
| 488 |
CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY; |
| 489 |
INSERT INTO t1 VALUES('', 0); |
| 490 |
ALTER TABLE t1 MODIFY c1 VARCHAR(101); |
| 491 |
SELECT c2 FROM t1; |
| 492 |
DROP TABLE t1; |
| 493 |
|
| 494 |
# |
| 495 |
# BUG#51763 Can't delete rows from MEMORY table with HASH key |
| 496 |
# |
| 497 |
|
| 498 |
CREATE TABLE t1 ( |
| 499 |
id int(11) NOT NULL AUTO_INCREMENT, |
| 500 |
color enum('GREEN', 'WHITE') DEFAULT NULL, |
| 501 |
ts int, |
| 502 |
PRIMARY KEY (id), |
| 503 |
KEY color (color) USING HASH |
| 504 |
) ENGINE=MEMORY DEFAULT CHARSET=utf8; |
| 505 |
|
| 506 |
INSERT INTO t1 VALUES("1","GREEN",1); |
| 507 |
INSERT INTO t1 VALUES("2","GREEN",1); |
| 508 |
INSERT INTO t1 VALUES("3","GREEN",1); |
| 509 |
INSERT INTO t1 VALUES("4","GREEN",1); |
| 510 |
INSERT INTO t1 VALUES("5","GREEN",1); |
| 511 |
INSERT INTO t1 VALUES("6","GREEN",1); |
| 512 |
DELETE FROM t1 WHERE id = 1; |
| 513 |
INSERT INTO t1 VALUES("7","GREEN", 2); |
| 514 |
DELETE FROM t1 WHERE ts = 1 AND color = 'GREEN'; |
| 515 |
SELECT * from t1; |
| 516 |
DROP TABLE t1; |
| 517 |
|
| 518 |
|
| 519 |
# |
| 520 |
# MDEV-5905 Creating tmp. memory table kills the server |
| 521 |
# |
| 522 |
|
| 523 |
CREATE TABLE t1 (id INT); |
| 524 |
INSERT INTO t1 VALUES (1); |
| 525 |
INSERT INTO t1 VALUES (2); |
| 526 |
|
| 527 |
--disable_warnings |
| 528 |
SET @@max_heap_table_size = 1024*1024*1024*20; |
| 529 |
--enable_warnings |
| 530 |
|
| 531 |
CREATE TEMPORARY TABLE tmp ENGINE=MEMORY |
| 532 |
SELECT id FROM t1; |
| 533 |
DROP TEMPORARY TABLE tmp; |
| 534 |
drop table t1; |
| 535 |
|
| 536 |
--echo # |
| 537 |
--echo # BUG#11825482: Broken key length calculation for btree index |
| 538 |
--echo # |
| 539 |
CREATE TABLE h1 (f1 VARCHAR(1), f2 INT NOT NULL, |
| 540 |
UNIQUE KEY h1i (f1,f2) USING BTREE ) ENGINE=HEAP; |
| 541 |
INSERT INTO h1 VALUES(NULL,0),(NULL,1); |
| 542 |
SELECT 'wrong' as 'result' FROM dual WHERE ('h', 0) NOT IN (SELECT * FROM h1); |
| 543 |
|
| 544 |
CREATE TABLE t1 ( |
| 545 |
pk int NOT NULL, |
| 546 |
col_int_nokey INT, |
| 547 |
col_varchar_nokey VARCHAR(1), |
| 548 |
PRIMARY KEY (pk) |
| 549 |
); |
| 550 |
|
| 551 |
INSERT INTO t1 VALUES (19,5,'h'),(20,5,'h'); |
| 552 |
|
| 553 |
CREATE TABLE t2 (col_int_nokey INT); |
| 554 |
|
| 555 |
INSERT INTO t2 VALUES (1),(2); |
| 556 |
|
| 557 |
CREATE VIEW v1 AS |
| 558 |
SELECT col_varchar_nokey, COUNT( col_varchar_nokey ) |
| 559 |
FROM t1 |
| 560 |
WHERE col_int_nokey <= 141 AND pk <= 4 |
| 561 |
; |
| 562 |
|
| 563 |
SELECT col_int_nokey FROM t2 |
| 564 |
WHERE ('h', 0) NOT IN ( SELECT * FROM v1); |
| 565 |
--echo # shouldn't crash |
| 566 |
EXPLAIN SELECT col_int_nokey FROM t2 |
| 567 |
WHERE ('h', 0) NOT IN ( SELECT * FROM v1); |
| 568 |
|
| 569 |
DROP TABLE t1,t2,h1; |
| 570 |
DROP VIEW v1; |
| 571 |
# End of 5.1 tests |
| 572 |
|
| 573 |
# |
| 574 |
# MDEV-5905 Creating tmp. memory table kills the server |
| 575 |
# |
| 576 |
|
| 577 |
CREATE TABLE t1 (id INT); |
| 578 |
INSERT INTO t1 VALUES (1); |
| 579 |
INSERT INTO t1 VALUES (2); |
| 580 |
|
| 581 |
--disable_warnings |
| 582 |
SET @@max_heap_table_size = 1024*1024*1024*20; |
| 583 |
--enable_warnings |
| 584 |
|
| 585 |
CREATE TEMPORARY TABLE tmp ENGINE=MEMORY |
| 586 |
SELECT id FROM t1; |
| 587 |
DROP TEMPORARY TABLE tmp; |
| 588 |
drop table t1; |
| 589 |
|
| 590 |
# |
| 591 |
# BUG#51763 Can't delete rows from MEMORY table with HASH key |
| 592 |
# |
| 593 |
|
| 594 |
CREATE TABLE t1 ( |
| 595 |
id int(11) NOT NULL AUTO_INCREMENT, |
| 596 |
color enum('GREEN', 'WHITE') DEFAULT NULL, |
| 597 |
ts int, |
| 598 |
PRIMARY KEY (id), |
| 599 |
KEY color (color) USING HASH |
| 600 |
) ENGINE=MEMORY DEFAULT CHARSET=utf8; |
| 601 |
|
| 602 |
INSERT INTO t1 VALUES("1","GREEN",1); |
| 603 |
INSERT INTO t1 VALUES("2","GREEN",1); |
| 604 |
INSERT INTO t1 VALUES("3","GREEN",1); |
| 605 |
INSERT INTO t1 VALUES("4","GREEN",1); |
| 606 |
INSERT INTO t1 VALUES("5","GREEN",1); |
| 607 |
INSERT INTO t1 VALUES("6","GREEN",1); |
| 608 |
DELETE FROM t1 WHERE id = 1; |
| 609 |
INSERT INTO t1 VALUES("7","GREEN", 2); |
| 610 |
DELETE FROM t1 WHERE ts = 1 AND color = 'GREEN'; |
| 611 |
SELECT * from t1 WHERE ts = 1 AND color = 'GREEN'; |
| 612 |
DROP TABLE t1; |
| 613 |
|
| 614 |
--echo # |
| 615 |
--echo # MDEV-22695 Server crashes in heap_rnext upon DELETE from a HEAP table |
| 616 |
--echo # |
| 617 |
CREATE TABLE t1 (a VARCHAR(128), b VARCHAR(32), KEY(a) USING BTREE, KEY(b) USING BTREE) ENGINE=HEAP; |
| 618 |
INSERT INTO t1 VALUES ('foo',NULL),('m','b'),(6,'j'),('bar','qux'),(NULL,NULL); |
| 619 |
DELETE FROM t1 WHERE a <=> 'm' OR b <=> NULL; |
| 620 |
# Cleanup |
| 621 |
DROP TABLE t1; |
| 622 |
|
| 623 |
--echo # |
| 624 |
--echo # MDEV-28130 MariaDB SEGV issue at tree_search_next |
| 625 |
--echo # |
| 626 |
CREATE TABLE v(t1 INT, pk INT, KEY(t1), KEY pk using btree (pk), KEY v using btree(t1, pk)) engine=memory; |
| 627 |
HANDLER v OPEN; |
| 628 |
HANDLER v READ t1=(2) limit 3; |
| 629 |
HANDLER v READ pk PREV; |
| 630 |
HANDLER v READ pk PREV; |
| 631 |
drop table v; |
| 632 |
|
| 633 |
--source include/test_db_charset_restore.inc |