Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

CTDB_ON_DATABASE_CONNECT

A CTDB_ON_DATABASE_CONNECT callback is invoked after a successful database connect but before the ctdbConnect() function returns. The handle passed as a parameter with this callback is a database handle and you can safely typecast the handle parameter to a pCTDBDATABASE structure pointer.

The database connect callback can be used as an indication that the database connection is now active and that table processing may occur. This callback is a good place to set database-wide parameters that may be active until a database disconnect is performed.

Below is an example demonstrating the database connect callback to set table open and table close callbacks.

c-treeDB API C API Example


CTDBRET ctdbDECL OnDatabaseConnect(CTHANDLE Handle)

{

CTDBRET Retval = CTDBRET_OK;

pCTDBDATABASE pDatabase = (pCTDBDATABASE)Handle;

if (!pDatabase)

Retval = CTDBRET_NOTDATABASE;

else

{

Retval = ctdbSetCallback(Handle, CTDB_ON_TABLE_OPEN, onTableOpen);

if (Retval == CTDBRET_OK)

Retval = ctdbSetCallback(Handle, CTDB_ON_TABLE_CLOSE, onTableClose);

}

return Retval;

}

TOCIndex