A CTDB_ON_RECORD_BEFORE_READ callback is invoked just before a record is read by one of the FairCom DB record reading functions. This callback is useful to prepare a record buffer just before data is read.
The handle passed as parameter for this callback is a record handle and you can safely typecast the handle parameter to a pCTDBRECORD structure pointer.
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 |
c-treeDB API C API Example
CTDBRET ctdbDECL OnRecordBeforeRead(CTHANDLE Handle)
{
CTDBRET Retval = CTDBRET_OK;
pCTDBRECORD pRecord = (pCTDBRECORD)Handle;
if (!pRecord)
Retval = CTDBRET_NOTRECORD;
else
{
/* swap the record buffer with the localTag */
pUTEXT ptr = pRecord->recbuf;
pRecord->recbuf = pRecord->localTag;
pRecord->localTag = ptr;
}
return Retval;
}