public final class TemporaryTableSemantics extends Object
This is the one place that decides it. resolver2 binds each table reference to the definition this rule makes visible there, and the lineage model shares a table model exactly when resolver2 bound two references to the same definition, so lookup and publish follow one rule.
A table whose definition is transient belongs to the routine body (or the top-level script) that creates it. Parsing a routine is not running it, so another routine never sees that definition unless a call in the analyzed SQL proves it can:
TemporaryTableSemantics.Scope.CALL: the routine that creates the table and the routines it calls, until it
returns.TemporaryTableSemantics.Scope.SESSION: as CALL, and the table also outlives the routine, so after
the call its caller sees it too.TemporaryTableSemantics.Scope.CATALOG and TemporaryTableSemantics.Scope.GLOBAL definitions are shared by every routine, as a
permanent table's is.
Vendor rules, from each vendor's documentation:
#name is CALL ("Temporary tables" in CREATE
TABLE); ##name is GLOBAL, one live object for every session.#name is CALL; ASE has no ## form, so ##name is
another # table. CREATE GLOBAL TEMPORARY TABLE is CATALOG.#name table created in a procedure outlives it (running
the procedure again fails with "table already exists"), so it is SESSION, as is
CREATE LOCAL TEMPORARY TABLE. CREATE GLOBAL TEMPORARY TABLE is
CATALOG. dbvsybase names no single product and follows IQ.#name) is SESSION; a global temporary
table is CATALOG.TEMP/TEMPORARY is SESSION;
GLOBAL and LOCAL are accepted and ignored, so they are SESSION too.
Redshift #name is SESSION.TEMPORARY/TEMP is SESSION.TEMPORARY and its synonyms (LOCAL, GLOBAL,
VOLATILE) are SESSION. A procedure's CREATE PROCEDURE SCOPED TEMP TABLE
is not classified: GSP does not parse it yet.VOLATILE is SESSION; GLOBAL TEMPORARY is
CATALOG.GLOBAL TEMPORARY is CATALOG; PRIVATE TEMPORARY is
SESSION.LOCAL TEMPORARY is SESSION; GLOBAL TEMPORARY is
CATALOG, and so is plain TEMPORARY, which is global under Vertica's default
DefaultTempTableLocal = 0 (a server configured with 1 makes it local).CREATE GLOBAL TEMPORARY TABLE is CATALOG.TEMP/LOCAL TEMP is SESSION; GLOBAL
TEMPORARY is CATALOG.Any other vendor or form is not classified (null): its tables are analyzed as
permanent tables are.
| Modifier and Type | Class and Description |
|---|---|
static class |
TemporaryTableSemantics.Scope
Who can see a temporary table's definition.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
hasTransientTables(EDbVendor vendor)
Whether
vendor has any transient temporary tables, so routine bodies need their own scope. |
static boolean |
isTransient(TemporaryTableSemantics.Scope scope)
Whether a definition of this scope belongs to the body that creates it.
|
static boolean |
isTransientName(EDbVendor vendor,
TObjectName name)
Whether a table name alone makes it transient (
#name in the vendors that read it so). |
static TemporaryTableSemantics.Scope |
ofDeclaration(TCreateTableSqlStatement create)
The scope of the table a CREATE TABLE statement declares, or null for a permanent table.
|
static TemporaryTableSemantics.Scope |
ofKinds(EDbVendor vendor,
Collection<ETableKind> kinds)
The scope the declaration keywords (
TEMPORARY, VOLATILE ...) give a table. |
static TemporaryTableSemantics.Scope |
ofName(EDbVendor vendor,
TObjectName name)
The scope a table's name alone gives it, from its SQL-lexical object segment.
|
static TemporaryTableSemantics.Scope |
ofNameSegment(EDbVendor vendor,
String lexicalObjectSegment)
The scope a table's name alone gives it, from one SQL-lexical object segment.
|
static TemporaryTableSemantics.Scope |
ofSelectInto(EDbVendor vendor,
TObjectName target)
The scope of the table a {@code SELECT ...
|
static TemporaryTableSemantics.Scope |
ofStoredName(EDbVendor vendor,
String storedName)
The scope a stored (decoded) table name alone gives it, or null when the name says nothing.
|
public static boolean isTransient(TemporaryTableSemantics.Scope scope)
public static TemporaryTableSemantics.Scope ofName(EDbVendor vendor, TObjectName name)
public static TemporaryTableSemantics.Scope ofNameSegment(EDbVendor vendor, String lexicalObjectSegment)
public static TemporaryTableSemantics.Scope ofStoredName(EDbVendor vendor, String storedName)
public static TemporaryTableSemantics.Scope ofKinds(EDbVendor vendor, Collection<ETableKind> kinds)
TEMPORARY, VOLATILE ...) give a table.public static TemporaryTableSemantics.Scope ofDeclaration(TCreateTableSqlStatement create)
public static TemporaryTableSemantics.Scope ofSelectInto(EDbVendor vendor, TObjectName target)
SELECT ... INTO target creates (INTO #t,
INTO TEMP t), or null for a permanent table. SAP HANA's SELECT ... INTO
assigns variables and creates no table, so a HANA target never has one.public static boolean isTransientName(EDbVendor vendor, TObjectName name)
#name in the vendors that read it so).public static boolean hasTransientTables(EDbVendor vendor)
vendor has any transient temporary tables, so routine bodies need their own scope.