informix
Informix DataBlade API Programmer's Manual
Developing a User-Defined Routine

Designing a User-Defined Routine

This section provides the following design considerations for the development of a C UDR:

Development Tools

The creation of a C UDR involves the production of source code, header files, SQL statements, and many other files. This manual describes how to generate the code for C UDRs yourself, using the DataBlade API and the basic tools available with an operating system.

However, Informix provides a package of development tools, called the DataBlade Developers Kit (DBDK), that helps you build and manage the C UDRs of a DataBlade module project. A DataBlade module is a package of software that extends the functionality of the database server. It can include the following objects:

The DBDK runs on Windows platforms. The following table summarizes the development tools of the DBDK.

DBDK Development Tool Description
BladeSmith
  • Provides an interactive Wizard. Generates code for many C UDRs.
  • Generates a project, with as much code as possible, including source for opaque-type support functions, header files, a makefile for compilation, SQL statements, and functional tests.
  • BladePack
  • Understands the contents of a project that BladeSmith produces, allowing it to be extended to include documentation and on-line help
  • Produces a releasable package for a DataBlade module
  • BladeManager Understands the contents of the releasable package that BladePack creates, enabling it to install a DataBlade module in a database

    These development tools include on-line help to describe their use. Informix also provides the DataBlade Developers Kit User's Guide to describe these tools.

    BladeSmith can develop source code and a makefile that can be compiled on a UNIX platform.

    Consider using the development tools of the DBDK to generate the initial code for your C UDRs. You can then use the information in this manual to enhance and change this code to handle the unique needs of your C UDR or DataBlade module.

    Uses of a C UDR

    The following table summarizes the tasks that a C UDR can perform. It also describes where you can find additional information in this manual for each of these UDR uses.

    Type of UDR Purpose For More Information
    Cast function A UDR that converts one data type to another See Extending Informix Dynamic Server 2000
    Cost function A UDR that determines the cost of execution for an expensive UDR Creating Selectivity and Cost Functions
    End-user routine A UDR that performs some common task for an end user Writing an End-User Routine
    Iterator function A function that returns more than one row of data Writing an Iterator Function
    Opaque-type support function One of a group of user-defined functions that tell the database server how to handle the data of an opaque data type Creating an Opaque Data Type
    Operator-class function User-defined functions that define operators to use with a particular secondary access method See your access-method documentation
    Negator function A user-defined function that calculates the Boolean NOT operation for a particular operator or function. Creating Negator Functions
    Selectivity function A UDR that determines the percentage of rows likely to be returned an expensive UDR Creating Selectivity and Cost Functions
    Parallelizable UDR A UDR that can run in parallel when executed within a PDQ statement Creating Parallelizable UDRs
    User-defined aggregate A function that calculates an aggregate value on a particular column or value Writing an Aggregate Function

    Portability

    To ensure portability of your C UDR, include the following items in the design and implementation of your C UDR:

    DataBlade API Data Types

    The DataBlade API provides platform-independent data types, such as mi_smallint (2-byte integer), mi_integer (4-byte integer), and mi_double_precision (floating-point values). For a complete list of DataBlade API data types, see Figure 1-1 on page 1-11. The mitypes.h header file defines these data types.

    Tip: The mi.h header file automatically includes the milib.h header, which in turn includes the mitypes.h header file. Therefore, you do not need to explicitly include mitypes.h to use the DataBlade API data types.

    To ensure maximum portability of your code, use these platform-independent data types instead of their C-language equivalents.

    Data Conversion

    The DataBlade API provides special functions to handle the following data conversions that a C UDR might need to perform:


    Informix DataBlade API Programmer's Manual, Version 9.2
    Copyright © 1999, Informix Software, Inc. All rights reserved