Home | Previous Page | Next Page   Creating User-Defined Routines > Writing a User-Defined Routine > Controlling the VP Environment >

Locking a UDR

If the UDR determines that its VP environment is correct and needs to remain as it is, the UDR can perform either of the following tasks.

Lock UDR DataBlade API Function
Lock the UDR to the current VP mi_udr_lock( )
Lock the shared-object file that contains the UDR into memory mi_module_lock( )

Locking a Routine Instance to a VP

If your UDR allocates resources that are process specific, it needs to be locked onto the VP where it started execution. When you write a UDR that needs access to global process information, you must take either of the following actions:

Important:
These solutions do not address resource allocations that last longer than the individual routine sequence in a statement or subquery. nor do they address the general issue of reclaiming resources for these sequences.

Locking a Shared-Object File in Memory

If the set of UDRs in a shared-object file requires a lot of initialization or uses external resources, it can be costly to have the routine manager continually load and unload this shared-object file. To prevent the routine manager from unloading a shared-object file, use the mi_module_lock( ) function. When you call mi_module_lock( ) with an argument of MI_TRUE, you set the module-lock flag, which locks the shared-object file in memory. Therefore, the routine manager does not allow the shared-object file to be unloaded for any reason.

This feature enables a DataBlade (or group of related UDRs) to prevent its shared-object file from being unloaded in any of the following cases:

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