Commit ded46506 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

New func RelationForgetRelation();

 *         RelationFlushRelation + if the relation is local then get rid of
 *         the relation descriptor from the newly created relation list.
parent 4da2ed9f
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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, ...@@ -252,6 +252,13 @@ static void build_tupdesc_ind(RelationBuildDescInfo buildinfo,
static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo); static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo);
static void IndexedAccessMethodInitialize(Relation relation); 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() * RelationIdGetRelation() and RelationNameGetRelation()
* support functions * support functions
...@@ -1243,6 +1250,51 @@ RelationFlushRelation(Relation *relationPtr, ...@@ -1243,6 +1250,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 * RelationIdInvalidateRelationCacheByRelationId
* -------------------------------- * --------------------------------
...@@ -1344,14 +1396,6 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero) ...@@ -1344,14 +1396,6 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero)
} }
/*
* newlyCreatedRelns -
* relations created during this transaction. We need to keep track of
* these
*/
static List *newlyCreatedRelns = NULL;
/* -------------------------------- /* --------------------------------
* RelationRegisterRelation - * RelationRegisterRelation -
* register the Relation descriptor of a newly created relation * register the Relation descriptor of a newly created relation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment