The SQLPrepare Phase of SQLExecDirect
[This is preliminary documentation and subject to change.]
SQLPrepare prepares an SQL string for execution by:
-
Creating a parse tree that represents the SQL statement, and checking syntax. The nodes of the parse tree contain placeholders that are used for annotations during semantics checking.
-
First verifying, during semantics checking, that each table in the table list specified in the select statement exists. If the table does not exist, an error occurs.
-
Ensuring that table alias names are not duplicated.
-
Semantically checking the select list of the SELECT statement, which involves:
-
Finding the table to which each column in the select list refers.
-
Ensuring that a column does not ambiguously refer to multiple tables.
-
Storing a reference in the column node to its associated table definition.
-
Checking the semantics of the WHERE clause.
In terms of the single-table, single-column example, SQLPrepare ensures that table and alias names are not duplicated. It accomplishes this task by verifying that t1 exists within the Wellfleet database. Also, in terms of this example, SQLPrepare checks the semantics of the select list by ensuring that c1t1 exists within t1 and a reference to a definition of t1 is stored in the column node representing c1.