Subject | Re: [Firebird-Architect] RFC: Proposal for the implementation of Temporary Tables. |
---|---|
Author | Dmitry Yemanov |
Post date | 2004-11-23T21:35:33Z |
"Paul Beach" <pbeach@...> wrote:
Oracle supports GLOBAL TEMPORARY TABLE with global schema and
session-specific data. AFAIU, this is what you propose. Oracle does not
support LOCAL TEMPORARY TABLE (at least in v9). AFAIU, InterBase 7.5 offers
exactly the same semantics. Sybase ASA - the same. DB2 offers DECLARE GLOBAL
TEMPORARY TABLE which is not included into the system schema and hence is
visible only on a per-session basis. MSSQL has both global and local temp
tables defined via the non-standard syntax with specific scopes (all
sessions or current session) and global temp tables have data shared between
sessions. MySQL has just TEMPORARY TABLE which is visible only for the
current session. PostgreSQL offers only LOCAL TEMPORARY TABLE which is also
visible for the current session only.
So everybody distinguishes between GLOBAL and LOCAL in terms of the user
session. Everybody considers GLOBAL visible to other sessions except DB2
(and perhaps MySQL). Everybody offers session-specific data for GLOBAL
except MSSQL. Can we stick to the majority and name our implementation
accordingly?
Questionable decision, but it seems it's what almost everybody supports.
Tend to agree here.
table or a view.
allowed.
<table element list>
| OF <path-resolved user-defined type name>
[ <subtable clause> ]
[ <table element list> ]
| <as subquery clause>
prefer to see an abstract class Relation with descendant classes
PersistentTable, TemporaryTable, ExternalTable, View.
Requires more thinking. What about PAG_temporary flag which means that a
page I/O should be redirected to the TempSpace object instead of PIO? In
this case we keep all advantages of VIO and DPM (CCH usage is questionable)
with an ability of a quick data destroy.
Considering the GLOBAL question solved, I don't see how:
1) LOCAL can be implemented
2) AS <subquery> can be implemented
Dmitry
>As almost everybody mentioned, GLOBAL and LOCAL are missing ;-)
> Syntax:
>
> CREATE TEMPORARY TABLE <table name> <table contents source>
> [ON COMMIT {PRESERVE | DELETE} ROWS]
Oracle supports GLOBAL TEMPORARY TABLE with global schema and
session-specific data. AFAIU, this is what you propose. Oracle does not
support LOCAL TEMPORARY TABLE (at least in v9). AFAIU, InterBase 7.5 offers
exactly the same semantics. Sybase ASA - the same. DB2 offers DECLARE GLOBAL
TEMPORARY TABLE which is not included into the system schema and hence is
visible only on a per-session basis. MSSQL has both global and local temp
tables defined via the non-standard syntax with specific scopes (all
sessions or current session) and global temp tables have data shared between
sessions. MySQL has just TEMPORARY TABLE which is visible only for the
current session. PostgreSQL offers only LOCAL TEMPORARY TABLE which is also
visible for the current session only.
So everybody distinguishes between GLOBAL and LOCAL in terms of the user
session. Everybody considers GLOBAL visible to other sessions except DB2
(and perhaps MySQL). Everybody offers session-specific data for GLOBAL
except MSSQL. Can we stick to the majority and name our implementation
accordingly?
> No connection can see data stored in a temporary table by anotherconnection.
Questionable decision, but it seems it's what almost everybody supports.
> A temporary table can be either the referenced or referencing table in aforeign key constraint, but the partner table must
> be a temporary table. If either table is ON DELETE COMMIT, both must beON DELETE COMMIT.
Tend to agree here.
> System table support:I'm with Arno here. Relation type is commonly considered to represent a
> A new field will be added to RDB$RELATIONS, called RDB$RELATION_TYPE.
table or a view.
> Notes:from permanent to temporary or vice-versa is accomplished
> No changes are proposed to ALTER TABLE or DROP TABLE. Changing a table
> by dropping the table and recreating it.Agreed, but a change between DELETE ROWS and PRESERVE ROWS should be
allowed.
> The syntax AS <query expression> has been suggested as an alternative tothe <table contents source> listed in the syntax above. If
> that syntax is part of the SQL-99 standard, I can't find it.<table contents source> ::=
<table element list>
| OF <path-resolved user-defined type name>
[ <subtable clause> ]
[ <table element list> ]
| <as subquery clause>
> A temporary table is represented internally by a TemporaryRelation class,which is a subclass of the Relation class. A
> TemporaryRelation instance is created either by dfw, CStatement, or duringthe processing of blr. TemporaryRelation classes hang
> off the attachment object as well as the Database object. TheTemporaryRelation object provides the location of the index root
> page for that table instance and it's pointer page list.Fine.
> Changes to VIO, DPM, NAV, BTR, and IDX would be primarily cleanup andapplying object discipline to the driving structures. Record
> source blocks become a class hierarchy. References to the sourcerelation would be through either the TemporaryRelation object or
> the Relation.Temporary relation is an incorrect term, as views are also relations. I'd
prefer to see an abstract class Relation with descendant classes
PersistentTable, TemporaryTable, ExternalTable, View.
> Using the active database leverages the existing structures. Free spacecan be located with existing mechanisms completely
> unchanged. Page number references in indexes and blobs can be useddirectly. Cleaning up the pages used by a temporary table in
> the case of a system crash is problematic.references be redirected to the temporary file, increasing the
>
> Using a temporary file requires that space management and all page
> number of layers that must be aware of this change. A temporary file isautomatically destroyed in case of system failure.
Requires more thinking. What about PAG_temporary flag which means that a
page I/O should be redirected to the TempSpace object instead of PIO? In
this case we keep all advantages of VIO and DPM (CCH usage is questionable)
with an ability of a quick data destroy.
Considering the GLOBAL question solved, I don't see how:
1) LOCAL can be implemented
2) AS <subquery> can be implemented
Dmitry