23 #include "TraceNdbApi.hpp"
27 NdbMutex* g_pNdbMutexTrace = 0;
34 g_pNdbMutexTrace = NdbMutex_Create();
36 NdbMutex_Lock(g_pNdbMutexTrace);
44 NdbMutex_Unlock(g_pNdbMutexTrace);
47 void TraceMethod(
const char* szMethod)
49 ndbout <<
"->" << szMethod <<
"(";
53 void TraceParamComma(
void)
62 void TraceNdb(
Ndb* pNdb)
65 ndbout <<
"((Ndb*)" << hex << (Uint32)pNdb <<
")";
71 ndbout <<
"((NdbSchemaCon*)" << hex << (Uint32)pNdbSchemaCon <<
")";
77 ndbout <<
"((NdbSchemaOp*)" << hex << (Uint32)pNdbSchemaOp <<
")";
83 ndbout <<
"((NdbConnection*)" << hex << (Uint32)pNdbConnection <<
")";
89 ndbout <<
"((NdbOperation*)" << hex << (Uint32)pNdbOperation <<
")";
95 ndbout <<
"((NdbIndexOperation*)" << hex << (Uint32)pNdbIndexOperation <<
")";
101 ndbout <<
"((NdbRecAttr*)" << hex << (Uint32)pNdbRecAttr <<
")";
104 void TraceTable(Table* pTable)
107 ndbout <<
"((Table*)" << hex << (Uint32)pTable <<
")";
110 void TraceString(
const char* szParam)
113 ndbout <<
"\"" << szParam <<
"\"";
116 void TraceInt(
const int i)
119 ndbout <<
"(int)" << dec <<
i;
122 void TraceUint32(
const Uint32
n)
125 ndbout <<
"(Uint32)" << dec <<
n;
128 void TraceKeyType(
const KeyType aKeyType)
133 case Undefined: ndbout <<
"Undefined";
break;
134 case NoKey: ndbout <<
"NoKey";
break;
135 case TupleKey: ndbout <<
"TupleKey";
break;
136 case TupleId: ndbout <<
"TupleId";
break;
137 default: ndbout <<
"(KeyType)" << aKeyType;
break;
141 void TraceExecType(
const ExecType aExecType)
145 case NoExecTypeDef: ndbout <<
"NoExecTypeDef";
break;
146 case Prepare: ndbout <<
"Prepare";
break;
147 case NoCommit: ndbout <<
"NoCommit";
break;
148 case Commit: ndbout <<
"Commit";
break;
149 case Rollback: ndbout <<
"Rollback";
break;
150 default: ndbout <<
"(ExecType)" << aExecType;
break;
155 void TraceNdbError(
const NdbError& err)
158 ndbout <<
"(NdbError)" << err;
168 void TraceReturn(
void)
170 ndbout <<
"); // return ";
177 int CTraceNdbSchemaOp::createTable(
const char* aTableName)
181 TraceNdbSchemaOp(
this);
182 TraceMethod(
"createTable");
183 TraceString(aTableName);
190 int CTraceNdbSchemaOp::createAttribute(
const char* aAttrName, KeyType aTupleyKey)
194 TraceNdbSchemaOp(
this);
195 TraceMethod(
"createAttribute");
196 TraceString(aAttrName);
197 TraceKeyType(aTupleyKey);
208 CTraceNdbSchemaOp* CTraceNdbSchemaCon::getNdbSchemaOp()
212 TraceNdbSchemaCon(
this);
213 TraceMethod(
"getNdbSchemaOp");
215 TraceNdbSchemaOp(pNdbSchemaOp);
217 return (CTraceNdbSchemaOp*)pNdbSchemaOp;
220 int CTraceNdbSchemaCon::execute()
224 TraceNdbSchemaCon(
this);
225 TraceMethod(
"execute");
236 Uint32 CTraceNdbRecAttr::u_32_value()
240 TraceNdbRecAttr(
this);
241 TraceMethod(
"u_32_value");
252 int CTraceNdbOperation::insertTuple()
256 TraceNdbOperation(
this);
257 TraceMethod(
"insertTuple");
264 int CTraceNdbOperation::updateTuple()
268 TraceNdbOperation(
this);
269 TraceMethod(
"updateTuple");
276 int CTraceNdbOperation::interpretedUpdateTuple()
280 TraceNdbOperation(
this);
281 TraceMethod(
"interpretedUpdateTuple");
288 int CTraceNdbOperation::readTuple()
292 TraceNdbOperation(
this);
293 TraceMethod(
"readTuple");
301 int CTraceNdbOperation::readTupleExclusive()
305 TraceNdbOperation(
this);
306 TraceMethod(
"readTupleExclusive");
314 int CTraceNdbOperation::deleteTuple()
318 TraceNdbOperation(
this);
319 TraceMethod(
"deleteTuple");
326 int CTraceNdbOperation::equal(
const char* anAttrName, Uint32 aValue)
330 TraceNdbOperation(
this);
331 TraceMethod(
"equal");
332 TraceString(anAttrName);
340 int CTraceNdbOperation::setValue(
const char* anAttrName, Uint32 aValue)
344 TraceNdbOperation(
this);
345 TraceMethod(
"setValue");
346 TraceString(anAttrName);
354 int CTraceNdbOperation::incValue(
const char* anAttrName, Uint32 aValue)
358 TraceNdbOperation(
this);
359 TraceMethod(
"incValue");
360 TraceString(anAttrName);
368 CTraceNdbRecAttr* CTraceNdbOperation::getValue(
const char* anAttrName)
372 TraceNdbOperation(
this);
373 TraceMethod(
"getValue");
374 TraceString(anAttrName);
376 TraceNdbRecAttr(pNdbRecAttr);
378 return (CTraceNdbRecAttr*)pNdbRecAttr;
384 int CTraceNdbIndexOperation::equal(
const char* anAttrName, Uint32 aValue)
388 TraceNdbIndexOperation(
this);
389 TraceMethod(
"equal");
390 TraceString(anAttrName);
399 int CTraceNdbIndexOperation::incValue(
const char* anAttrName, Uint32 aValue)
403 TraceNdbIndexOperation(
this);
404 TraceMethod(
"incValue");
405 TraceString(anAttrName);
414 CTraceNdbRecAttr* CTraceNdbIndexOperation::getValue(
const char* anAttrName)
418 TraceNdbIndexOperation(
this);
419 TraceMethod(
"getValue");
420 TraceString(anAttrName);
422 TraceNdbRecAttr(pNdbRecAttr);
424 return (CTraceNdbRecAttr*)pNdbRecAttr;
430 CTraceNdbOperation* CTraceNdbConnection::getNdbOperation(
const char* aTableName)
434 TraceNdbConnection(
this);
435 TraceMethod(
"getNdbOperation");
436 TraceString(aTableName);
438 TraceNdbOperation(pNdbOperation);
440 return (CTraceNdbOperation*)pNdbOperation;
443 CTraceNdbIndexOperation* CTraceNdbConnection::getNdbIndexOperation(
const char* anIndexName,
const char* aTableName)
447 TraceNdbConnection(
this);
448 TraceMethod(
"getNdbIndexOperation");
449 TraceString(anIndexName);
450 TraceString(aTableName);
452 TraceNdbIndexOperation(pNdbIndexOperation);
454 return (CTraceNdbIndexOperation*)pNdbIndexOperation;
457 int CTraceNdbConnection::execute(ExecType aTypeOfExec)
461 TraceNdbConnection(
this);
462 TraceMethod(
"execute");
463 TraceExecType(aTypeOfExec);
470 const NdbError & CTraceNdbConnection::getNdbError(
void)
const
474 TraceNdbConnection(
this);
475 TraceMethod(
"getNdbError");
486 CTraceNdb::CTraceNdb(
const char* aDataBase)
492 TraceString(aDataBase);
498 CTraceNdbSchemaCon* CTraceNdb::startSchemaTransaction()
500 NdbSchemaCon* pNdbSchemaCon = Ndb::startSchemaTransaction();
503 TraceMethod(
"startSchemaTransaction");
505 TraceNdbSchemaCon(pNdbSchemaCon);
507 return (CTraceNdbSchemaCon*)pNdbSchemaCon;
510 void CTraceNdb::closeSchemaTransaction(CTraceNdbSchemaCon* aSchemaCon)
512 Ndb::closeSchemaTransaction(aSchemaCon);
515 TraceMethod(
"closeSchemaTransaction");
521 CTraceNdbConnection* CTraceNdb::startTransaction()
526 TraceMethod(
"startTransaction");
528 TraceNdbConnection(pNdbConnection);
530 return (CTraceNdbConnection*)pNdbConnection;
533 void CTraceNdb::closeTransaction(CTraceNdbConnection* aConnection)
538 TraceMethod(
"closeTransaction");
539 TraceNdbConnection(aConnection);