Input support function

The database server calls the input function when it receives the external representation of an opaque type from a client application. For example, when a client application issues an INSERT or UPDATE statement, it can send the text representation of an opaque type to the database server to be stored in an opaque-type column. The database server calls the input function to convert this external representation to an internal representation that it stores on disk.

The following figure shows when the database server executes the input support function.
Figure 1: Execution of the input support function

begin figure description - This figure is described in the surrounding text. - end figure description

If the opaque data type is pass by reference, the input support function should perform the following tasks:
  • Allocate enough space to hold the internal representation.

    The function can use the mi_alloc() DataBlade® API function to allocate the space for the internal structure.

  • Parse the input string.

    It must obtain the individual members from the input string and store them in the appropriate fields of the internal structure

  • Return a pointer to the internal structure.

If the opaque data type is pass by value, the input support function should perform these same basic tasks but return the actual value in the internal structure instead of a pointer to this structure. You can use pass by value only for opaque types that are less than 4 bytes in length.

The input function takes an mi_lvarchar value as an argument and returns the internal structure for the opaque type. The following function signature is an input support function for a fixed-length opaque data type whose internal structure is ll_longlong_t:
ll_longlong_t * ll_longlong_input(mi_lvarchar *extrnl_format);

The ll_longlong_input() function is a cast function from the LVARCHAR data type to the ll_longlong_t internal structure. It must be registered as an implicit cast function with the CREATE IMPLICIT CAST statement. For more information about cast functions, see Create casts for opaque data types.