| 1 |
-- source include/have_ndb.inc |
| 2 |
|
| 3 |
--echo # bug#18082045 - TESTFK CREATEDROPWITHDATA NEED HIGH MAXNOOFCONCURRENTSCANS |
| 4 |
|
| 5 |
create table t1 ( |
| 6 |
a1 int not null, |
| 7 |
primary key using hash (a1) |
| 8 |
) engine ndb; |
| 9 |
|
| 10 |
create table t2 ( |
| 11 |
a2 int not null, |
| 12 |
b2 int not null, |
| 13 |
primary key using hash (a2), |
| 14 |
key t2x1 (b2), |
| 15 |
-- cascade is not essential to demo the bug |
| 16 |
foreign key t2fk1 (b2) references t1 (a1) on delete cascade |
| 17 |
) engine ndb; |
| 18 |
|
| 19 |
# A full scan delete batch on t1 starts 64 parallel cascading scans |
| 20 |
# on t2 each with (hardcoded) 4 fragment scans. Our .cnf limits these |
| 21 |
# to 64. The 1024 rows here is more than enough to create such batches. |
| 22 |
|
| 23 |
--disable_query_log |
| 24 |
let $i=1024; |
| 25 |
while ($i) |
| 26 |
{ |
| 27 |
eval insert into t1 values ($i); |
| 28 |
eval insert into t2 values ($i,$i); |
| 29 |
dec $i; |
| 30 |
} |
| 31 |
--enable_query_log |
| 32 |
|
| 33 |
begin; |
| 34 |
delete from t1; |
| 35 |
rollback; |
| 36 |
select count(*) from t1; |
| 37 |
select count(*) from t2; |
| 38 |
|
| 39 |
delete from t1; |
| 40 |
select count(*) from t1; |
| 41 |
select count(*) from t2; |
| 42 |
|
| 43 |
# Using IN(...) we can create even more parallel cascading scans. |
| 44 |
# This becomes a batch of PK deletes where triggers are executed |
| 45 |
# at the end. |
| 46 |
|
| 47 |
--disable_query_log |
| 48 |
let $i=256; |
| 49 |
let $s=0; |
| 50 |
while ($i) |
| 51 |
{ |
| 52 |
eval insert into t1 values ($i); |
| 53 |
eval insert into t2 values ($i,$i); |
| 54 |
let $s=$s,$i; |
| 55 |
dec $i; |
| 56 |
} |
| 57 |
--enable_query_log |
| 58 |
|
| 59 |
--eval begin; delete from t1 where a1 in ($s); rollback |
| 60 |
select count(*) from t1; |
| 61 |
select count(*) from t2; |
| 62 |
|
| 63 |
--eval delete from t1 where a1 in ($s) |
| 64 |
select count(*) from t1; |
| 65 |
select count(*) from t2; |
| 66 |
|
| 67 |
drop table t2, t1; |