1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Generalize concept of temporary relations to "relation persistence".

This commit replaces pg_class.relistemp with pg_class.relpersistence;
and also modifies the RangeVar node type to carry relpersistence rather
than istemp.  It also removes removes rd_istemp from RelationData and
instead performs the correct computation based on relpersistence.

For clarity, we add three new macros: RelationNeedsWAL(),
RelationUsesLocalBuffers(), and RelationUsesTempNamespace(), so that we
can clarify the purpose of each check that previous depended on
rd_istemp.

This is intended as infrastructure for the upcoming unlogged tables
patch, as well as for future possible work on global temporary tables.
This commit is contained in:
Robert Haas
2010-12-13 12:34:26 -05:00
parent 0c90442355
commit 5f7b58fad8
48 changed files with 334 additions and 230 deletions

View File

@ -2131,7 +2131,8 @@ OpenIntoRel(QueryDesc *queryDesc)
/*
* Check consistency of arguments
*/
if (into->onCommit != ONCOMMIT_NOOP && !into->rel->istemp)
if (into->onCommit != ONCOMMIT_NOOP
&& into->rel->relpersistence != RELPERSISTENCE_TEMP)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("ON COMMIT can only be used on temporary tables")));
@ -2141,7 +2142,8 @@ OpenIntoRel(QueryDesc *queryDesc)
* code. This is needed because calling code might not expect untrusted
* tables to appear in pg_temp at the front of its search path.
*/
if (into->rel->istemp && InSecurityRestrictedOperation())
if (into->rel->relpersistence == RELPERSISTENCE_TEMP
&& InSecurityRestrictedOperation())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("cannot create temporary table within security-restricted operation")));
@ -2168,7 +2170,7 @@ OpenIntoRel(QueryDesc *queryDesc)
}
else
{
tablespaceId = GetDefaultTablespace(into->rel->istemp);
tablespaceId = GetDefaultTablespace(into->rel->relpersistence);
/* note InvalidOid is OK in this case */
}
@ -2208,6 +2210,7 @@ OpenIntoRel(QueryDesc *queryDesc)
tupdesc,
NIL,
RELKIND_RELATION,
into->rel->relpersistence,
false,
false,
true,