The MI_FPARAM argument

The routine manager passes an MI_FPARAM structure into every UDR that it executes. This structure contains routine-state information about the UDR, such as information about arguments and return values. Because the routine manager automatically passes an MI_FPARAM structure to a UDR, you do not need to explicitly declare this structure in most C-function declarations.

You must include an MI_FPARAM declaration in the C-function declaration in the following cases:
  • You need to access routine-state information within the UDR.

    When you declare an MI_FPARAM parameter, this declaration must be the last parameter in the C declaration of your UDR. For more information about the DataBlade® API functions that access the routine-state information from MI_FPARAM, see Access MI_FPARAM routine-state information.

  • You declare a UDR that does not take any arguments.

    A C UDR always gets at least one argument: a pointer to the MI_FPARAM structure. When the parameter list of your SQL UDR is empty, you must still include a declaration for the MI_FPARAM structure, even if the UDR does not access routine-state information.

For example, the bigger_double() user-defined function in Passing arguments by reference does not include a declaration for the MI_FPARAM structure because it does not need to access routine-state information and it has other parameters. However, suppose you register a user-defined function named func_noargs() that does not require any arguments:
CREATE FUNCTION func_noargs() RETURNS INTEGER
   EXTERNAL NAME '/usr/lib/udrs/udrs.so' LANGUAGE C;
In the C UDR, you can declare the func_noargs() function with a single parameter, a pointer to the MI_FPARAM structure:
mi_integer func_noargs(MI_FPARAM *fparam)
{
...
}
The declaration of the MI_FPARAM structure allows the routine manager to pass this structure into the UDR.
Tip: If your C UDR does not declare an MI_FPARAM structure but determines dynamically that it needs information in this structure, it can use the mi_fparam_get_current() function to obtain a pointer to its MI_FPARAM structure. This function, however, is an advanced feature. Make sure you need it before you use it in a C UDR.