Loading mysql-test/r/ndb_lock.result +12 −3 Original line number Diff line number Diff line Loading @@ -64,17 +64,26 @@ pk u o insert into t1 values (1,1,1); drop table t1; create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3); insert into t1 values (1,'one',1); begin; select * from t1 where x = 1 for update; x y z 1 one 1 begin; select * from t1 where x = 2 for update; select * from t1 where x = 1 for update; ERROR HY000: Lock wait timeout exceeded; try restarting transaction rollback; rollback; insert into t1 values (2,'two',2),(3,"three",3); begin; select * from t1 where x = 1 for update; x y z 2 two 2 1 one 1 select * from t1 where x = 1 for update; ERROR HY000: Lock wait timeout exceeded; try restarting transaction select * from t1 where x = 2 for update; x y z 2 two 2 rollback; commit; begin; Loading mysql-test/t/ndb_lock.test +13 −2 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ drop table t1; create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3); insert into t1 values (1,'one',1); # PK access connection con1; Loading @@ -82,11 +82,22 @@ select * from t1 where x = 1 for update; connection con2; begin; select * from t1 where x = 2 for update; --error 1205 select * from t1 where x = 1 for update; rollback; connection con1; rollback; insert into t1 values (2,'two',2),(3,"three",3); begin; select * from t1 where x = 1 for update; connection con2; --error 1205 select * from t1 where x = 1 for update; select * from t1 where x = 2 for update; rollback; connection con1; commit; Loading sql/ha_ndbcluster.cc +20 −0 Original line number Diff line number Diff line Loading @@ -2929,6 +2929,26 @@ int ha_ndbcluster::close_scan() NdbScanOperation *cursor= m_active_cursor ? m_active_cursor : m_multi_cursor; if (m_lock_tuple) { /* Lock level m_lock.type either TL_WRITE_ALLOW_WRITE (SELECT FOR UPDATE) or TL_READ_WITH_SHARED_LOCKS (SELECT LOCK WITH SHARE MODE) and row was not explictly unlocked with unlock_row() call */ NdbOperation *op; // Lock row DBUG_PRINT("info", ("Keeping lock on scanned row")); if (!(op= cursor->lockCurrentTuple())) { m_lock_tuple= false; ERR_RETURN(trans->getNdbError()); } m_ops_pending++; } m_lock_tuple= false; if (m_ops_pending) { /* Loading Loading
mysql-test/r/ndb_lock.result +12 −3 Original line number Diff line number Diff line Loading @@ -64,17 +64,26 @@ pk u o insert into t1 values (1,1,1); drop table t1; create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3); insert into t1 values (1,'one',1); begin; select * from t1 where x = 1 for update; x y z 1 one 1 begin; select * from t1 where x = 2 for update; select * from t1 where x = 1 for update; ERROR HY000: Lock wait timeout exceeded; try restarting transaction rollback; rollback; insert into t1 values (2,'two',2),(3,"three",3); begin; select * from t1 where x = 1 for update; x y z 2 two 2 1 one 1 select * from t1 where x = 1 for update; ERROR HY000: Lock wait timeout exceeded; try restarting transaction select * from t1 where x = 2 for update; x y z 2 two 2 rollback; commit; begin; Loading
mysql-test/t/ndb_lock.test +13 −2 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ drop table t1; create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3); insert into t1 values (1,'one',1); # PK access connection con1; Loading @@ -82,11 +82,22 @@ select * from t1 where x = 1 for update; connection con2; begin; select * from t1 where x = 2 for update; --error 1205 select * from t1 where x = 1 for update; rollback; connection con1; rollback; insert into t1 values (2,'two',2),(3,"three",3); begin; select * from t1 where x = 1 for update; connection con2; --error 1205 select * from t1 where x = 1 for update; select * from t1 where x = 2 for update; rollback; connection con1; commit; Loading
sql/ha_ndbcluster.cc +20 −0 Original line number Diff line number Diff line Loading @@ -2929,6 +2929,26 @@ int ha_ndbcluster::close_scan() NdbScanOperation *cursor= m_active_cursor ? m_active_cursor : m_multi_cursor; if (m_lock_tuple) { /* Lock level m_lock.type either TL_WRITE_ALLOW_WRITE (SELECT FOR UPDATE) or TL_READ_WITH_SHARED_LOCKS (SELECT LOCK WITH SHARE MODE) and row was not explictly unlocked with unlock_row() call */ NdbOperation *op; // Lock row DBUG_PRINT("info", ("Keeping lock on scanned row")); if (!(op= cursor->lockCurrentTuple())) { m_lock_tuple= false; ERR_RETURN(trans->getNdbError()); } m_ops_pending++; } m_lock_tuple= false; if (m_ops_pending) { /* Loading