SQL Programming Manual for TAL
Program Compilation and Execution
HP NonStop SQL Programming Manual for TAL—527887-001
5-26
Understanding the Run-Time Timestamp Check
SQL load time TACL DEFINEs for a static SQL statement and the current active TACL
DEFINEs when a PREPARE statement is executed for a dynamic SQL statement.
Unavailable Access Path (Index)
If the SQL executor tries to execute an SQL statement and detects that an access path
in the execution plan is unavailable, the executor invokes the SQL compiler to
recompile the statement. The SQL compiler then determines the best alternate access
path (if such a path exists) to execute the statement. Only the affected statement is
automatically recompiled when the access path becomes unavailable.
Attempted Execution of an Uncompiled SQL Statement
If the SQL executor encounters an uncompiled SQL statement, it invokes the SQL
compiler to compile the statement. A program can contain uncompiled SQL statements
if:
•
A table or view used by an SQL statement did not exist during explicit SQL
compilation.
•
A description of a table, view, or index needed for the execution plan of an SQL
statement was not available during explicit SQL compilation.
•
The program was explicitly compiled with the FORCE option and an SQL
statement had errors.
Understanding the Run-Time Timestamp Check
A program file and all SQL database objects (such as a tables, protection views, and
indexes) have unique timestamps. The SQL executor checks each timestamp to
ensure that a program file uses the current definition of an object for its execution plan.
For example, consider these cases:
•
Program PROGRAMA, which is SQL valid when it runs, uses table TABLEA.
•
After PROGRAMA starts executing, a database administrator adds a new column
to TABLEA using the ALTER TABLE statement (TABLEA is not locked by
PROGRAMA). The execution plans in PROGRAMA that were generated from the
old TABLEA definition during explicit SQL compilation time are no longer valid.
•
When the first SQL statement that uses TABLEA executes, the SQL executor
opens TABLEA and checks the timestamp to ensure that PROGRAMA has a valid
definition for TABLEA. The SQL executor compares the TABLEA timestamp with
the PROGRAMA timestamp. The TABLEA timestamp is more recent than the
PROGRAMA timestamp.
•
The SQL executor invokes the SQL compiler to recompile the statement using the
current TABLEA definition. Recompilation does not modify PROGRAMA on disk or
record dependencies in the catalog; it only changes the copy of PROGRAMA in
memory.