The mi_key_funcid() accessor function

The mi_key_funcid() function retrieves the identifier of the function that computes the key values in a functional index.

Syntax

mi_integer mi_key_funcid(MI_AM_KEY_DESC *keyDesc,
   mi_integer keyNum)
keyDesc
Points to the key descriptor.
keyNum
Specifies the column number of the index-based key or 0 for a single-key index.

For the first (or only) key, pass 0 as keyNum. Increment keyNum by one for each subsequent key in a composite index.

Usage

A UDR returns the values that make up a functional index. For example, the following statement creates an index from the values that the box() function returns:
CREATE INDEX box_func_idx ON zones (box(x1,y1,x2,y2)) USING map_am;

Use the DataBlade® API FastPath facility to obtain values for function-based index keys.

To execute a function on a key column
  1. Call mi_key_funcid() to extract the routine identifier from the qualification descriptor.
  2. Pass the routine identifier to the DataBlade API mi_func_desc_by_typeid() function, which returns the function descriptor.
  3. Pass the function descriptor to the DataBlade API mi_routine_exec() function, which executes the function in a virtual processor.

Return values

A positive integer identifies the function that creates the values in the keyNum position of a composite-key index.

A return value of 0 indicates that the specified keyNum contains column values and does not belong to a functional index.

A negative value indicates that the CREATE INDEX statement specifies an unknown function to create the key.

Related topics

See the discussions of:
  • Fastpath functions in the Informix® DataBlade API Programmer's Guide, including functions mi_func_desc_by_typeid() and mi_routine_exec().
  • CREATE INDEX in the Informix Guide to SQL: Syntax, particularly functional index information.