diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-12-13 12:34:26 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-12-13 12:34:26 -0500 |
commit | 5f7b58fad8f45c69bb67944779dce67e2f481995 (patch) | |
tree | fae9ba84d982d83e9505546facfe17369909994a /src/backend/commands/view.c | |
parent | 0c90442355fbbe785740669f63141f24674c8958 (diff) | |
download | postgresql-5f7b58fad8f45c69bb67944779dce67e2f481995.tar.gz postgresql-5f7b58fad8f45c69bb67944779dce67e2f481995.zip |
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.
Diffstat (limited to 'src/backend/commands/view.c')
-rw-r--r-- | src/backend/commands/view.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 09ab24b0116..2b2b9085005 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -68,10 +68,10 @@ isViewOnTempTable_walker(Node *node, void *context) if (rte->rtekind == RTE_RELATION) { Relation rel = heap_open(rte->relid, AccessShareLock); - bool istemp = rel->rd_istemp; + char relpersistence = rel->rd_rel->relpersistence; heap_close(rel, AccessShareLock); - if (istemp) + if (relpersistence == RELPERSISTENCE_TEMP) return true; } } @@ -173,9 +173,9 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) /* * Due to the namespace visibility rules for temporary objects, we * should only end up replacing a temporary view with another - * temporary view, and vice versa. + * temporary view, and similarly for permanent views. */ - Assert(relation->istemp == rel->rd_istemp); + Assert(relation->relpersistence == rel->rd_rel->relpersistence); /* * Create a tuple descriptor to compare against the existing view, and @@ -454,10 +454,11 @@ DefineView(ViewStmt *stmt, const char *queryString) * schema name. */ view = stmt->view; - if (!view->istemp && isViewOnTempTable(viewParse)) + if (view->relpersistence == RELPERSISTENCE_PERMANENT + && isViewOnTempTable(viewParse)) { view = copyObject(view); /* don't corrupt original command */ - view->istemp = true; + view->relpersistence = RELPERSISTENCE_TEMP; ereport(NOTICE, (errmsg("view \"%s\" will be a temporary view", view->relname))); |