Home | Previous Page | Next Page   Programming DataBlade Module Routines in C > Editing Routines in udr.c >

Selectivity Functions

If you create a user-defined function and mark it as a selectivity function for another function (see Selectivity Functions), BladeSmith generates the selectivity function in the udr.c source code file.

For a description of selectivity and user-defined statistics, see User-Defined Statistics.

The Generated Code

BladeSmith generates only templates for selectivity functions.

The generated code declares the function, its return type, and arguments. In addition to the arguments you specified when you created the function, BladeSmith also generates an MI_FPARAM argument, which is not used by the generated code.

Completing the Code

You must add code to the selectivity function to call the statistics support functions and calculate the selectivity of the associated function for a given set of arguments. For built-in data types, call the built-in statistics functions, such as StatCollect(). For opaque data types, call the statistics support functions in the statistics.c file, such as OpaqueStatCollect(). For more information on statistics support functions for opaque data types, see Editing Statistics Routines in statistics.c.

For example, if you have a selectivity function on an OpaqueEqual() function that is overloaded for an opaque data types, the code for the selectivity function, OpaqueEqualSelectivity(), might perform the following tasks:

For more information on coding selectivity functions, see the IBM Informix: DataBlade API Programmer's Guide.

Example

The Box DataBlade module has selectivity functions.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]