18 #include <signaldata/NodeFailRep.hpp>
19 #include <signaldata/ReadNodesConf.hpp>
21 #include <signaldata/DumpStateOrd.hpp>
22 #include <signaldata/DbinfoScan.hpp>
23 #include <signaldata/TransIdAI.hpp>
26 #ifdef DBINFO_SCAN_TRACE
27 #include <debugger/DebuggerNames.hpp>
30 Uint32 dbinfo_blocks[] = { DBACC, DBTUP, BACKUP, DBTC, SUMA, DBUTIL,
31 TRIX, DBTUX, DBDICT, CMVMI, DBLQH, LGMAN,
42 addRecSignal(GSN_STTOR, &Dbinfo::execSTTOR);
43 addRecSignal(GSN_DUMP_STATE_ORD, &Dbinfo::execDUMP_STATE_ORD);
44 addRecSignal(GSN_READ_CONFIG_REQ, &Dbinfo::execREAD_CONFIG_REQ,
true);
46 addRecSignal(GSN_DBINFO_SCANREQ, &Dbinfo::execDBINFO_SCANREQ);
47 addRecSignal(GSN_DBINFO_SCANCONF, &Dbinfo::execDBINFO_SCANCONF);
49 addRecSignal(GSN_NODE_FAILREP, &Dbinfo::execNODE_FAILREP);
50 addRecSignal(GSN_INCL_NODEREQ, &Dbinfo::execINCL_NODEREQ);
67 void Dbinfo::execREAD_CONFIG_REQ(
Signal *signal)
71 Uint32 ref = req->senderRef;
72 Uint32 senderData = req->senderData;
77 conf->senderRef = reference();
78 conf->senderData = senderData;
79 sendSignal(ref, GSN_READ_CONFIG_CONF, signal,
80 ReadConfigConf::SignalLength, JBB);
83 void Dbinfo::sendSTTORRY(
Signal* signal)
85 signal->theData[0] = 0;
86 signal->theData[3] = 1;
87 signal->theData[4] = 3;
88 signal->theData[5] = 255;
89 sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 6, JBB);
92 void Dbinfo::execDUMP_STATE_ORD(
Signal* signal)
96 switch(signal->theData[0])
98 case DumpStateOrd::DbinfoListTables:
100 ndbout_c(
"--- BEGIN NDB$INFO.TABLES ---");
101 for(
int i = 0;
i < Ndbinfo::getNumTables();
i++)
104 ndbout_c(
"%d,%s",
i, tab.m.name);
106 ndbout_c(
"--- END NDB$INFO.TABLES ---");
109 case DumpStateOrd::DbinfoListColumns:
111 ndbout_c(
"--- BEGIN NDB$INFO.COLUMNS ---");
112 for(
int i = 0;
i < Ndbinfo::getNumTables();
i++)
116 for(
int j = 0; j < tab.m.ncols; j++)
117 ndbout_c(
"%d,%d,%s,%d",
i, j,
118 tab.col[j].name, tab.col[j].coltype);
120 ndbout_c(
"--- END NDB$INFO.COLUMNS ---");
127 Uint32 Dbinfo::find_next_block(Uint32
block)
const
131 while (dbinfo_blocks[i] != block &&
132 dbinfo_blocks[i] != 0)
136 ndbrequire(dbinfo_blocks[i]);
139 return dbinfo_blocks[++
i];
143 switchRef(Uint32 block, Uint32 node)
145 const Uint32 ref = numberToRef(block, node);
146 #ifdef DBINFO_SCAN_TRACE
147 ndbout_c(
"Dbinfo: switching to %s in node %d, ref: 0x%.8x",
148 getBlockName(block,
"<unknown>"), node, ref);
156 Uint32 node = refToNode(cursor->currRef);
157 Uint32 block = refToBlock(cursor->currRef);
158 const Uint32 instance = refToInstance(cursor->currRef);
159 ndbrequire(instance == 0);
165 ndbrequire(block == 0);
166 cursor->currRef = switchRef(dbinfo_blocks[0], getOwnNodeId());
174 ndbrequire(node == getOwnNodeId());
175 block = find_next_block(block);
179 cursor->currRef = switchRef(block, node);
189 void Dbinfo::execDBINFO_SCANREQ(
Signal *signal)
193 const Uint32 senderRef = signal->header.theSendersBlockRef;
198 const Uint32 resultData = req.resultData;
199 const Uint32 transId0 = req.transId[0];
200 const Uint32 transId1 = req.transId[1];
201 const Uint32 resultRef = req.resultRef;
204 const Uint32 tableId = req.tableId;
205 if (tableId >= (Uint32)Ndbinfo::getNumTables())
209 ref->resultData = resultData;
210 ref->transId[0] = transId0;
211 ref->transId[1] = transId1;
212 ref->resultRef = resultRef;
213 ref->errorCode= DbinfoScanRef::NoTable;
214 sendSignal(senderRef, GSN_DBINFO_SCANREF, signal,
215 DbinfoScanRef::SignalLength, JBB);
223 Uint32 signal_length = signal->getLength();
224 if (signal_length == DbinfoScanReq::SignalLength)
228 cursor->senderRef = senderRef;
229 cursor->saveSenderRef = 0;
231 cursor->saveCurrRef = 0;
233 memset(cursor->data, 0,
sizeof(cursor->data));
235 cursor->totalRows = 0;
236 cursor->totalBytes = 0;
237 req.cursor_sz = Ndbinfo::ScanCursor::Length;
238 signal_length += req.cursor_sz;
240 ndbrequire(signal_length ==
241 DbinfoScanReq::SignalLength + Ndbinfo::ScanCursor::Length);
242 ndbrequire(req.cursor_sz == Ndbinfo::ScanCursor::Length);
246 case Ndbinfo::TABLES_TABLEID:
251 Uint32 tableId = cursor->data[0];
253 while(tableId < (Uint32)Ndbinfo::getNumTables())
258 row.write_uint32(tableId);
259 row.write_string(tab.m.name);
260 row.write_string(tab.m.comment);
261 ndbinfo_send_row(signal, req, row, rl);
265 if (rl.need_break(req))
268 ndbinfo_send_scan_break(signal, req, rl, tableId);
275 ndbinfo_send_scan_conf(signal, req, rl);
281 case Ndbinfo::COLUMNS_TABLEID:
286 Uint32 tableId = cursor->data[0];
287 Uint32 columnId = cursor->data[1];
289 while(tableId < (Uint32)Ndbinfo::getNumTables())
293 while(columnId < (Uint32)tab.m.ncols)
297 row.write_uint32(tableId);
298 row.write_uint32(columnId);
299 row.write_string(tab.col[columnId].name);
300 row.write_uint32(tab.col[columnId].coltype);
301 row.write_string(tab.col[columnId].comment);
302 ndbinfo_send_row(signal, req, row, rl);
304 assert(columnId < 256);
307 if(rl.need_break(req))
310 ndbinfo_send_scan_break(signal, req, rl, tableId, columnId);
320 ndbinfo_send_scan_conf(signal, req, rl);
329 ndbassert(tableId > 1);
334 if (Ndbinfo::ScanCursor::getHasMoreData(cursor->
flags) ||
338 ndbrequire(cursor->currRef);
341 cursor->senderRef = reference();
344 MEMCOPY_NO_WORDS(req_ptr,
345 &req, signal_length);
346 sendSignal(cursor->currRef,
348 signal, signal_length, JBB);
355 MEMCOPY_NO_WORDS(apiconf, &req, DbinfoScanConf::SignalLength);
357 apiconf->cursor_sz = 0;
358 sendSignal(resultRef, GSN_DBINFO_SCANCONF, signal,
359 DbinfoScanConf::SignalLength, JBB);
366 void Dbinfo::execDBINFO_SCANCONF(
Signal *signal)
376 Uint32 signal_length = signal->getLength();
377 ndbrequire(signal_length ==
378 DbinfoScanReq::SignalLength+Ndbinfo::ScanCursor::Length);
379 ndbrequire(conf.cursor_sz == Ndbinfo::ScanCursor::Length);
382 const Uint32 tableId= conf.tableId;
383 ndbassert(tableId < (Uint32)Ndbinfo::getNumTables());
385 const Uint32 resultRef = conf.resultRef;
388 ndbrequire(conf.cursor_sz);
392 if (Ndbinfo::ScanCursor::getHasMoreData(cursor->
flags) || conf.returnedRows)
396 ndbrequire(cursor->currRef);
398 MEMCOPY_NO_WORDS(apiconf, &conf, signal_length);
399 sendSignal(resultRef, GSN_DBINFO_SCANCONF, signal, signal_length, JBB);
403 if (find_next(cursor))
406 ndbrequire(cursor->currRef);
409 cursor->senderRef = reference();
412 MEMCOPY_NO_WORDS(signal->getDataPtrSend(),
413 &conf, signal_length);
414 sendSignal(cursor->currRef,
416 signal, signal_length, JBB);
423 MEMCOPY_NO_WORDS(apiconf, &conf, DbinfoScanConf::SignalLength);
426 apiconf->cursor_sz = 0;
427 sendSignal(resultRef, GSN_DBINFO_SCANCONF, signal,
428 DbinfoScanConf::SignalLength, JBB);
433 void Dbinfo::execINCL_NODEREQ(
Signal* signal)
437 const Uint32 senderRef = signal->theData[0];
438 const Uint32 inclNode = signal->theData[1];
440 signal->theData[0] = inclNode;
441 signal->theData[1] = reference();
442 sendSignal(senderRef, GSN_INCL_NODECONF, signal, 2, JBB);
445 void Dbinfo::execNODE_FAILREP(
Signal* signal)
451 Uint32 theFailedNodes[NdbNodeBitmask::Size];
452 for (Uint32 i = 0; i < NdbNodeBitmask::Size; i++)
453 theFailedNodes[i] = rep->theNodes[i];
455 for (Uint32 i = 0; i < MAX_NDB_NODES; i++)
460 ndbassert(elementsCleaned == 0);
461 (void) elementsCleaned;