C External Procedures
This chapter describes the features and the execution of external procedures written in the C language.
Features
Available only in the following operating systems:
Linux, AIX 64-bit, HP-UX 64-bit, and Solaris 5.10 64-bit.
Allows users to access a shared library
A shared library that is dynamically loadable in C language can be called via C external procedures.
Memory for C external procedures is different from that for Tibero
User-defined libraries (hereafter User Shared Libraries) are dynamically loaded, not by a Tiberoserver process (server process) but by a tbEPA (Tibero C External Procedure Agent) process.
Because user shared libraries are run in the memory of the tbEPA process, any error generated during execution does not affect server processes.
Privileges can be granted
User shared libraries are treated as a PSM function in the server, thus all the privileges applicable to PSM can be granted to the libraries.
The C external procedure is included in the current transaction
When a C external procedure is called while Tibero server is handling a client request, the tbEPA process waits until the request is completed.
The C external procedure is included in the current transaction, thus it is possible to commit or rollback the transaction depending on the result.
Users can perform SQL operations on the current transaction by using a callback service
C external procedures are included in the current transaction, thus users can perform query or DML operations on the current transaction using the functions of the shared library.
To enable this feature, users must use the Callback Service provided by Tibero.
For further information about the callback service, refer to "callback service".
Executing C External Procedures
User shared libraries registered via a C external procedure are dynamically loaded upon request for execution. Such actions are taken not by a server process, but by a tbEPA process.
A tbEPA process is automatically created by a server process when a C external procedure is called. The tbEPA process then receives the various information necessary to call the shared library from the server process. The information needed is; the library location, the function to call, parameter information, and so on.
The tbEPA process dynamically loads the shared library and searches for the function. Based on user entered parameters, the tbEPA process executes the function. When the function has a return value or output parameter, the tbEPA process delivers the value to the server process.
These procedures are automatically processed in Tibero, thus users can write application programs in the same way they write PSM functions.
The following figure illustrates how a C external procedure is executed.
[Figure 1] Execution of a C External Procedure
The C external procedures are executed in the following way.
User specifies a PSM to be run, to execute a user shared library.
When a user created application program calls the user shared library, the PMS module included in the Tibero server checks if the library locates outside the database and then executes an external process. The tbEPA processes are dynamically loaded.
The server process delivers the library information (such as library location, the function to be called, parameter information, and so on.) to any of the tbEPA processes, and waits the processing result.
The tbEPA process dynamically loads a library to call the function. Then it sends the result to the server.
The server analyzes the result received from the tbEPA process, and delivers it to the user-created application program.
The tbEPA process is automatically terminated when the session ends.
Last updated