Using virtual processors with UDRs written in C

About this task

To run in the CPU VP class, a C UDR must be well behaved; that is, it must adhere to special programming requirements. Running in a user-defined VP relaxes some, but not all, of the programming requirements of a well-behaved routine. For example, these routines can issue direct file-system calls that block further processing by the virtual processor until the I/O is complete. Because virtual processors are not CPU virtual processors, however, the normal processing of user queries is not affected. However, they still cannot perform local resource allocations because they might migrate among the VPs.

To assign a C UDR to a user-defined VP class:

Procedure

  1. When you register an external function or procedure, assign it to a class of virtual processors with the CLASS routine modifier of the CREATE FUNCTION or CREATE PROCEDURE statement.
    The CLASS routine modifier specifies the virtual-processor class with the following syntax:
    CLASS = vpclass_name

    In this syntax, vpclass_name is the name of the user-defined VP class that you have configured in the database server. The class name is not case sensitive.

  2. Configure new user-defined virtual-processor classes in the onconfig file with the VPCLASS configuration parameter.

    The following sample onconfig entry creates the user-defined VP class newvp:

    VPCLASS newvp,num=3                      # New VP class for testing

    The num option specifies the number of virtual processors that the database server starts. For the newvp virtual-processor class, the database server initially starts three virtual processors.

Results

The VP class need not exist when the routine is registered. However, when you execute the routine, the class must exist and have virtual processors assigned to it. If the class does not have any virtual processors, you receive an SQL error.

For more information about how to choose a virtual-processor class for a C UDR, see the HCL OneDB™ DataBlade® API Programmer's Guide. For information about the VPCLASS configuration parameter, see the HCL OneDB Administrator's Reference.