Commit 66e82554 authored by mskold/marty@mysql.com/linux.site's avatar mskold/marty@mysql.com/linux.site

Merge mysql.com:/windows/Linux_space/MySQL/mysql-4.1

into  mysql.com:/windows/Linux_space/MySQL/mysql-5.0
parents d03b39aa 6a3143e2
...@@ -64,17 +64,26 @@ pk u o ...@@ -64,17 +64,26 @@ pk u o
insert into t1 values (1,1,1); insert into t1 values (1,1,1);
drop table t1; drop table t1;
create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; 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; begin;
select * from t1 where x = 1 for update; select * from t1 where x = 1 for update;
x y z x y z
1 one 1 1 one 1
begin; 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 x y z
2 two 2 1 one 1
select * from t1 where x = 1 for update; select * from t1 where x = 1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1 where x = 2 for update;
x y z
2 two 2
rollback; rollback;
commit; commit;
begin; begin;
......
...@@ -73,7 +73,7 @@ drop table t1; ...@@ -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; 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 # PK access
connection con1; connection con1;
...@@ -82,11 +82,22 @@ select * from t1 where x = 1 for update; ...@@ -82,11 +82,22 @@ select * from t1 where x = 1 for update;
connection con2; connection con2;
begin; begin;
select * from t1 where x = 2 for update;
--error 1205 --error 1205
select * from t1 where x = 1 for update; select * from t1 where x = 1 for update;
rollback; 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; connection con1;
commit; commit;
......
...@@ -140,6 +140,7 @@ class NdbTransaction ...@@ -140,6 +140,7 @@ class NdbTransaction
friend class NdbIndexOperation; friend class NdbIndexOperation;
friend class NdbIndexScanOperation; friend class NdbIndexScanOperation;
friend class NdbBlob; friend class NdbBlob;
friend class ha_ndbcluster;
#endif #endif
public: public:
...@@ -791,6 +792,7 @@ private: ...@@ -791,6 +792,7 @@ private:
// optim: any blobs // optim: any blobs
bool theBlobFlag; bool theBlobFlag;
Uint8 thePendingBlobOps; Uint8 thePendingBlobOps;
inline bool hasBlobOperation() { return theBlobFlag; }
static void sendTC_COMMIT_ACK(NdbApiSignal *, static void sendTC_COMMIT_ACK(NdbApiSignal *,
Uint32 transId1, Uint32 transId2, Uint32 transId1, Uint32 transId2,
......
...@@ -235,6 +235,7 @@ int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans) ...@@ -235,6 +235,7 @@ int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans)
if (m_batch_execute) if (m_batch_execute)
return 0; return 0;
#endif #endif
h->release_completed_operations(trans);
return trans->execute(NdbTransaction::NoCommit, return trans->execute(NdbTransaction::NoCommit,
NdbTransaction::AbortOnError, NdbTransaction::AbortOnError,
h->m_force_send); h->m_force_send);
...@@ -274,6 +275,7 @@ int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans) ...@@ -274,6 +275,7 @@ int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans)
if (m_batch_execute) if (m_batch_execute)
return 0; return 0;
#endif #endif
h->release_completed_operations(trans);
return trans->execute(NdbTransaction::NoCommit, return trans->execute(NdbTransaction::NoCommit,
NdbTransaction::AO_IgnoreError, NdbTransaction::AO_IgnoreError,
h->m_force_send); h->m_force_send);
...@@ -2928,6 +2930,26 @@ int ha_ndbcluster::close_scan() ...@@ -2928,6 +2930,26 @@ int ha_ndbcluster::close_scan()
NdbScanOperation *cursor= m_active_cursor ? m_active_cursor : m_multi_cursor; 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->lockTuple()))
{
m_lock_tuple= false;
ERR_RETURN(trans->getNdbError());
}
m_ops_pending++;
}
m_lock_tuple= false;
if (m_ops_pending) if (m_ops_pending)
{ {
/* /*
...@@ -5986,6 +6008,17 @@ int ha_ndbcluster::write_ndb_file() ...@@ -5986,6 +6008,17 @@ int ha_ndbcluster::write_ndb_file()
DBUG_RETURN(error); DBUG_RETURN(error);
} }
void
ha_ndbcluster::release_completed_operations(NdbConnection *trans)
{
if (trans->hasBlobOperation())
{
/* We are reading/writing BLOB fields,
releasing operation records is unsafe
*/
return;
}
trans->releaseCompletedOperations();
int int
ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p,
KEY_MULTI_RANGE *ranges, KEY_MULTI_RANGE *ranges,
......
...@@ -716,6 +716,8 @@ private: ...@@ -716,6 +716,8 @@ private:
bool m_force_send; bool m_force_send;
ha_rows m_autoincrement_prefetch; ha_rows m_autoincrement_prefetch;
bool m_transaction_on; bool m_transaction_on;
void release_completed_operations(NdbConnection*);
Ndb_cond_stack *m_cond_stack; Ndb_cond_stack *m_cond_stack;
bool m_disable_multi_read; bool m_disable_multi_read;
byte *m_multi_range_result_ptr; byte *m_multi_range_result_ptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment