The following application program interface support is provided for the development of user-defined access methods:
The Virtual-Index Interface (VII) 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 INDEX 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 index 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 index 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 VII 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 VII descriptors, refer to the Descriptors.
Descriptor Name and Structure | Database Server Entries in the Descriptor |
---|---|
table descriptor
MI_AM_TABLE_DESC |
The database server
puts CREATE INDEX 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.
Descriptor Name and Structure | Access Method Entries in the Descriptor |
---|---|
table descriptor
MI_AM_TABLE_DESC |
To share state information among multiple purpose functions, the access method can allocate user-data memory with a PER_STATEMENT duration and store a pointer to the user data in the table descriptor. PER_STATEMENT memory lasts for the duration of an SQL statement, for as long as the accessed index is open. For example, an access method might execute DataBlade API functions that open smart large objects or files and store the values, or handles, that the functions return in PER_STATEMENT memory. |
scan descriptor
MI_AM_SCAN_DESC |
To maintain state information during a scan, an access method can allocate user-data memory with a PER_COMMAND duration and store a pointer to the user data in the scan descriptor. For example, as it scans an index, the access method can maintain a pointer in PER_COMMAND memory to the address of the current index entry. |
qualification descriptor
MI_AM_QUAL_DESC |
As it processes each qualification against a
single index entry, the access method can set the following items
in the qualification descriptor:
|
To allocate memory for a specific duration, the access method specifies a duration keyword. For example, the following command allocates PER_STATEMENT memory:
my_data = (my_data_t *) mi_dalloc(sizeof(my_data_t), PER_STATEMENT)
Unlike purpose functions, the VII 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 application programming interface includes functions and opaque data structures that enable an application to implement C-language 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.
The 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 SECONDARY 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 index in an SQL statement.
To create a virtual index with the CREATE INDEX 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 index in an extspace or sbspace.
For more information about the SQL extensions specific to virtual indexes, refer to Supporting Data Definition Statements and Supporting Data Retrieval, Manipulation, and Return.
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 ]