| 1 |
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; |
| 2 |
create table t1 (x integer not null primary key, y varchar(32)) engine = ndb; |
| 3 |
insert into t1 values (1,'one'), (2,'two'); |
| 4 |
select * from t1 order by x; |
| 5 |
x y |
| 6 |
1 one |
| 7 |
2 two |
| 8 |
select * from t1 order by x; |
| 9 |
x y |
| 10 |
1 one |
| 11 |
2 two |
| 12 |
start transaction; |
| 13 |
insert into t1 values (3,'three'); |
| 14 |
select * from t1 order by x; |
| 15 |
x y |
| 16 |
1 one |
| 17 |
2 two |
| 18 |
3 three |
| 19 |
start transaction; |
| 20 |
select * from t1 order by x; |
| 21 |
x y |
| 22 |
1 one |
| 23 |
2 two |
| 24 |
commit; |
| 25 |
select * from t1 order by x; |
| 26 |
x y |
| 27 |
1 one |
| 28 |
2 two |
| 29 |
3 three |
| 30 |
commit; |
| 31 |
drop table t1; |
| 32 |
create table t1 (pk integer not null primary key, u int not null, o int not null, |
| 33 |
unique(u), key(o)) engine = ndb; |
| 34 |
insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); |
| 35 |
lock tables t1 write; |
| 36 |
delete from t1 where pk = 1; |
| 37 |
unlock tables; |
| 38 |
select * from t1 order by pk; |
| 39 |
pk u o |
| 40 |
2 2 2 |
| 41 |
3 3 3 |
| 42 |
4 4 4 |
| 43 |
5 5 5 |
| 44 |
insert into t1 values (1,1,1); |
| 45 |
lock tables t1 write; |
| 46 |
delete from t1 where u = 1; |
| 47 |
unlock tables; |
| 48 |
select * from t1 order by pk; |
| 49 |
pk u o |
| 50 |
2 2 2 |
| 51 |
3 3 3 |
| 52 |
4 4 4 |
| 53 |
5 5 5 |
| 54 |
insert into t1 values (1,1,1); |
| 55 |
lock tables t1 write; |
| 56 |
delete from t1 where o = 1; |
| 57 |
unlock tables; |
| 58 |
select * from t1 order by pk; |
| 59 |
pk u o |
| 60 |
2 2 2 |
| 61 |
3 3 3 |
| 62 |
4 4 4 |
| 63 |
5 5 5 |
| 64 |
insert into t1 values (1,1,1); |
| 65 |
drop table t1; |
| 66 |
create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; |
| 67 |
insert into t1 values (1,'one',1); |
| 68 |
begin; |
| 69 |
select * from t1 where x = 1 for update; |
| 70 |
x y z |
| 71 |
1 one 1 |
| 72 |
begin; |
| 73 |
select * from t1 where x = 1 for update; |
| 74 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 75 |
rollback; |
| 76 |
rollback; |
| 77 |
insert into t1 values (2,'two',2),(3,"three",3); |
| 78 |
begin; |
| 79 |
select * from t1 where x = 1 for update; |
| 80 |
x y z |
| 81 |
1 one 1 |
| 82 |
select * from t1 where x = 1 for update; |
| 83 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 84 |
select * from t1 where x = 2 for update; |
| 85 |
x y z |
| 86 |
2 two 2 |
| 87 |
rollback; |
| 88 |
commit; |
| 89 |
begin; |
| 90 |
select * from t1 where y = 'one' or y = 'three' for update; |
| 91 |
x y z |
| 92 |
# # # |
| 93 |
# # # |
| 94 |
begin; |
| 95 |
select * from t1 where x = 2 for update; |
| 96 |
x y z |
| 97 |
2 two 2 |
| 98 |
select * from t1 where x = 1 for update; |
| 99 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 100 |
rollback; |
| 101 |
commit; |
| 102 |
begin; |
| 103 |
select * from t1 where y = 'one' or y = 'three' order by x for update; |
| 104 |
x y z |
| 105 |
1 one 1 |
| 106 |
3 three 3 |
| 107 |
begin; |
| 108 |
select * from t1 where x = 2 for update; |
| 109 |
x y z |
| 110 |
2 two 2 |
| 111 |
select * from t1 where x = 1 for update; |
| 112 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 113 |
rollback; |
| 114 |
commit; |
| 115 |
begin; |
| 116 |
select * from t1 where z > 1 and z < 3 for update; |
| 117 |
x y z |
| 118 |
2 two 2 |
| 119 |
begin; |
| 120 |
select * from t1 where x = 1 for update; |
| 121 |
x y z |
| 122 |
1 one 1 |
| 123 |
select * from t1 where x = 2 for update; |
| 124 |
Got one of the listed errors |
| 125 |
rollback; |
| 126 |
commit; |
| 127 |
begin; |
| 128 |
select * from t1 where x = 1 lock in share mode; |
| 129 |
x y z |
| 130 |
1 one 1 |
| 131 |
begin; |
| 132 |
select * from t1 where x = 1 lock in share mode; |
| 133 |
x y z |
| 134 |
1 one 1 |
| 135 |
select * from t1 where x = 2 for update; |
| 136 |
x y z |
| 137 |
2 two 2 |
| 138 |
select * from t1 where x = 1 for update; |
| 139 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 140 |
rollback; |
| 141 |
commit; |
| 142 |
begin; |
| 143 |
select * from t1 where y = 'one' or y = 'three' lock in share mode; |
| 144 |
x y z |
| 145 |
# # # |
| 146 |
# # # |
| 147 |
begin; |
| 148 |
select * from t1 where y = 'one' lock in share mode; |
| 149 |
x y z |
| 150 |
1 one 1 |
| 151 |
select * from t1 where x = 2 for update; |
| 152 |
x y z |
| 153 |
2 two 2 |
| 154 |
select * from t1 where x = 1 for update; |
| 155 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 156 |
rollback; |
| 157 |
commit; |
| 158 |
begin; |
| 159 |
select * from t1 where y = 'one' or y = 'three' order by x lock in share mode; |
| 160 |
x y z |
| 161 |
1 one 1 |
| 162 |
3 three 3 |
| 163 |
begin; |
| 164 |
select * from t1 where y = 'one' lock in share mode; |
| 165 |
x y z |
| 166 |
1 one 1 |
| 167 |
select * from t1 where x = 2 for update; |
| 168 |
x y z |
| 169 |
2 two 2 |
| 170 |
select * from t1 where x = 1 for update; |
| 171 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 172 |
rollback; |
| 173 |
commit; |
| 174 |
begin; |
| 175 |
select * from t1 where z > 1 and z < 3 lock in share mode; |
| 176 |
x y z |
| 177 |
2 two 2 |
| 178 |
begin; |
| 179 |
select * from t1 where z = 1 lock in share mode; |
| 180 |
x y z |
| 181 |
1 one 1 |
| 182 |
select * from t1 where x = 1 for update; |
| 183 |
x y z |
| 184 |
1 one 1 |
| 185 |
select * from t1 where x = 2 for update; |
| 186 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 187 |
rollback; |
| 188 |
commit; |
| 189 |
drop table t1; |
| 190 |
create table t3 (id2 int) engine=ndb; |
| 191 |
lock tables t3 write; |
| 192 |
unlock tables; |
| 193 |
drop table t3; |
| 194 |
create table t2 (id int, j int) engine=ndb; |
| 195 |
insert into t2 values (2, 2); |
| 196 |
create table t3 (id int) engine=ndb; |
| 197 |
lock tables t3 read; |
| 198 |
delete t2 from t2, t3 where t2.id = t3.id; |
| 199 |
unlock tables; |
| 200 |
drop table t2, t3; |