Commit d9d7c785 authored by jonas@perch.ndb.mysql.com's avatar jonas@perch.ndb.mysql.com

Merge perch.ndb.mysql.com:/home/jonas/src/51-work

into  perch.ndb.mysql.com:/home/jonas/src/mysql-5.1-new-ndb
parents 79d8773e 5230dceb
...@@ -639,3 +639,6 @@ select a, sha1(b) from t1; ...@@ -639,3 +639,6 @@ select a, sha1(b) from t1;
a sha1(b) a sha1(b)
1 08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d 1 08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d
drop table t1; drop table t1;
create table t1(id int not null) engine = NDB;
alter table t1 add constraint uk_test unique (id) using hash;
drop table t1;
...@@ -329,4 +329,12 @@ select a, sha1(b) from t1; ...@@ -329,4 +329,12 @@ select a, sha1(b) from t1;
drop table t1; drop table t1;
# bug#21873 MySQLD Crash on ALTER...ADD..UNIQUE..USING HASH statement for NDB backed table
create table t1(id int not null) engine = NDB;
alter table t1 add constraint uk_test unique (id) using hash;
drop table t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -1399,9 +1399,8 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_key(uint inx, ...@@ -1399,9 +1399,8 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_key(uint inx,
ORDERED_INDEX); ORDERED_INDEX);
} }
int ha_ndbcluster::check_index_fields_not_null(uint inx) int ha_ndbcluster::check_index_fields_not_null(KEY* key_info)
{ {
KEY* key_info= table->key_info + inx;
KEY_PART_INFO* key_part= key_info->key_part; KEY_PART_INFO* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts; KEY_PART_INFO* end= key_part+key_info->key_parts;
DBUG_ENTER("ha_ndbcluster::check_index_fields_not_null"); DBUG_ENTER("ha_ndbcluster::check_index_fields_not_null");
...@@ -5017,7 +5016,7 @@ int ha_ndbcluster::create_index(const char *name, KEY *key_info, ...@@ -5017,7 +5016,7 @@ int ha_ndbcluster::create_index(const char *name, KEY *key_info,
error= create_unique_index(unique_name, key_info); error= create_unique_index(unique_name, key_info);
break; break;
case UNIQUE_INDEX: case UNIQUE_INDEX:
if (!(error= check_index_fields_not_null(idx_no))) if (!(error= check_index_fields_not_null(key_info)))
error= create_unique_index(unique_name, key_info); error= create_unique_index(unique_name, key_info);
break; break;
case ORDERED_INDEX: case ORDERED_INDEX:
......
...@@ -808,7 +808,7 @@ private: ...@@ -808,7 +808,7 @@ private:
NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const; NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const;
NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info, NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info,
bool primary) const; bool primary) const;
int check_index_fields_not_null(uint index_no); int check_index_fields_not_null(KEY *key_info);
uint set_up_partition_info(partition_info *part_info, uint set_up_partition_info(partition_info *part_info,
TABLE *table, TABLE *table,
......
...@@ -2036,6 +2036,7 @@ void handler::print_keydup_error(uint key_nr, const char *msg) ...@@ -2036,6 +2036,7 @@ void handler::print_keydup_error(uint key_nr, const char *msg)
{ {
/* Key is unknown */ /* Key is unknown */
str.length(0); str.length(0);
str.append(STRING_WITH_LEN(""));
key_nr= -1; key_nr= -1;
my_printf_error(ER_DUP_ENTRY, msg, my_printf_error(ER_DUP_ENTRY, msg,
MYF(0), str.c_ptr(), "*UNKNOWN*"); MYF(0), str.c_ptr(), "*UNKNOWN*");
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <AttributeHeader.hpp> #include <AttributeHeader.hpp>
#include <ArrayPool.hpp> #include <ArrayPool.hpp>
#include <DataBuffer.hpp> #include <DataBuffer.hpp>
#include <DLFifoList.hpp>
#include <md5_hash.hpp> #include <md5_hash.hpp>
// big brother // big brother
...@@ -338,6 +339,18 @@ private: ...@@ -338,6 +339,18 @@ private:
typedef DataBuffer<ScanBoundSegmentSize>::ConstDataBufferIterator ScanBoundIterator; typedef DataBuffer<ScanBoundSegmentSize>::ConstDataBufferIterator ScanBoundIterator;
typedef DataBuffer<ScanBoundSegmentSize>::DataBufferPool ScanBoundPool; typedef DataBuffer<ScanBoundSegmentSize>::DataBufferPool ScanBoundPool;
ScanBoundPool c_scanBoundPool; ScanBoundPool c_scanBoundPool;
// ScanLock
struct ScanLock {
Uint32 m_accLockOp;
union {
Uint32 nextPool;
Uint32 nextList;
};
Uint32 prevList;
};
typedef Ptr<ScanLock> ScanLockPtr;
ArrayPool<ScanLock> c_scanLockPool;
/* /*
* Scan operation. * Scan operation.
...@@ -384,6 +397,8 @@ private: ...@@ -384,6 +397,8 @@ private:
Uint32 m_savePointId; Uint32 m_savePointId;
// lock waited for or obtained and not yet passed to LQH // lock waited for or obtained and not yet passed to LQH
Uint32 m_accLockOp; Uint32 m_accLockOp;
// locks obtained and passed to LQH but not yet returned by LQH
DLFifoList<ScanLock>::Head m_accLockOps;
Uint8 m_readCommitted; // no locking Uint8 m_readCommitted; // no locking
Uint8 m_lockMode; Uint8 m_lockMode;
Uint8 m_descending; Uint8 m_descending;
...@@ -399,13 +414,6 @@ private: ...@@ -399,13 +414,6 @@ private:
Uint32 nextList; Uint32 nextList;
}; };
Uint32 prevList; Uint32 prevList;
/*
* Locks obtained and passed to LQH but not yet returned by LQH.
* The max was increased from 16 to 992 (default 64). Record max
* ever used in this scan. TODO fix quadratic behaviour
*/
Uint32 m_maxAccLockOps;
Uint32 m_accLockOps[MaxAccLockOps];
ScanOp(ScanBoundPool& scanBoundPool); ScanOp(ScanBoundPool& scanBoundPool);
}; };
typedef Ptr<ScanOp> ScanOpPtr; typedef Ptr<ScanOp> ScanOpPtr;
...@@ -625,8 +633,9 @@ private: ...@@ -625,8 +633,9 @@ private:
bool scanCheck(ScanOpPtr scanPtr, TreeEnt ent); bool scanCheck(ScanOpPtr scanPtr, TreeEnt ent);
bool scanVisible(ScanOpPtr scanPtr, TreeEnt ent); bool scanVisible(ScanOpPtr scanPtr, TreeEnt ent);
void scanClose(Signal* signal, ScanOpPtr scanPtr); void scanClose(Signal* signal, ScanOpPtr scanPtr);
void addAccLockOp(ScanOp& scan, Uint32 accLockOp); void abortAccLockOps(Signal* signal, ScanOpPtr scanPtr);
void removeAccLockOp(ScanOp& scan, Uint32 accLockOp); void addAccLockOp(ScanOpPtr scanPtr, Uint32 accLockOp);
void removeAccLockOp(ScanOpPtr scanPtr, Uint32 accLockOp);
void releaseScanOp(ScanOpPtr& scanPtr); void releaseScanOp(ScanOpPtr& scanPtr);
/* /*
...@@ -687,7 +696,8 @@ private: ...@@ -687,7 +696,8 @@ private:
DebugMeta = 1, // log create and drop index DebugMeta = 1, // log create and drop index
DebugMaint = 2, // log maintenance ops DebugMaint = 2, // log maintenance ops
DebugTree = 4, // log and check tree after each op DebugTree = 4, // log and check tree after each op
DebugScan = 8 // log scans DebugScan = 8, // log scans
DebugLock = 16 // log ACC locks
}; };
STATIC_CONST( DataFillByte = 0xa2 ); STATIC_CONST( DataFillByte = 0xa2 );
STATIC_CONST( NodeFillByte = 0xa4 ); STATIC_CONST( NodeFillByte = 0xa4 );
...@@ -944,6 +954,7 @@ Dbtux::ScanOp::ScanOp(ScanBoundPool& scanBoundPool) : ...@@ -944,6 +954,7 @@ Dbtux::ScanOp::ScanOp(ScanBoundPool& scanBoundPool) :
m_transId2(0), m_transId2(0),
m_savePointId(0), m_savePointId(0),
m_accLockOp(RNIL), m_accLockOp(RNIL),
m_accLockOps(),
m_readCommitted(0), m_readCommitted(0),
m_lockMode(0), m_lockMode(0),
m_descending(0), m_descending(0),
...@@ -951,18 +962,12 @@ Dbtux::ScanOp::ScanOp(ScanBoundPool& scanBoundPool) : ...@@ -951,18 +962,12 @@ Dbtux::ScanOp::ScanOp(ScanBoundPool& scanBoundPool) :
m_boundMax(scanBoundPool), m_boundMax(scanBoundPool),
m_scanPos(), m_scanPos(),
m_scanEnt(), m_scanEnt(),
m_nodeScan(RNIL), m_nodeScan(RNIL)
m_maxAccLockOps(0)
{ {
m_bound[0] = &m_boundMin; m_bound[0] = &m_boundMin;
m_bound[1] = &m_boundMax; m_bound[1] = &m_boundMax;
m_boundCnt[0] = 0; m_boundCnt[0] = 0;
m_boundCnt[1] = 0; m_boundCnt[1] = 0;
#ifdef VM_TRACE
for (unsigned i = 0; i < MaxAccLockOps; i++) {
m_accLockOps[i] = 0x1f1f1f1f;
}
#endif
} }
// Dbtux::Index // Dbtux::Index
......
...@@ -299,6 +299,7 @@ operator<<(NdbOut& out, const Dbtux::DescAttr& descAttr) ...@@ -299,6 +299,7 @@ operator<<(NdbOut& out, const Dbtux::DescAttr& descAttr)
NdbOut& NdbOut&
operator<<(NdbOut& out, const Dbtux::ScanOp& scan) operator<<(NdbOut& out, const Dbtux::ScanOp& scan)
{ {
Dbtux* tux = (Dbtux*)globalData.getBlock(DBTUX);
out << "[ScanOp " << hex << &scan; out << "[ScanOp " << hex << &scan;
out << " [state " << dec << scan.m_state << "]"; out << " [state " << dec << scan.m_state << "]";
out << " [lockwait " << dec << scan.m_lockwait << "]"; out << " [lockwait " << dec << scan.m_lockwait << "]";
...@@ -308,9 +309,15 @@ operator<<(NdbOut& out, const Dbtux::ScanOp& scan) ...@@ -308,9 +309,15 @@ operator<<(NdbOut& out, const Dbtux::ScanOp& scan)
out << " [savePointId " << dec << scan.m_savePointId << "]"; out << " [savePointId " << dec << scan.m_savePointId << "]";
out << " [accLockOp " << hex << scan.m_accLockOp << "]"; out << " [accLockOp " << hex << scan.m_accLockOp << "]";
out << " [accLockOps"; out << " [accLockOps";
for (unsigned i = 0; i < scan.m_maxAccLockOps; i++) { {
if (scan.m_accLockOps[i] != RNIL) DLFifoList<Dbtux::ScanLock>::Head head = scan.m_accLockOps;
out << " " << hex << scan.m_accLockOps[i]; LocalDLFifoList<Dbtux::ScanLock> list(tux->c_scanLockPool, head);
Dbtux::ScanLockPtr lockPtr;
list.first(lockPtr);
while (lockPtr.i != RNIL) {
out << " " << hex << lockPtr.p->m_accLockOp;
list.next(lockPtr);
}
} }
out << "]"; out << "]";
out << " [readCommitted " << dec << scan.m_readCommitted << "]"; out << " [readCommitted " << dec << scan.m_readCommitted << "]";
...@@ -336,13 +343,12 @@ operator<<(NdbOut& out, const Dbtux::ScanOp& scan) ...@@ -336,13 +343,12 @@ operator<<(NdbOut& out, const Dbtux::ScanOp& scan)
NdbOut& NdbOut&
operator<<(NdbOut& out, const Dbtux::Index& index) operator<<(NdbOut& out, const Dbtux::Index& index)
{ {
Dbtux* tux = (Dbtux*)globalData.getBlock(DBTUX);
out << "[Index " << hex << &index; out << "[Index " << hex << &index;
out << " [tableId " << dec << index.m_tableId << "]"; out << " [tableId " << dec << index.m_tableId << "]";
out << " [numFrags " << dec << index.m_numFrags << "]"; out << " [numFrags " << dec << index.m_numFrags << "]";
for (unsigned i = 0; i < index.m_numFrags; i++) { for (unsigned i = 0; i < index.m_numFrags; i++) {
out << " [frag " << dec << i << " "; out << " [frag " << dec << i << " ";
// dangerous and wrong
Dbtux* tux = (Dbtux*)globalData.getBlock(DBTUX);
const Dbtux::Frag& frag = *tux->c_fragPool.getPtr(index.m_fragPtrI[i]); const Dbtux::Frag& frag = *tux->c_fragPool.getPtr(index.m_fragPtrI[i]);
out << frag; out << frag;
out << "]"; out << "]";
......
...@@ -163,6 +163,7 @@ Dbtux::execREAD_CONFIG_REQ(Signal* signal) ...@@ -163,6 +163,7 @@ Dbtux::execREAD_CONFIG_REQ(Signal* signal)
Uint32 nFragment; Uint32 nFragment;
Uint32 nAttribute; Uint32 nAttribute;
Uint32 nScanOp; Uint32 nScanOp;
Uint32 nScanBatch;
const ndb_mgm_configuration_iterator * p = const ndb_mgm_configuration_iterator * p =
m_ctx.m_config.getOwnConfigIterator(); m_ctx.m_config.getOwnConfigIterator();
...@@ -172,9 +173,11 @@ Dbtux::execREAD_CONFIG_REQ(Signal* signal) ...@@ -172,9 +173,11 @@ Dbtux::execREAD_CONFIG_REQ(Signal* signal)
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_FRAGMENT, &nFragment)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_FRAGMENT, &nFragment));
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_ATTRIBUTE, &nAttribute)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_ATTRIBUTE, &nAttribute));
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_SCAN_OP, &nScanOp)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_SCAN_OP, &nScanOp));
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_BATCH_SIZE, &nScanBatch));
const Uint32 nDescPage = (nIndex * DescHeadSize + nAttribute * DescAttrSize + DescPageSize - 1) / DescPageSize; const Uint32 nDescPage = (nIndex * DescHeadSize + nAttribute * DescAttrSize + DescPageSize - 1) / DescPageSize;
const Uint32 nScanBoundWords = nScanOp * ScanBoundSegmentSize * 4; const Uint32 nScanBoundWords = nScanOp * ScanBoundSegmentSize * 4;
const Uint32 nScanLock = nScanOp * nScanBatch;
c_indexPool.setSize(nIndex); c_indexPool.setSize(nIndex);
c_fragPool.setSize(nFragment); c_fragPool.setSize(nFragment);
...@@ -182,6 +185,7 @@ Dbtux::execREAD_CONFIG_REQ(Signal* signal) ...@@ -182,6 +185,7 @@ Dbtux::execREAD_CONFIG_REQ(Signal* signal)
c_fragOpPool.setSize(MaxIndexFragments); c_fragOpPool.setSize(MaxIndexFragments);
c_scanOpPool.setSize(nScanOp); c_scanOpPool.setSize(nScanOp);
c_scanBoundPool.setSize(nScanBoundWords); c_scanBoundPool.setSize(nScanBoundWords);
c_scanLockPool.setSize(nScanLock);
/* /*
* Index id is physical array index. We seize and initialize all * Index id is physical array index. We seize and initialize all
* index records now. * index records now.
......
...@@ -313,7 +313,7 @@ Dbtux::execNEXT_SCANREQ(Signal* signal) ...@@ -313,7 +313,7 @@ Dbtux::execNEXT_SCANREQ(Signal* signal)
EXECUTE_DIRECT(DBACC, GSN_ACC_LOCKREQ, signal, AccLockReq::UndoSignalLength); EXECUTE_DIRECT(DBACC, GSN_ACC_LOCKREQ, signal, AccLockReq::UndoSignalLength);
jamEntry(); jamEntry();
ndbrequire(lockReq->returnCode == AccLockReq::Success); ndbrequire(lockReq->returnCode == AccLockReq::Success);
removeAccLockOp(scan, req->accOperationPtr); removeAccLockOp(scanPtr, req->accOperationPtr);
} }
if (req->scanFlag == NextScanReq::ZSCAN_COMMIT) { if (req->scanFlag == NextScanReq::ZSCAN_COMMIT) {
jam(); jam();
...@@ -469,7 +469,7 @@ Dbtux::execACC_CHECK_SCAN(Signal* signal) ...@@ -469,7 +469,7 @@ Dbtux::execACC_CHECK_SCAN(Signal* signal)
scan.m_state = ScanOp::Locked; scan.m_state = ScanOp::Locked;
scan.m_accLockOp = lockReq->accOpPtr; scan.m_accLockOp = lockReq->accOpPtr;
#ifdef VM_TRACE #ifdef VM_TRACE
if (debugFlags & DebugScan) { if (debugFlags & (DebugScan | DebugLock)) {
debugOut << "Lock immediate scan " << scanPtr.i << " " << scan << endl; debugOut << "Lock immediate scan " << scanPtr.i << " " << scan << endl;
} }
#endif #endif
...@@ -481,7 +481,7 @@ Dbtux::execACC_CHECK_SCAN(Signal* signal) ...@@ -481,7 +481,7 @@ Dbtux::execACC_CHECK_SCAN(Signal* signal)
scan.m_lockwait = true; scan.m_lockwait = true;
scan.m_accLockOp = lockReq->accOpPtr; scan.m_accLockOp = lockReq->accOpPtr;
#ifdef VM_TRACE #ifdef VM_TRACE
if (debugFlags & DebugScan) { if (debugFlags & (DebugScan | DebugLock)) {
debugOut << "Lock wait scan " << scanPtr.i << " " << scan << endl; debugOut << "Lock wait scan " << scanPtr.i << " " << scan << endl;
} }
#endif #endif
...@@ -537,7 +537,7 @@ Dbtux::execACC_CHECK_SCAN(Signal* signal) ...@@ -537,7 +537,7 @@ Dbtux::execACC_CHECK_SCAN(Signal* signal)
if (accLockOp != RNIL) { if (accLockOp != RNIL) {
scan.m_accLockOp = RNIL; scan.m_accLockOp = RNIL;
// remember it until LQH unlocks it // remember it until LQH unlocks it
addAccLockOp(scan, accLockOp); addAccLockOp(scanPtr, accLockOp);
} else { } else {
ndbrequire(scan.m_readCommitted); ndbrequire(scan.m_readCommitted);
// operation RNIL in LQH would signal no tuple returned // operation RNIL in LQH would signal no tuple returned
...@@ -592,7 +592,7 @@ Dbtux::execACCKEYCONF(Signal* signal) ...@@ -592,7 +592,7 @@ Dbtux::execACCKEYCONF(Signal* signal)
c_scanOpPool.getPtr(scanPtr); c_scanOpPool.getPtr(scanPtr);
ScanOp& scan = *scanPtr.p; ScanOp& scan = *scanPtr.p;
#ifdef VM_TRACE #ifdef VM_TRACE
if (debugFlags & DebugScan) { if (debugFlags & (DebugScan | DebugLock)) {
debugOut << "Lock obtained scan " << scanPtr.i << " " << scan << endl; debugOut << "Lock obtained scan " << scanPtr.i << " " << scan << endl;
} }
#endif #endif
...@@ -637,7 +637,7 @@ Dbtux::execACCKEYREF(Signal* signal) ...@@ -637,7 +637,7 @@ Dbtux::execACCKEYREF(Signal* signal)
c_scanOpPool.getPtr(scanPtr); c_scanOpPool.getPtr(scanPtr);
ScanOp& scan = *scanPtr.p; ScanOp& scan = *scanPtr.p;
#ifdef VM_TRACE #ifdef VM_TRACE
if (debugFlags & DebugScan) { if (debugFlags & (DebugScan | DebugLock)) {
debugOut << "Lock refused scan " << scanPtr.i << " " << scan << endl; debugOut << "Lock refused scan " << scanPtr.i << " " << scan << endl;
} }
#endif #endif
...@@ -681,7 +681,7 @@ Dbtux::execACC_ABORTCONF(Signal* signal) ...@@ -681,7 +681,7 @@ Dbtux::execACC_ABORTCONF(Signal* signal)
c_scanOpPool.getPtr(scanPtr); c_scanOpPool.getPtr(scanPtr);
ScanOp& scan = *scanPtr.p; ScanOp& scan = *scanPtr.p;
#ifdef VM_TRACE #ifdef VM_TRACE
if (debugFlags & DebugScan) { if (debugFlags & (DebugScan | DebugLock)) {
debugOut << "ACC_ABORTCONF scan " << scanPtr.i << " " << scan << endl; debugOut << "ACC_ABORTCONF scan " << scanPtr.i << " " << scan << endl;
} }
#endif #endif
...@@ -1016,18 +1016,9 @@ Dbtux::scanClose(Signal* signal, ScanOpPtr scanPtr) ...@@ -1016,18 +1016,9 @@ Dbtux::scanClose(Signal* signal, ScanOpPtr scanPtr)
ScanOp& scan = *scanPtr.p; ScanOp& scan = *scanPtr.p;
ndbrequire(! scan.m_lockwait && scan.m_accLockOp == RNIL); ndbrequire(! scan.m_lockwait && scan.m_accLockOp == RNIL);
// unlock all not unlocked by LQH // unlock all not unlocked by LQH
for (unsigned i = 0; i < scan.m_maxAccLockOps; i++) { if (! scan.m_accLockOps.isEmpty()) {
if (scan.m_accLockOps[i] != RNIL) { jam();
jam(); abortAccLockOps(signal, scanPtr);
AccLockReq* const lockReq = (AccLockReq*)signal->getDataPtrSend();
lockReq->returnCode = RNIL;
lockReq->requestInfo = AccLockReq::Abort;
lockReq->accOpPtr = scan.m_accLockOps[i];
EXECUTE_DIRECT(DBACC, GSN_ACC_LOCKREQ, signal, AccLockReq::UndoSignalLength);
jamEntry();
ndbrequire(lockReq->returnCode == AccLockReq::Success);
scan.m_accLockOps[i] = RNIL;
}
} }
// send conf // send conf
NextScanConf* const conf = (NextScanConf*)signal->getDataPtrSend(); NextScanConf* const conf = (NextScanConf*)signal->getDataPtrSend();
...@@ -1041,44 +1032,76 @@ Dbtux::scanClose(Signal* signal, ScanOpPtr scanPtr) ...@@ -1041,44 +1032,76 @@ Dbtux::scanClose(Signal* signal, ScanOpPtr scanPtr)
} }
void void
Dbtux::addAccLockOp(ScanOp& scan, Uint32 accLockOp) Dbtux::abortAccLockOps(Signal* signal, ScanOpPtr scanPtr)
{ {
ndbrequire(accLockOp != RNIL); ScanOp& scan = *scanPtr.p;
Uint32* list = scan.m_accLockOps; #ifdef VM_TRACE
bool ok = false; if (debugFlags & (DebugScan | DebugLock)) {
for (unsigned i = 0; i < scan.m_maxAccLockOps; i++) { debugOut << "Abort locks in scan " << scanPtr.i << " " << scan << endl;
ndbrequire(list[i] != accLockOp);
if (! ok && list[i] == RNIL) {
list[i] = accLockOp;
ok = true;
// continue check for duplicates
}
} }
if (! ok) { #endif
unsigned i = scan.m_maxAccLockOps; LocalDLFifoList<ScanLock> list(c_scanLockPool, scan.m_accLockOps);
if (i < MaxAccLockOps) { ScanLockPtr lockPtr;
list[i] = accLockOp; while (list.first(lockPtr)) {
ok = true; jam();
scan.m_maxAccLockOps = i + 1; AccLockReq* const lockReq = (AccLockReq*)signal->getDataPtrSend();
} lockReq->returnCode = RNIL;
lockReq->requestInfo = AccLockReq::Abort;
lockReq->accOpPtr = lockPtr.p->m_accLockOp;
EXECUTE_DIRECT(DBACC, GSN_ACC_LOCKREQ, signal, AccLockReq::UndoSignalLength);
jamEntry();
ndbrequire(lockReq->returnCode == AccLockReq::Success);
list.release(lockPtr);
} }
ndbrequire(ok);
} }
void void
Dbtux::removeAccLockOp(ScanOp& scan, Uint32 accLockOp) Dbtux::addAccLockOp(ScanOpPtr scanPtr, Uint32 accLockOp)
{ {
ScanOp& scan = *scanPtr.p;
#ifdef VM_TRACE
if (debugFlags & (DebugScan | DebugLock)) {
debugOut << "Add lock " << hex << accLockOp << dec
<< " to scan " << scanPtr.i << " " << scan << endl;
}
#endif
LocalDLFifoList<ScanLock> list(c_scanLockPool, scan.m_accLockOps);
ScanLockPtr lockPtr;
#ifdef VM_TRACE
list.first(lockPtr);
while (lockPtr.i != RNIL) {
ndbrequire(lockPtr.p->m_accLockOp != accLockOp);
list.next(lockPtr);
}
#endif
bool ok = list.seize(lockPtr);
ndbrequire(ok);
ndbrequire(accLockOp != RNIL); ndbrequire(accLockOp != RNIL);
Uint32* list = scan.m_accLockOps; lockPtr.p->m_accLockOp = accLockOp;
bool ok = false; }
for (unsigned i = 0; i < scan.m_maxAccLockOps; i++) {
if (list[i] == accLockOp) { void
list[i] = RNIL; Dbtux::removeAccLockOp(ScanOpPtr scanPtr, Uint32 accLockOp)
ok = true; {
ScanOp& scan = *scanPtr.p;
#ifdef VM_TRACE
if (debugFlags & (DebugScan | DebugLock)) {
debugOut << "Remove lock " << hex << accLockOp << dec
<< " from scan " << scanPtr.i << " " << scan << endl;
}
#endif
LocalDLFifoList<ScanLock> list(c_scanLockPool, scan.m_accLockOps);
ScanLockPtr lockPtr;
list.first(lockPtr);
while (lockPtr.i != RNIL) {
if (lockPtr.p->m_accLockOp == accLockOp) {
jam();
break; break;
} }
list.next(lockPtr);
} }
ndbrequire(ok); ndbrequire(lockPtr.i != RNIL);
list.release(lockPtr);
} }
/* /*
......
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