A CTDB_ON_TABLE_ALTER callback is invoked at the beginning of the ctdbAlterTable function call, before any operations are performed on the table. This callback should be used to indicate if alter table operations are to be performed on a particular table.
If the alter table operation is allowed, then the callback function must returns CTDBRET_OK value. On the other hand, if alter table operations are not to be allowed, the callback function must return an error code. In case of error, the suggested error code is CTDBRET_NOTSUPPORTED.
The handle passed as a parameter with this callback is a table handle and you can safely typecast the handle parameter to a pCTDBTABLE structure pointer.
Below demonstrates an AlterTable() not allowed if table name is "mytable".
c-treeDB API C API Example
CTDBRET ctdbDECL OnTableAlter(CTHANDLE Handle)
{
CTDBRET Retval = CTDBRET_OK;
pCTDBTABLE pTable = (pCTDBTABLE)Handle;
if (pTable && pTable->name && strcmp(pTable->name, "mytable") == 0)
{
/* if table is 'mytable' alter table not allowed */
Retval = CTDBRET_NOTSUPPORTED;
}
return Retval;
}