16.20 - Recompiling and Redistributing an Existing Method - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Data Definition Language Detailed Topics

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Release Date
March 2019
Content Type
Programming Reference
Publication ID
B035-1184-162K
Language
English (United States)

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 .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 .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 as part of a follow-up ALTER METHOD request. See When to Specify Unprotected Mode.

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 and then thoroughly debugged. See CREATE METHOD. 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 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 and REPLACE ORDERING and CREATE TRANSFORM and REPLACE TRANSFORM.

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 .so file is built for all methods in each database. The .so files are stored outside the database on the system disk of each node. If a .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 .so file.

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

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.