aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
authorVadim B. Mikheev <vadim4o@yahoo.com>1997-06-04 08:56:51 +0000
committerVadim B. Mikheev <vadim4o@yahoo.com>1997-06-04 08:56:51 +0000
commitded465064278a938e3360dc1ca2259dd0fc1a297 (patch)
treea10c182ed4d50d0b0e40122335a11cd78c192d24 /src/backend/utils/cache/relcache.c
parent4da2ed9f1f7b2cc14f106cac14c1d0d5b72fd4d2 (diff)
downloadpostgresql-ded465064278a938e3360dc1ca2259dd0fc1a297.tar.gz
postgresql-ded465064278a938e3360dc1ca2259dd0fc1a297.zip
New func RelationForgetRelation();
* RelationFlushRelation + if the relation is local then get rid of * the relation descriptor from the newly created relation list.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c62
1 files changed, 53 insertions, 9 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 61c6359e088..0e8bcf8be82 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.8 1997/05/22 17:24:20 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.9 1997/06/04 08:56:51 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -252,6 +252,13 @@ static void build_tupdesc_ind(RelationBuildDescInfo buildinfo,
static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo);
static void IndexedAccessMethodInitialize(Relation relation);
+/*
+ * newlyCreatedRelns -
+ * relations created during this transaction. We need to keep track of
+ * these.
+ */
+static List *newlyCreatedRelns = NULL;
+
/* ----------------------------------------------------------------
* RelationIdGetRelation() and RelationNameGetRelation()
* support functions
@@ -1244,6 +1251,51 @@ RelationFlushRelation(Relation *relationPtr,
}
/* --------------------------------
+ * RelationForgetRelation -
+ * RelationFlushRelation + if the relation is local then get rid of
+ * the relation descriptor from the newly created relation list.
+ * --------------------------------
+ */
+void
+RelationForgetRelation (Oid rid)
+{
+ Relation relation;
+
+ RelationIdCacheLookup (rid, relation);
+ Assert ( PointerIsValid (relation) );
+
+ if ( relation->rd_islocal )
+ {
+ MemoryContext oldcxt;
+ List *curr;
+ List *prev = NIL;
+
+ oldcxt = MemoryContextSwitchTo((MemoryContext)CacheCxt);
+
+ foreach (curr, newlyCreatedRelns)
+ {
+ Relation reln = lfirst(curr);
+
+ Assert ( reln != NULL && reln->rd_islocal );
+ if ( reln->rd_id == rid )
+ break;
+ prev = curr;
+ }
+ if ( curr == NIL )
+ elog (FATAL, "Local relation %.*s not found in list",
+ NAMEDATALEN, (RelationGetRelationName(relation))->data);
+ if ( prev == NIL )
+ newlyCreatedRelns = lnext (newlyCreatedRelns);
+ else
+ lnext (prev) = lnext (curr);
+ pfree (curr);
+ MemoryContextSwitchTo(oldcxt);
+ }
+
+ RelationFlushRelation (&relation, false);
+}
+
+/* --------------------------------
* RelationIdInvalidateRelationCacheByRelationId
* --------------------------------
*/
@@ -1342,14 +1394,6 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero)
Assert(RelationIdCache->hctl->nkeys == 10);
}
}
-
-
-/*
- * newlyCreatedRelns -
- * relations created during this transaction. We need to keep track of
- * these
- */
-static List *newlyCreatedRelns = NULL;
/* --------------------------------