Here is a synopsis of the steps you take to develop, compile, install, and use a UDF that issues operating system I/O calls:
- 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. - 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.
- 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.
- Install the UDF on your production database.
- Use GRANT to grant privileges to users who are authorized to use the UDF.