A resource can be deleted from a table by calling the following c-treeDB API C API function:
CTDBRET ctdbDECL ctdbDeleteResource(CTHANDLE resource);
Before the resource can be deleted, the table must be opened with exclusive mode CTOPEN_EXCLUSIVE.
After the resource is deleted, its name, number and name are reset.
c-treeDB API C API Delete Resource Example
/* delete a resource */
CTDBRET DelMyResource(CTHANDLE Handle, ULONG type, ULONG number, pTEXT name)
{
CTDBRET Retval;
CTHANDLE hRes = ctdbAllocResource(Handle, type, number, name);
if (hRes)
{
if ((Retval = ctdbDeleteResource(hRes)) != CTDBRET_OK)
printf("ctdbDeleteResource failed with error %d\n", Retval);
ctdbFreeResource(hRes);
}
else
{
printf("Failed to allocate resource handle\n");
Retval = CTDBRET_NOMEMORY;
}
return Retval;
}