Reference counts for opaque-type columns

The database server does not automatically manage the reference count for an opaque type that contains a smart large object (including multirepresentational opaque types).

For these opaque-type columns, you must explicitly manage the reference count in special support functions of the opaque data type, as follows.
Support function Reference-count task DataBlade® API function
assign() Increment the reference count by one each time a new LO handle for the smart large object is saved in the database. mi_lo_increfcount()
destroy() Decrement the reference count by one each time an LO handle that is stored in the database is removed from the database. mi_lo_decrefcount()
lohandles() If the opaque type does not have an lohandles() support function, you must handle the reference count in the assign() and destroy() support functions.

If the opaque type has an lohandles() support function, you do not need to handle the reference count in the assign() and destroy() support functions. The database server handles the decrement of the reference count when it executes the lohandles() support function.

If you increment or decrement the reference count for a smart large object within a transaction causing it to end up with a value of zero, the database server automatically deletes the smart large object at the end of the transaction (as long as it has no open LO file descriptors).