| 1 |
# |
| 2 |
# Testing insert and select on a table with two threads |
| 3 |
# using locking |
| 4 |
# |
| 5 |
|
| 6 |
-- source include/have_maria.inc |
| 7 |
set global aria_page_checksum=1; |
| 8 |
|
| 9 |
--disable_warnings |
| 10 |
drop table if exists t1; |
| 11 |
--enable_warnings |
| 12 |
|
| 13 |
connect (con1,localhost,root,,); |
| 14 |
connection con1; |
| 15 |
|
| 16 |
create table t1 (i int) engine=aria; |
| 17 |
show create table t1; |
| 18 |
|
| 19 |
# versioning is disabled when table is empty, so insert a row |
| 20 |
insert into t1 values (0); |
| 21 |
|
| 22 |
lock tables t1 write concurrent; |
| 23 |
insert into t1 values (1); |
| 24 |
insert into t1 values (2); |
| 25 |
/* should see 0, 1 and 2 */ |
| 26 |
select i from t1; |
| 27 |
select count(*) from t1; |
| 28 |
|
| 29 |
connect (con2,localhost,root,,); |
| 30 |
connection con2; |
| 31 |
/* should see 0 */ |
| 32 |
select i from t1; |
| 33 |
select count(*) from t1; |
| 34 |
lock tables t1 write concurrent; |
| 35 |
insert into t1 values (3); |
| 36 |
insert into t1 values (4); |
| 37 |
/* should see 0, 3 and 4 */ |
| 38 |
select i from t1; |
| 39 |
select count(*) from t1; |
| 40 |
unlock tables; |
| 41 |
lock tables t1 write concurrent; |
| 42 |
insert into t1 values (5); |
| 43 |
/* should see 0, 3, 4 and 5 */ |
| 44 |
select i from t1; |
| 45 |
select count(*) from t1; |
| 46 |
|
| 47 |
connect (con3,localhost,root,,); |
| 48 |
connection con3; |
| 49 |
lock tables t1 write concurrent; |
| 50 |
/* should see 0, 3, 4 */ |
| 51 |
select i from t1; |
| 52 |
select count(*) from t1; |
| 53 |
|
| 54 |
connection con1; |
| 55 |
insert into t1 values (6); |
| 56 |
/* Should see 0, 1, 2, 6 */ |
| 57 |
select i from t1; |
| 58 |
select count(*) from t1; |
| 59 |
unlock tables; |
| 60 |
lock tables t1 write concurrent; |
| 61 |
/* Should see 0, 1, 2, 3, 4 and 6 */ |
| 62 |
select i from t1; |
| 63 |
select count(*) from t1; |
| 64 |
|
| 65 |
connection con2; |
| 66 |
/* should see 0, 3, 4, 5 */ |
| 67 |
select i from t1; |
| 68 |
select count(*) from t1; |
| 69 |
unlock tables; |
| 70 |
/* should see 0, 1, 2, 3, 4, 5, 6 */ |
| 71 |
select i from t1; |
| 72 |
select count(*) from t1; |
| 73 |
|
| 74 |
connection con1; |
| 75 |
unlock tables; |
| 76 |
/* should see 0, 1, 2, 3, 4, 5, 6 */ |
| 77 |
select i from t1; |
| 78 |
select count(*) from t1; |
| 79 |
|
| 80 |
connection con3; |
| 81 |
insert into t1 values (7); |
| 82 |
/* should see 0, 3, 4, 7 */ |
| 83 |
select i from t1; |
| 84 |
select count(*) from t1; |
| 85 |
unlock tables; |
| 86 |
/* should see 0, 1, 2, 3, 4, 5, 6, 7 */ |
| 87 |
select i from t1; |
| 88 |
select count(*) from t1; |
| 89 |
|
| 90 |
connection default; |
| 91 |
drop table t1; |
| 92 |
|
| 93 |
# |
| 94 |
# Test count(*) for not versioned tables |
| 95 |
# |
| 96 |
|
| 97 |
CREATE TABLE t1 (fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, g GEOMETRY NOT NULL, SPATIAL KEY(g) ) transactional=1 row_format=page engine=aria; |
| 98 |
|
| 99 |
lock tables t1 write concurrent, t1 as t2 write concurrent; |
| 100 |
insert into t1 (fid,g) values (NULL,GeomFromText('LineString(0 0,1 1)')); |
| 101 |
select fid from t1 as t2; |
| 102 |
select count(*) from t1 as t2; |
| 103 |
insert into t1 (fid,g) values (NULL,GeomFromText('LineString(0 0,1 1)')); |
| 104 |
select fid from t1 as t2; |
| 105 |
select count(*) from t1 as t2; |
| 106 |
unlock tables; |
| 107 |
drop table t1; |
| 108 |
|