public final class ParseTimeCatalog extends Object
Phase 1 links a statement's columns as soon as the statement is parsed, but RESOLVER and resolver2 put the
script's CREATE TABLE statements into the parser's catalog only after every statement was parsed, and
EResolverType.NONE never does. This catalog takes each declaration when it is parsed, so Phase 1 of the
statements after it reads it in every resolver type. It places a declaration where resolver2 does
(StatementMetadata): in the context of the USE statements before it, and a routine's transient
table in that routine's own catalog (Mantis 4715). A CREATE TABLE ... AS SELECT has the columns of its
query, and a name temporary by its spelling (#t) is the same table in every database and schema.
Only Phase 1 reads it, before the parser's catalog, and the parser drops it when the statements are parsed: the
later passes register the declarations at their positions themselves, so a CREATE OR REPLACE never takes the
place of a catalog table ahead of them. With no later pass the parser publishes into its catalog what resolver2
would (publish()). A declaration of a table the parser's catalog already holds where it would put it (caller
metadata, a DDL preload) is not copied unless it replaces it: Phase 1 reads that table, as resolver2 keeps it.
| Constructor and Description |
|---|
ParseTimeCatalog(TSQLEnv shared,
TStatementList statements,
String catalog,
String schema) |
| Modifier and Type | Method and Description |
|---|---|
void |
advanceTo(int index)
Called before the top-level statement at
index is parsed: the statements before it set the context. |
static void |
declare(TCreateTableSqlStatement create)
Phase 1 of a
CREATE TABLE: register the declared table where the statements after it look it up. |
static void |
declareSelectInto(TSelectSqlStatement select,
TObjectName target)
Phase 1 of {@code SELECT ...
|
static boolean |
isRoutineTransient(TSelectSqlStatement select,
TObjectName target)
Whether {@code SELECT ...
|
void |
publish()
Put the declarations into the parser's catalog at their positions, as resolver2 would, for a parse with no
later pass (
EResolverType.NONE): a table declared with its columns, and a top-level #t. |
static TSQLTable |
searchTable(TCustomSqlStatement statement,
String database,
String schema,
String table)
The table Phase 1 of
statement reads under database.schema.table (the qualifiers may be empty)
before the parser's catalog: a transient table its routine declared before it, or a table the script declared
before it. |
public ParseTimeCatalog(TSQLEnv shared, TStatementList statements, String catalog, String schema)
shared - the parser's catalogstatements - the parser's statements, parsed in this ordercatalog - the database the script starts in, before any of its USE statementsschema - the schema the script starts inpublic void advanceTo(int index)
index is parsed: the statements before it set the context.public static void declare(TCreateTableSqlStatement create)
CREATE TABLE: register the declared table where the statements after it look it up.public static boolean isRoutineTransient(TSelectSqlStatement select, TObjectName target)
SELECT ... INTO target creates a transient table of the routine it is in (INTO #t), which
resolver2 keeps in the routine's own catalog: a named routine's, not an anonymous block's, which runs as part of
the script around it.public static void declareSelectInto(TSelectSqlStatement select, TObjectName target)
SELECT ... INTO a routine's transient table (isRoutineTransient(gudusoft.gsqlparser.stmt.TSelectSqlStatement, gudusoft.gsqlparser.nodes.TObjectName)): register it in the
routine's own catalog, as resolver2 does. Any other target is the parser's catalog's, where the statement
registers it.public static TSQLTable searchTable(TCustomSqlStatement statement, String database, String schema, String table)
statement reads under database.schema.table (the qualifiers may be empty)
before the parser's catalog: a transient table its routine declared before it, or a table the script declared
before it. Null when there is none or no parse is running.public void publish()
EResolverType.NONE): a table declared with its columns, and a top-level #t.
resolver2 reads a plain CREATE TABLE ... AS SELECT from the statement, never from its catalog.