Mechanism for passing MI_DATUM values

The routine manager pushes MI_DATUM values onto the thread stack before it invokes the routine. The MI_DATUM structures contain the data in its internal database format. The size of the MI_DATUM data type determines whether the routine manager passes a particular argument by value or by reference, as follows:
  • The routine manager passes most argument values by reference; that is, it passes a pointer to the actual argument value.

    If the argument value has a data type whose size is greater than the size of the MI_DATUM data type, the routine manager passes the argument by reference because it cannot fit the actual value onto the stack. Instead, the MI_DATUM structure that the routine manager pushes onto the stack contains a pointer to the value. The routine manager allocates the memory for these pass-by-reference arguments with a PER_ROUTINE duration.

  • The routine manager passes a few special types of argument by value; that is, the MI_DATUM structure contains the actual argument value.

    If the argument value is a data type whose size is less than or equal to the size of the MI_DATUM data type, the routine manager passes the argument by value because it can fit the actual value onto the stack.

Types of values that fit in an MI_DATUM structure (Passed by value) lists the data types that the routine manager passes by value. All arguments whose data type is listed in this figure are passed by value unless the argument is an OUT parameter. OUT parameters are never passed by value; they are always passed by reference. The routine manager passes by reference any argument whose data type is not listed in Types of values that fit in an MI_DATUM structure (Passed by value).
Tip: For a particular argument data type, you can determine from its type descriptor whether it is passed by reference or passed by value with the mi_type_byvalue() function.

For information about how to code routine parameters, see Define routine parameters. For information about how the routine manager passes return values out of a UDR, see Return the value.