ctdbSetDatabaseExclusive
Sets or clears the database exclusive flag.
Declaration
CTDBRET ctdbSetDatabaseExclusive(CTHANDLE Handle, CTBOOL flag);
Description
ctdbSetDatabaseExclusive() sets or clears the database exclusive flag. If a database exclusive flag is set, only one connection will be allowed on this database. Set the database exclusive flag after allocating the database handle, and before performing a connect. Setting the database exclusive flag after a database is connected will not have any effect during the current connection.
Return
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
CTDBRET_OK |
No error occurred. |
See Appendix A for a complete listing of valid c-tree Plus error values.
Example
/* perform an exclusive logon and connect */
CTHANDLE hSession = ctdbAllocSession(CTSESSION_CTDB);
CTHANDLE hDatabase = ctdbAllocDatabase(hSession);
if (hSession)
{
ctdbSetSessionExclusive(hSession, YES);
if (ctdbLogon(hSession, "FAIRCOM", "ADMIN", "ADMIN") != CTDBRET_OK)
printf("ctdbLogon failed\n");
else
{
ctdbSetDatabaseExclusive(hDatabase, YES);
if (ctdbConnect(hDatabase, "MyData") != CTDBRET_OK)
printf("ctdbConnect failed\n");
}
}
ctdbFreeDatabase(hDatabase);
ctdbFreeSession(hSession);
See Also
ctdbSetSessionExclusive(), ctdbIsSessionExclusive(), ctdbIsDatabaseExclusive()