Determine if a function is a commutator function

Before you execute a user-defined function with the Fastpath interface, you might want to determine whether this function has a commutator function.

If a user-defined function has either of the following characteristics, it is a commutator of another user-defined function:
  • A user-defined function takes the same arguments as another user-defined function, but in opposite order.
  • A user-defined function returns the same result as another user-defined function.

In many cases, a commutator function can be more efficient to execute than the actual user-defined function.

To determine whether a user-defined function has a commutator function, pass its function descriptor to the mi_func_commutator() function. This function determines whether the user-defined function associated with this function descriptor was registered with the COMMUTATOR routine modifier of the CREATE FUNCTION statement. If so, mi_func_commutator() returns the name of the commutator function (from the commutator column of the sysprocedures system catalog table). If the commutator is more efficient, you can use this function name to obtain a function descriptor for the commutator function with a Fastpath function such as mi_routine_get().