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.
UDF Access Level Description Operating system resources that ordinary operating system users can access UDF can run in protected run mode as separate process under tdatuser, a local operating system user that database installation process creates. Specific operating system resources Use CREATE AUTHORIZATION or REPLACE AUTHORIZATION to create context that identifies native operating system user and allows UDFs to perform I/O by running as separate processes under 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 the item on a development or test database.Teradata recommends against creating UDFs in Teradata system databases such as SYSLIB or SYSUDTLIB. See Installing the Function.
Action in Previous Step Result Used CREATE AUTHORIZATION or REPLACE AUTHORIZATION CREATE FUNCTION or REPLACE FUNCTION sets default run mode for UDF to protected mode. UDF runs under tdatuser operating system user and can access system resources for which tdatuser has privileges.
Did not use CREATE AUTHORIZATION or REPLACE AUTHORIZATION CREATE FUNCTION or REPLACE FUNCTION must specify EXTERNAL SECURITY clause to associate running of UDF with context created by CREATE AUTHORIZATION or REPLACE AUTHORIZATION statement. UDF runs under operating system user identified by specified context and can access system resources for which 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 UDF 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.