Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitded4650

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 parent4da2ed9 commitded4650

File tree

1 file changed

+53
-9
lines changed

1 file changed

+53
-9
lines changed

‎src/backend/utils/cache/relcache.c

Lines changed: 53 additions & 9 deletions
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
staticRelationRelationBuildDesc(RelationBuildDescInfobuildinfo);
253253
staticvoidIndexedAccessMethodInitialize(Relationrelation);
254254

255+
/*
256+
* newlyCreatedRelns -
257+
* relations created during this transaction. We need to keep track of
258+
* these.
259+
*/
260+
staticList*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 (Oidrid)
1261+
{
1262+
Relationrelation;
1263+
1264+
RelationIdCacheLookup (rid,relation);
1265+
Assert (PointerIsValid (relation) );
1266+
1267+
if (relation->rd_islocal )
1268+
{
1269+
MemoryContextoldcxt;
1270+
List*curr;
1271+
List*prev=NIL;
1272+
1273+
oldcxt=MemoryContextSwitchTo((MemoryContext)CacheCxt);
1274+
1275+
foreach (curr,newlyCreatedRelns)
1276+
{
1277+
Relationreln=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-
staticList*newlyCreatedRelns=NULL;
13531397

13541398

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp