UDFs that Issue Operating System I/O Calls | Teradata Vantage - UDFs that Issue Operating System I/O Calls - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

Here is a synopsis of the steps you take to develop, compile, install, and use a UDF that issues operating system I/O calls:

  1. Determine the level of access to operating system services that the UDF requires.
    IF the UDF … THEN …
    accesses operating system resources that ordinary operating system users have access to the UDF can run in protected execution mode as a separate process under 'tdatuser', a local operating system user that the database installation process creates.
    requires access to specific operating system resources use CREATE AUTHORIZATION or REPLACE AUTHORIZATION to create a context that identifies a native operating system user and allows UDFs to perform I/O by running as separate processes under the authorization of that user.
  2. Use the CREATE FUNCTION or REPLACE FUNCTION statement to identify the location of the source code, object, or package, and install it on a development or test database.

    Recommendation: In general, you should not create UDFs in Teradata system databases such as SYSLIB or SYSUDTLIB. For more information, see Installing the Function.

    IF you … THEN the CREATE FUNCTION or REPLACE FUNCTION statement …
    did not use CREATE AUTHORIZATION or REPLACE AUTHORIZATION in the previous step sets the default execution mode for the UDF to protected mode.

    The UDF runs under the tdatuser operating system user and can access the system resources for which tdatuser has privileges.

    used CREATE AUTHORIZATION or REPLACE AUTHORIZATION in the previous step must specify the EXTERNAL SECURITY clause to associate execution of the UDF with the context created by the CREATE AUTHORIZATION or REPLACE AUTHORIZATION statement.

    The UDF runs under the operating system user identified by the specified context and can access the system resources for which the user has privileges.

    The function is compiled, if the source code is submitted, linked to the dynamic linked library (DLL or SO) associated with the database in which the function resides, and distributed to all database nodes in the system.

  3. Test and debug the UDF until you are satisfied it works correctly.

    You can use the Teradata C/C++ UDF Debugger, which is a version of GDB (the gnu Source-Level Debugger) that contains extensions. For more information, see C/C++ Command-line Debugging for UDFs.

  4. Install the UDF on your production database.
  5. Use GRANT to grant privileges to users who are authorized to use the UDF.