Accessing support functions for a multiple-column key

About this task

To access support functions for a multiple-column key:

Procedure

  1. Call the mi_key_nkeys() accessor function to determine the number of columns in the key.
  2. Call the mi_key_opclass_nsupt() function to determine the number of support functions for a single key column.

    If the access method needs every column in the key, use the return value from mi_key_nkeys() as the number of times to execute mi_key_opclass_nsupt(). For example, the am_create purpose function, which builds the index, might need support functions for every column.

  3. Call the mi_key_opclass_supt() accessor function to extract one support function name.

    Use the return value from mi_key_opclass_nsupt() as the number of times to execute mi_key_opclass_supt().

Example

The sample syntax retrieves all the support functions.
Figure 1: Extracting support functions for a multiple-column index key
MI_KEY_DESC * keyDesc;
mi_integer   keyNum;
mi_integer   sfunctNum;
mi_string    sfunctName;

keynum = mi_key_nkeys(keyDesc);

for (k=0; k<= keyNum; k++)
{
   sfunctNum = mi_key_opclass_nsupt(keyDesc, keyNum);

      for (i=0; i<=sfunctNum; i++)
      {
         sfunctName = 
         mi_key_opclass_supt(keyDesc, 
                  keyNum, sfunctNum);
         /* 
         ** Use the function name 
         ** or store it in user data. (Not shown.)         */
      } /* End get sfunctName */
   } /* End get sfunctNum */
} /* End get keynum */

The access method might need information about all the strategy functions for a particular key. For example, the access method might use the key descriptor rather than the qualification descriptor to identify strategy functions.