When a UDR calls a DataBlade API memory-allocation function, the memory exists until the duration assigned to that memory expires. The database server stores memory in pools by duration. By default, memory-allocation functions assign a PER_ROUTINE duration to memory. The database server automatically frees PER_ROUTINE memory after the UDR that allocates the memory completes.
An SQL statement typically invokes many UDRs to perform a table task. Memory that stores state information must persist across all the UDR calls that the statement requires. The default PER_ROUTINE duration does not allow memory to persist for an entire SQL statement.
Use the mi_dalloc() function to specify a memory duration for a particular new memory allocation. If you do not specify a duration, the default duration applies. You can change the default from PER_ROUTINE to a different duration with the mi_switch_mem_duration() function. The following list describes memory durations that an access method typically specifies:
You must store a pointer to the PER_COMMAND, PER_STMT_EXEC, or PER_STMT_PREP memory so that multiple UDRs that execute during the command or statement can retrieve and reference the pointer to access the memory.
For detailed information about the following, refer to the IBM Informix: DataBlade API Programmer's Guide:
For more information about semipublic functions and named memory, see the indexing information on the IBM Informix Developer Zone at www.ibm.com/software/data/developer/informix. Look for the following titles from the list of tech notes: