Release routine resources

A function descriptor for a UDR has a memory duration of PER_COMMAND. Therefore, a function descriptor remains active until one of the following events occurs:
  • The mi_routine_end() function frees the function descriptor.
  • The end of the current SQL command is reached.
  • The mi_close() function closes the current connection.

To conserve resources, use the mi_routine_end() function to explicitly deallocate the function descriptor when your DataBlade® API module no longer needs it. The mi_routine_end() function is the destructor function for a function descriptor. It frees the function descriptor and any resources that are associated with it.

The following call to mi_routine_end() explicitly releases the resources for the fdesc function descriptor that the code in Obtaining a function descriptor for the numeric_func() function and Executing the numeric_func() function with INTEGER arguments uses:
if ( mi_routine_end(conn, fdesc) != MI_OK )
   /* handle error */
   ...
Important: It is recommended that you explicitly deallocate function descriptors with mi_routine_end() once you no longer need them. Otherwise, these function descriptors remain until the end of the associated SQL command.
Server only:
If your UDR accesses any session-duration function descriptors, these descriptors have a memory duration of PER_SESSION. Therefore, they remain active until the end of the session. You can explicitly deallocate them with mi_routine_end().
Restriction: Session-duration function descriptors are an advanced feature of the DataBlade® API. Do not use session-duration function descriptors unless regular function descriptors (PER_COMMAND) cannot perform the task you need done.