Assign a C UDR to a user-defined VP class
When you register an ill-behaved C UDR, you assign it to a class of user-defined virtual processors with the CLASS routine modifier of the CREATE FUNCTION or CREATE PROCEDURE statement.
Tip: By default, all C UDRs execute in any VP. To
have your C UDR run only in the CPU VP, you can specify the string “cpu
vp” with the CLASS modifier. If your C UDR can run
anywhere, you must omit the CLASS modifier.
For example, the following code fragment shows a CREATE FUNCTION
statement that registers the C user-defined function, GreaterThanEqual() and
specifies that the user-defined VP class named newvp executes
this function.
CREATE FUNCTION GreaterThanEqual(ScottishName, ScottishName)
RETURNS BOOLEAN
WITH (CLASS = 'newvp')
EXTERNAL NAME '/usr/lib/objects/udrs.so(grtrthan_equal'
LANGUAGE C;
The code fragment in Define a yielding user-defined VP class shows the definition of the newvp user-defined VP class. All UDRs that specify the newvp VP class with the CLASS routine modifier share the three VPs in the newvp VP class.
When you register user-defined functions or user-defined procedures
with the CREATE FUNCTION or CREATE PROCEDURE statement, you can reference
any user-defined VP class that you like. The CREATE FUNCTION and CREATE
PROCEDURE statements do not verify that the VP class you specify exists
when they register the UDR.
Important: When you try
to run a UDR that was registered to execute in a user-defined VP class,
that VP class must exist and it must have virtual processors assigned
to it. If the class does not have any virtual processors, you receive
an SQL error. For information about how to define a user-defined VP,
see Define a user-defined VP.
For more information about the syntax of CREATE FUNCTION or CREATE PROCEDURE to assign a C UDR to a VP class, see the description of the CLASS routine modifier in the Routine Modifier segment of the HCL Informix® Guide to SQL: Syntax.