A CTDB_ON_RECORD_INIT callback is invoked when the record is initialized because it is being used for the first time or after an alter table. The handle passed as a parameter with this callback is a record handle and you can safely typecast the handle parameter to a pCTDBRECORD structure pointer.
The record init callback can be used as an indication that the record handle is becoming active and records operations may occur from this point.
The following CTDBRECORD structure members keep information regarding the record buffer kept by the record handle:
CTDBRECORD Structure Member |
Explanation |
---|---|
pUTEXT recbuf |
record buffer |
VRLEN recbuf_size |
size in bytes of memory allocated for record buffer |
VRLEN recbuf_len |
actual length of data in record buffer |
FairCom DB API C API Example
CTDBRET ctdbDECL OnRecordInit(CTHANDLE Handle)
{
CTDBRET Retval = CTDBRET_OK;
pCTDBRECORD pRecord = (pCTDBRECORD)Handle;
if (!pRecord)
Retval = CTDBRET_NOTRECORD;
else
{
/* allocate a paralell record buffer and store it in the localTag */
pRecord->localTag = pRecord->pSession ? pRecord->pSession->onAlloc(pRecord->recbuf_size) : NULL;
if (!pRecord->localTag)
Retval = CTDBRET_OK;
}
return Retval;
}