Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ded4650

Browse files
committed
New func RelationForgetRelation();
* RelationFlushRelation + if the relation is local then get rid of * the relation descriptor from the newly created relation list.
1 parent 4da2ed9 commit ded4650

File tree

1 file changed

+53
-9
lines changed

1 file changed

+53
-9
lines changed

src/backend/utils/cache/relcache.c

+53-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.8 1997/05/22 17:24:20 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.9 1997/06/04 08:56:51 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -252,6 +252,13 @@ static void build_tupdesc_ind(RelationBuildDescInfo buildinfo,
252252
static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo);
253253
static void IndexedAccessMethodInitialize(Relation relation);
254254

255+
/*
256+
* newlyCreatedRelns -
257+
* relations created during this transaction. We need to keep track of
258+
* these.
259+
*/
260+
static List *newlyCreatedRelns = NULL;
261+
255262
/* ----------------------------------------------------------------
256263
* RelationIdGetRelation() and RelationNameGetRelation()
257264
* support functions
@@ -1243,6 +1250,51 @@ RelationFlushRelation(Relation *relationPtr,
12431250
}
12441251
}
12451252

1253+
/* --------------------------------
1254+
* RelationForgetRelation -
1255+
* RelationFlushRelation + if the relation is local then get rid of
1256+
* the relation descriptor from the newly created relation list.
1257+
* --------------------------------
1258+
*/
1259+
void
1260+
RelationForgetRelation (Oid rid)
1261+
{
1262+
Relation relation;
1263+
1264+
RelationIdCacheLookup (rid, relation);
1265+
Assert ( PointerIsValid (relation) );
1266+
1267+
if ( relation->rd_islocal )
1268+
{
1269+
MemoryContext oldcxt;
1270+
List *curr;
1271+
List *prev = NIL;
1272+
1273+
oldcxt = MemoryContextSwitchTo((MemoryContext)CacheCxt);
1274+
1275+
foreach (curr, newlyCreatedRelns)
1276+
{
1277+
Relation reln = lfirst(curr);
1278+
1279+
Assert ( reln != NULL && reln->rd_islocal );
1280+
if ( reln->rd_id == rid )
1281+
break;
1282+
prev = curr;
1283+
}
1284+
if ( curr == NIL )
1285+
elog (FATAL, "Local relation %.*s not found in list",
1286+
NAMEDATALEN, (RelationGetRelationName(relation))->data);
1287+
if ( prev == NIL )
1288+
newlyCreatedRelns = lnext (newlyCreatedRelns);
1289+
else
1290+
lnext (prev) = lnext (curr);
1291+
pfree (curr);
1292+
MemoryContextSwitchTo(oldcxt);
1293+
}
1294+
1295+
RelationFlushRelation (&relation, false);
1296+
}
1297+
12461298
/* --------------------------------
12471299
* RelationIdInvalidateRelationCacheByRelationId
12481300
* --------------------------------
@@ -1342,14 +1394,6 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero)
13421394
Assert(RelationIdCache->hctl->nkeys == 10);
13431395
}
13441396
}
1345-
1346-
1347-
/*
1348-
* newlyCreatedRelns -
1349-
* relations created during this transaction. We need to keep track of
1350-
* these
1351-
*/
1352-
static List *newlyCreatedRelns = NULL;
13531397

13541398

13551399
/* --------------------------------

0 commit comments

Comments
 (0)