To delete a record, you need to perform the following actions:
/* read and then lock the first record */
ctdbFirstRecord(hRecord);
ctdbLockRecord (hRecord, CTLOCK_WRITE);
/* delete the record */
if (ctdbDeleteRecord(hRecord) != CTDBRET_OK)
printf("Delete record failed\n");
Note that using this manual locking scheme is not the safest approach, because a manual record lock cannot be applied until after the record is read from disk. This means there is a window of opportunity for the record to be modified or deleted by another thread before the record is manually locked by this thread. Fortunately, the FairCom DB API API provides a safer locking mechanism than manually locking individual records: session-wide record locking. This locking mechanism automatically locks records as they are read from disk, thereby removing the window of opportunity, resulting in improved data security. Session-wide record locking is discussed further in Data Integrity.