skip to main content
Developing an Interface Provider (IP) : Designing and implementing the required IP functions
 

Designing and implementing the required IP functions

Once you have determined the functionality to support, you must design and implement the functions to implement that functionality. An IP performs an operation by associating a function with the operation.
The following table lists the operations defined by the OpenAccess SDK IP API.
 
Table 5: Operations supported by an IP 
Operation
Description
CONNECT
Required
Called when a client wants to establish a connection with a data source that is served by the IP. Authentication information such as the user name and password are passed in.
DCL
Optional
Called with GRANT and other Database Configuration Language commands to configure privileges.
DDL
Optional
Called with CREATE TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX operation code to perform the requested operation (only required if you want the IP code to support DDL operations).
DISCONNECT
Required
Closes the connection. The IP should close any files or other connections established on behalf of this connection.
DYNAMIC_RESULTS
Optional
Called to invoke a stored procedure that returns one or more result sets that can be defined at runtime.
END TRANSACTION
Required
Called with operation code COMMIT, ROLLBACK or PREPARE_TO_ COMMIT.
EXECUTE
Required
Called with INSERT, SELECT, UPDATE or DELETE operation code to perform the requested operation.
EXIT
Required
Called when the OpenAccess SDK SQL engine is shutting down.
GETINFO
Required
Gets information about driver specific settings.
GETSUPPORT
Required
Gets information about what type of operations are supported by the driver. This information is used to determine what processing is passed down to the IP.
INIT
Required
Called at startup of the OpenAccess SDK SQL engine to initialize the IP.
INIT_SCALAR
Optional
Called to have the IP register custom scalar functions.
NATIVE
Optional
Called to execute a command that the OpenAccess SDK SQL engine did not recognize as a valid SQL command.
PRIVILEGE
Optional
Called to authorize access to an object.
PROCEDURE
Optional
Called to invoke a stored procedure (only required if you want the IP code to support stored procedures with pre-defined result sets).
SCHEMA
Optional
Called to retrieve the schema information of your data source (only required if the IP will handle the schema management).
SCHEMAEX
Optional
Called to retrieve schema information for stored procedures that define result set at runtime.
SETINFO
Required
Passes client side settings to the IP.
START TRANSACTION
Required
Called to initiate a new transaction. The IP can use this entry point to perform transaction management for each connection.
Here is an example of how an operation is associated with a function. The EXECUTE operation is called with information about the table that is being operated on and, in this case of execution, the type of operation. The IP uses this information to perform the appropriate processing. Consider a query of the form:
SELECT INTVAL FROM CURVALUE;
For this query, the IP function associated with the EXECUTE operation is called (for example, OAIP_execute() in C). This function determines that the specified table is CURVALUE and performs the SELECT operation.
An IP written in C/C++ implements functions for each of the operations in the preceding table and registers them with OpenAccess SDK SQL engine. An IP written in Java implements these operations by defining a class that implements the IP API. An IP written in .NET implements these operations by defining a class that is based on the IP API class.
For information on the API functions that you must implement in your IP, refer to Chapter 2 in the specific OpenAccess SDK SQL Engine Programmer’s Reference for your programming language. The Programmer’s Reference also explains:
How to set up the development environment.
How to use the template and examples as a starting point for your IP.
As shown by the types of operations in Table 5, you are not responsible for implementing any operations for parsing, joins, sorting, or set functions (such as min and max). OpenAccess SDK SQL engine handles these with the assistance of the primitive operations defined in the table. A later discussion describes how the IP can optionally perform the sorting and grouping of a result set, or help in performing joins.
Designs of each of the database operations SELECT, UPDATE and DELETE are described in Chapter 4, "Designing and coding the IP" in the specific OpenAccess SDK Programmer’s Reference for your programming language. Be sure you have read OpenAccess SDK SQL engine and IP interaction, for an overview of the interactions between the OpenAccess SDK SQL engine and the IP code.
The IP calls the optimization functions in the OpenAccess SDK SQL engine to narrow the row selection, and then use the evaluation function in the OpenAccess SDK SQL engine to process each row as it is read. If the evaluation is true for each row that is read from the database, then one of the following actions takes place:
For a SELECT statement, the row is added to the result set.
For an UPDATE statement, the IP calls the OpenAccess SDK SQL engine to get the updating data, and updates the database at the current location.
For a DELETE statement, the current row is removed from the database.
Design of the INSERT database operation is simple. The IP calls the OpenAccess SDK SQL engine for the value set and inserts it into the database. An INSERT statement with a SELECT subquery is broken into a SELECT followed by an INSERT request to the IP.