The IBM Informix database server provides the following API support for the development of user-defined access methods:
The Virtual-Table Interface (VTI) consists of the following items:
The database server calls user-defined purpose functions to pass SQL statement specifications and state information to the access method. The following special traits distinguish purpose functions from other user-defined routines (UDRs):
The purpose-function syntax describes the parameters and valid return values, but the access method developer chooses a unique function name.
For example, when the database server encounters a CREATE TABLE statement, it invokes an access-method function with the following required parameter and return value types:
mi_integer am_create(MI_AM_TABLE_DESC *)
To determine which UDR provides the entry point for table creation in this example, the database server looks for the function identifier in the am_create column of the sysams system catalog. The database server then calls that UDR and passes, by reference, an MI_AM_TABLE_DESC structure that contains data-definition information.
The access-method developer provides the program code inside the purpose function to create the new table structure. When the purpose function exits, the access-method returns a prespecified value to indicate success or failure.
For information about the access-method developer's contribution to purpose functions, refer to Components That You Provide. For the syntax and usage of each purpose function, refer to Purpose-Function Reference.
Descriptors are predefined opaque data types that the database server creates to exchange information with a Datablade module or an access method. The VTI provides several descriptors in addition to those that the DataBlade API provides. An access-method descriptor contains the specifications from an SQL statement or oncheck request as well as relevant information from the system catalog.
The database server passes descriptors by reference as arguments to purpose functions. The following list highlights only a few access-method descriptors to illustrate the type of information that the database server passes to an access method. For detailed information about all the VTI descriptors, refer to Descriptors.
Descriptor Name and
Structure |
Database Server Entries in the Descriptor |
---|---|
table descriptor
MI_AM_TABLE_DESC |
The database server
puts CREATE TABLE specifications in the
table descriptor, including the following items:
|
scan descriptor
MI_AM_SCAN_DESC |
The database server
puts SELECT statement specifications in
the scan descriptor, including the following items:
|
qualification
descriptor MI_AM_QUAL_DESC |
In the qualification descriptor, the database
server describes the functions and Boolean operators that a WHERE clause
specifies. A qualification function tests
the value in a column against a constant or value that an application
supplies. The following examples test the value in the price column
against the constant value 80.
WHERE lessthan(price,80) WHERE price < 80The qualification descriptor for a function identifies the following items:
WHERE price < 80 AND cost > 60A complex qualification descriptor contains each Boolean AND or OR operator from the WHERE clause. For examples, refer to Interpreting the Qualification Descriptor. |
Descriptors reserve areas where the access method stores information. An access method can also allocate user-data memory of a specified duration and store a pointer to the user-data in a descriptor, as the following list shows.
To allocate memory for a specific duration, the access method specifies a duration keyword. For example, the following command allocates PER_STMT_EXEC memory:
my_data = (my_data_t *) mi_dalloc(sizeof(my_data_t), PER_STMT_EXEC)
Unlike purpose functions, the VTI supplies the full code for each accessor function. Accessor functions obtain and set specific information in descriptors. For example, the access method can perform the following actions:
For the syntax and usage of each accessor function, refer to Accessor Functions.
The DataBlade API includes functions and opaque data structures that enable an application to implement C UDRs. The access method uses functions from the DataBlade API that allocate shared memory, execute user-defined routines, handle exceptions, construct rows, and report whether a transaction commits or rolls back.
The remainder of this manual contains information about the specific DataBlade API functions that an access method calls. For more information about the DataBlade API, refer to the IBM Informix: DataBlade API Programmer's Guide.
IBM Informix extension to ANSI SQL-92 entry-level standard SQL includes statements and keywords that specifically refer to user-defined access methods.
The CREATE PRIMARY ACCESS_METHOD statement registers a user-defined access method. When you register an access method, the database server puts information in the system catalog that identifies the purpose functions and other properties of the access method.
ALTER ACCESS_METHOD changes the registration information in the system catalog, and DROP ACCESS_METHOD removes the access-method entries from the system catalog.
For more information about the SQL statements that register, alter, or drop the access method, refer to SQL Statements for Access Methods.
The user needs a way to specify a virtual table in an SQL statement.
To create a virtual table with the CREATE TABLE statement, a user specifies the USING keyword followed by the access-method name and, optionally, with additional access-method-specific keywords.
With the IN clause, the user can place the virtual table in an extspace or sbspace.
For more information about the SQL extensions specific to virtual tables, refer to Supporting Data Definition Statements and Supporting Data Retrieval, Manipulation, and Return.
The IBM Informix database server provides Global Language Support with the IBM Informix GLS functions, which access Informix locales and support multibyte character sets. Use this API to allow the access method to interpret international alphabets.
For information about the complete set of APIs for Dynamic Server, refer to the IBM Informix: Getting Started Guide.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]