The mi_unlock_memory() function
The mi_unlock_memory() function unlocks a named-memory block specified by name and memory duration.
Syntax
mi_integer mi_unlock_memory(mem_name, duration)
mi_string *mem_name;
MI_MEMORY_DURATION duration;
- mem_name
- The null-terminated name of the named-memory block to unlock.
- duration
- A value that specifies the memory duration of the named-memory
block to unlock. Valid values for duration are:
- PER_ROUTINE
- For the duration of one iteration of the UDR
- PER_COMMAND
- For the duration of the execution of the current subquery
- PER_STATEMENT (Deprecated)
- For the duration of the current SQL statement
- PER_STMT_EXEC
- For the duration of the execution of the current SQL statement
- PER_STMT_PREP
- For the duration of the current prepared SQL statement
- PER_TRANSACTION
- For the duration of one transaction
- PER_SESSION
- For the duration of the current client session
- PER_SYSTEM
- For the duration of the database server execution
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
No | Yes |
Important: This advanced function can adversely
affect your UDR if you use the function incorrectly. Use it only when
no regular DataBlade
API function
can perform the task you need done.
Usage
The mi_unlock_memory() function
releases a lock on the named-memory block based on its memory duration
of duration and its name, which mem_name references.
The database server does not release any locks you acquire on named
memory. You must ensure that your code uses the mi_unlock_memory() function
to release locks in the following cases:
- Immediately after you are done accessing the named memory
- Before you raise an exception with the mi_db_error_raise() function
- Before you call another DataBlade API function that raises an exception internally (For more information, see the HCL Informix® DataBlade API Programmer's Guide.)
- Before the session ends
- Before the memory duration of the named memory expires
- Before you attempt to free the named memory with the mi_named_free() function
Important: After you obtain a lock on a named-memory
block, you must explicitly release it with the mi_unlock_memory() function.
Failure to release a lock before one of the previous conditions occurs
can severely impact the operation of the database server.
Return values
- MI_OK
- The function successfully unlocked the specified named-memory block.
- MI_NO_SUCH_NAME
- The requested named-memory block does not exist for the specified duration.
- MI_ERROR
- The function was not successful.