A CTDB_ON_TABLE_GET_SCHEMA callback is invoked after the FairCom DB data and index files are open and the CTDB_ON_TABLE_OPEN callback is invoked. This callback is also invoked after the FairCom DB data file record schema object is loaded into the table handle.
You may use the CTDB_ON_TABLE_GET_SCHEMA callback event to modify FairCom DB schema information stored in the table handle. You should typecast the table handle to a pCTDBTABLE structure pointer. The following CTDBTABLE structure members keep schema information:
CTDBTABLE Structure Member |
Explanation |
---|---|
pConvMap schemaptr |
c-tree ConvMap structure pointer |
VRLEN schema_size |
size in bytes of allocated ConvMap structure |
At the point a CTDB_ON_TABLE_GET_SCHEMA callback is invoked, the table’s schema has already been loaded and stored in the schemaptr member of CTDBTABLE structure. The schema_size member contains the allocated size of schemaptr.
FairCom DB API C API Example
CTDBRET ctdbDECL OnTableGetSchema(CTHANDLE Handle)
{
CTDBRET Retval = CTDBRET_OK;
pCTDBTABLE pTable = (pCTDBTABLE)Handle;
if (!pTable)
Retval = CTDBRET_NOTTABLE;
else
{
/* change the field padding byte */
if (pTable->schemaptr)
pTable->schemaptr->padding = ' ';
}
return Retval;
}