Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

CTDB_ON_TABLE_GET_DODA

A CTDB_ON_TABLE_GET_DODA callback is invoked after FairCom DB data and index files are open and the CTDB_ON_TABLE_OPEN and CTDB_ON_TABLE_GET_SCHEMA callbacks have been invoked. This callback is also invoked after the FairCom DB data file record schema and DODA object are loaded into the table handle.

You can use the CTDB_ON_TABLE_GET_DODA callback event to modify the FairCom DB DODA stored in the table handle. You should typecast the table handle to a pCTDBTABLE structure pointer. The following CTDBTABLE structure members keep DODA information:

CTDBTABLE Structure Member

Explanation

pDATOBJ dodaptr

pointer to c-tree DODA

VRLEN doda_size

size in bytes of allocated DODA

VRLEN dodacount

number of fields in DODA

By the time a CTDB_ON_TABLE_GET_DODA callback is invoked, the table’s DODA has already been loaded and stored in the dodaptr member of CTDBTABLE structure. The doda_size member contains the allocated size of dodaptr and dodacount keep count of the number of fields described by dodaptr.

The example below shows how to use the CTDB_ON_TABLE_GET_DODA callback to modify the DODA information.

FairCom DB API C API Example


static DATOBJ newdoda[4] =

{

{"id", (pTEXT)0, CT_INT4U, 4},

{"who", (pTEXT)4, CT_INT2, 2},

{"when",(pTEXT)8, CT_TIMES, 8},

{"text",(pTEXT)16, CT_STRING, 0}

};

CTDBRET ctdbDECL OnTableGetDoda(CTHANDLE Handle)

{

CTDBRET Retval = CTDBRET_OK;

pCTDBTABLE pTable = (pCTDBTABLE)Handle;

NINT i;

/* check the table handle */

if (!pTable)

{

Retval = CTDBRET_NOTTABLE;

goto Exit;

}

/* fix the DODA */

for (i = 0; i < pLocal->dodacount; i++)

{

pTable->dodaptr[i].fadr = newdoda[i].fadr;

pTable->dodaptr[i].flen = newdoda[i].flen;

pTable->dodaptr[i].ftype = newdoda[i].ftype;

}

/* fix the IFIL index segment */

if (pTable->ifilptr && pTable->ifilptr->ix && pTable->ifilptr->ix[0].seg)

{

pTable->ifilptr->ix[0].seg->soffset = 0;

pTable->ifilptr->ix[0].seg->slength = 4;

pTable->ifilptr->ix[0].seg->segmode = CTSEG_SCHSEG;

}

Exit:

return Retval;

}

TOCIndex