Home | Previous Page | Next Page   Data Manipulation > Using Smart Large Objects >

Using Byte-Range Locking

By default, the database server uses whole lock-all locks when it needs to lock a smart large object. Lock-all locks are an "all or nothing" lock; that is, they lock the entire smart large object. When the database server obtains an exclusive lock, no other user can access the data of the smart large object as long as the lock is held. (For more information on the default locking, see Locking Modes.)

If this locking is too restrictive for the concurrency requirements of your application, you can use byte-range locking instead of lock-all locking. With byte-range locking, you can specify the range of bytes to lock in the smart-large-object data. If other users access other portions of the data, they can still acquire their own byte-range lock.

To use byte-range locking
  1. Enable the byte-range locking feature on the smart large object you need to lock.

    You can specify the byte-range locking feature either when you create the smart large object or when you open it, as follows:

    • At the time of smart-large-object creation

      You can specify the LO_LOCKRANGE lock-mode constant as a default open flag for the new smart large object.

    • When you open the smart large object

      You can specify the LO_LOCKRANGE lock-mode constant in the open-mode argument of mi_lo_open( ).

  2. Handle the lock requests for the byte-range locks with the appropriate function of the smart-large-object interface.

    The smart-large-object interface provides the following functions for handle lock requests of byte-range locks.

Byte-Range Locking Function
Description
mi_lo_lock( )
Obtains a byte-range lock on the specified number of bytes in a smart large object
mi_lo_unlock( )
Releases a byte-range lock on a smart large object

With the mi_lo_lock( ) function, you can specify the following information for the lock request of the byte-range lock:

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]