18 #define DBTUX_MAINT_CPP
26 Dbtux::execTUX_MAINT_REQ(
Signal* signal)
32 c_indexPool.
getPtr(indexPtr, sig->indexId);
34 if (unlikely(! (indexPtr.p->m_state == Index::Online ||
35 indexPtr.p->m_state == Index::Building)))
39 if (debugFlags & DebugMaint) {
40 TupLoc tupLoc(sig->pageId, sig->pageIndex);
41 debugOut <<
"opInfo=" << hex << sig->opInfo;
42 debugOut <<
" tableId=" << dec << sig->tableId;
43 debugOut <<
" indexId=" << dec << sig->indexId;
44 debugOut <<
" fragId=" << dec << sig->fragId;
45 debugOut <<
" tupLoc=" << tupLoc;
46 debugOut <<
" tupVersion=" << dec << sig->tupVersion;
47 debugOut <<
" -- ignored at ISP=" << dec << c_internalStartPhase;
48 debugOut <<
" TOS=" << dec << c_typeOfStart;
58 const Uint32 opCode = req->opInfo & 0xFF;
59 const Uint32 opFlag = req->opInfo >> 8;
61 ndbrequire(indexPtr.p->m_tableId == req->tableId);
63 const Uint32 fragId = req->fragId;
66 findFrag(*indexPtr.p, fragId, fragPtr);
67 ndbrequire(fragPtr.i != RNIL);
68 Frag& frag = *fragPtr.p;
71 ent.m_tupLoc = TupLoc(req->pageId, req->pageIndex);
72 ent.m_tupVersion = req->tupVersion;
74 KeyData searchKey(indexPtr.p->m_keySpec,
false, 0);
75 searchKey.set_buf(c_ctx.c_searchKey, MaxAttrDataSize << 2);
76 readKeyAttrs(c_ctx, frag, ent, searchKey, indexPtr.p->m_numAttrs);
77 if (unlikely(! indexPtr.p->m_storeNullKey) &&
78 searchKey.get_null_cnt() == indexPtr.p->m_numAttrs) {
83 if (debugFlags & DebugMaint) {
84 debugOut <<
"opCode=" << dec << opCode;
85 debugOut <<
" opFlag=" << dec << opFlag;
86 debugOut <<
" tableId=" << dec << req->tableId;
87 debugOut <<
" indexId=" << dec << req->indexId;
88 debugOut <<
" fragId=" << dec << req->fragId;
89 debugOut <<
" entry=" << ent;
98 case TuxMaintReq::OpAdd:
100 ok = searchToAdd(c_ctx, frag, searchKey, ent, treePos);
102 if (debugFlags & DebugMaint) {
103 debugOut << treePos << (! ok ?
" - error" :
"") << endl;
109 if (indexPtr.p->m_state == Index::Online) {
111 req->errorCode = TuxMaintReq::SearchError;
119 if (frag.m_freeLoc == NullTupLoc) {
121 NodeHandle node(frag);
122 req->errorCode = allocNode(c_ctx, node);
123 if (req->errorCode != 0) {
127 frag.m_freeLoc = node.m_loc;
128 ndbrequire(frag.m_freeLoc != NullTupLoc);
130 treeAdd(c_ctx, frag, treePos, ent);
132 frag.m_entryBytes += searchKey.get_data_len();
135 case TuxMaintReq::OpRemove:
137 ok = searchToRemove(c_ctx, frag, searchKey, ent, treePos);
139 if (debugFlags & DebugMaint) {
140 debugOut << treePos << (! ok ?
" - error" :
"") << endl;
146 if (indexPtr.p->m_state == Index::Online) {
148 req->errorCode = TuxMaintReq::SearchError;
152 treeRemove(frag, treePos);
153 ndbrequire(frag.m_entryCount != 0);
155 frag.m_entryBytes -= searchKey.get_data_len();
163 if (debugFlags & DebugTree) {
164 printTree(signal, frag, debugOut);