Sybase IQ overview

Learn how to create and configure external C/C++ user-defined functions (UDFs).

Sybase IQ supports high-performance in-process external C/C++ user-defined functions. This style of UDF supports functions written in C or C++ code that adhere to the interfaces described in this guide. These UDF definitions can be compiled and linked into a dynamically linkable library. The dynamically linkable library can be loaded into a running IQ server, and the defined UDFs can be used directly within queries or other SQL statements.

The use of these external C/C++ UDFs interfaces requires the IQ_UDF license.

These external C/C++ UDFs differ from the Interactive SQL UDFs available in earlier versions of Sybase IQ. Interactive SQL UDFs are unchanged and do not require a special license. For instructions on creating UDFs using Interactive SQL see Chapter 1, “Using Procedures and Batches,” in System Administration Guide: Volume 2.

To build and use a UDF from a dynamically linkable library:


  1. Declare the UDF to the server by using the CREATE FUNCTION or CREATE AGGREGATE FUNCTION statements. These statements can either be directly written and executed as a command, or the appropriate CREATE statement can be built using the Sybase Central New Function wizard.

    The external C/C++ form of the CREATE FUNCTION statement requires DBA or RESOURCE authority, so standard users do not have the authority to declare any UDFs of this type.

  2. Define the UDF as a set of C or C++ functions. See Defining a scalar UDF or Defining an aggregate UDF.

  3. Write the UDF library identification function.

  4. Compile the UDF functions and the library identification functions.

  5. Link the compiled file into a dynamically linkable library.

Once these steps have been completed, any reference to that UDF in a SQL statement first, if necessary, links the dynamically linkable library. The calling patterns are then called.

Because these high-performance external C/C++ user-defined functions involve the loading of non-server library code into the process space of the server, there are potential risks to data integrity, data security, and server robustness from poorly or maliciously written functions. To manage these risks each IQ server can explicitly enable or disable this functionality.

Related tasks
Setting the dynamic library interface
Enabling and disabling user-defined functions


Created November 2, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com