15.00 - Recompiling and Redistributing an Existing Method - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1184-015K

Recompiling and Redistributing an Existing Method

The COMPILE option is intended to be used by DBAs to recompile methods that have been moved to a platform, system, or restored database other than the one in which they were created.

Specify the COMPILE option to recompile an existing method. If its source code is present, then the system recompiles it, generates the object, recreates the .dll or .so file, and distributes it to all nodes of the system. The object is replaced with the recompiled version.

If the method was created with the object only (that is, there is no source code present to be recompiled), the method object is used to recreate the .dll or .so file and distribute it to all nodes of the system.

If the method is restored from a different platform to a new platform whose objects are not compatible, the COMPILE option fails. When this happens, you must recreate the method with the correct object or source code.

You cannot specify this option if the method was installed as part of a package.

Methods defined to run in unprotected mode and recompiled with this option do not retain the ability to run in unprotected mode unless you specify EXECUTE NOT PROTECTED (see “When to Specify Unprotected Mode” on page 20) as part of a follow‑up ALTER METHOD request.

For example, suppose you have a method named in_state() for the UDT named address, and in_state() has been set to run in EXECUTE NOT PROTECTED mode by an ALTER METHOD request that was submitted after the method was created using a CREATE METHOD request (see “CREATE METHOD” on page 403) and then thoroughly debugged. Some time later, it becomes necessary for in_state() to be recompiled for some reason, so you must perform the following multistep procedure if in_state() is to be both recompiled and to retain its ability to run in unprotected mode (because you cannot specify both COMPILE [ONLY] and EXECUTE [NOT] PROTECTED in the same ALTER METHOD request).

1 You first submit the following ALTER METHOD request to recompile the in_state() method:

     ALTER METHOD in_state FOR SYSUDTLIB.address COMPILE;

2 After the successful completion of this request, the system resets the protection mode for in_state() to EXECUTE PROTECTED, so you must run a second ALTER METHOD request to set its protection mode back to EXECUTE NOT PROTECTED:

     ALTER METHOD in_state FOR SYSUDTLIB.address 
     EXECUTE NOT PROTECTED;

When you specify COMPILE ONLY, then only the method is recompiled and no new dynamic linked libraries are distributed to database nodes.

See “Restrictions on Altering Methods That Implement UDT Transform and Ordering Functionality” on page 22 for a description of the restrictions imposed on using ALTER METHOD to change the protection mode, or to recompile the object code for methods that implement UDT transform or ordering functionality.

Also see “CREATE ORDERING/ REPLACE ORDERING” on page 416 and “CREATE TRANSFORM/ REPLACE TRANSFORM” on page 694.

When a method is loaded onto another platform of a different type, it is marked as non‑valid. All non‑valid methods must be recompiled. If there are many methods in one database, you can save time by specifying the ONLY option for all but the last compilation in that database to avoid having to generate and distribute a new library. When you do this, make certain not to specify the ONLY option for the last method you recompile in that database.

One .dll or .so file is built for all methods in each database. The .dll or .so files are stored outside the database on the system disk of each node. If a .dll or .so file becomes corrupted on one node, the DBA can regenerate it by issuing an ALTER METHOD request with the COMPILE option to rebuild the .dll or .so file.

To regenerate a corrupted .dll, or .so file, you only need to compile one method in that database. The system regenerates the .dll, or .so file, and includes all other user‑defined methods defined in that database in the regenerated .dll, or .so file.

Note that changing the protection mode for a method also causes the system‑generated UDF constructor function to be recompiled invisibly. That is, the system does not return any compilation messages unless the compilation fails. Then the system returns an appropriate error message to the requestor.