Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbUnlock

Disables or suspends session-wide record locking and releases some record locks.

Declaration

CTDBRET ctdbUnlock(CTHANDLE Handle)

Description

ctdbUnlock() disables or suspends session-wide record locking, so any records read after calling this function will NOT be automatically locked. Also, ctdbUnlock() releases some (but not all) of the record locks, as described below. Calling this function is the same as calling ctdbLock() with the lock mode CTLOCK_FREE.

  • Handle [in] a Session or any other Handle.

This function behaves differently if called inside or outside of a transaction. ("Inside a transaction" means that ctdbBegin() was called, but ctdbCommit() / ctdbAbort() was NOT called.)

Inside a Transaction - Session-wide record locking is suspended. All currently-locked records remain locked. This means both records automatically locked via the session-wide record locking mechanism (call ctdbLock() and then read a record), and records manually locked by calling ctdbLockRecord() on an individual record. Later, when the transaction is finished (by calling ctdbCommit() or ctdbAbort()), the locks on these records will be released. To restore session-wide locking (un-suspend it), call ctdbLock() with one of the READ or WRITE lock modes (or one of the RESTORE options).

Outside a Transaction - Session-wide record locking is turned off. All records that were automatically locked via the session-wide record locking mechanism (call ctdbLock() and then read a record) are unlocked. All records that were manually locked by calling ctdbLockRecord() on an individual record remain locked, EXCEPT for records from a CTCREATE_NORMAL table that were modified and then written before this function was called; those records are unlocked.

To release record locks that were manually obtained with ctdbLockRecord(), use ctdbUnlockRecord().

If the unused locks from a particular table must be released inside a transaction, ctdbUnlockTable() may be used. Unused locks are records that where locked but not updated/deleted/added.

Returns

ctdbUnlock() returns CTDBRET_OK on success, or FairCom DB API C API error code on failure.

Example


if (ctdbIsLockActive(pSession))

ctdbUnlock(pSession);


See also

ctdbLock(), ctdbIsLockActive(), ctdbGetLockMode(), ctdbUnlockRecord(), ctdbUnlockTable(), Locking

TOCIndex