|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * 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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -252,6 +252,13 @@ static void build_tupdesc_ind(RelationBuildDescInfo buildinfo,
|
252 | 252 | static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo);
|
253 | 253 | static void IndexedAccessMethodInitialize(Relation relation);
|
254 | 254 |
|
| 255 | +/* |
| 256 | + * newlyCreatedRelns - |
| 257 | + * relations created during this transaction. We need to keep track of |
| 258 | + * these. |
| 259 | + */ |
| 260 | +static List *newlyCreatedRelns = NULL; |
| 261 | + |
255 | 262 | /* ----------------------------------------------------------------
|
256 | 263 | * RelationIdGetRelation() and RelationNameGetRelation()
|
257 | 264 | * support functions
|
@@ -1243,6 +1250,51 @@ RelationFlushRelation(Relation *relationPtr,
|
1243 | 1250 | }
|
1244 | 1251 | }
|
1245 | 1252 |
|
| 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 | + |
1246 | 1298 | /* --------------------------------
|
1247 | 1299 | * RelationIdInvalidateRelationCacheByRelationId
|
1248 | 1300 | * --------------------------------
|
@@ -1342,14 +1394,6 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero)
|
1342 | 1394 | Assert(RelationIdCache->hctl->nkeys == 10);
|
1343 | 1395 | }
|
1344 | 1396 | }
|
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; |
1353 | 1397 |
|
1354 | 1398 |
|
1355 | 1399 | /* --------------------------------
|
|
0 commit comments