MCPcopy Create free account
hub / github.com/apache/cloudberry / RelationFlushRelation

Function RelationFlushRelation

src/backend/utils/cache/relcache.c:2922–2950  ·  view source on GitHub ↗

* RelationFlushRelation * * Rebuild the relation if it is open (refcount > 0), else blow it away. * This is used when we receive a cache invalidation event for the rel. */

Source from the content-addressed store, hash-verified

2920 * This is used when we receive a cache invalidation event for the rel.
2921 */
2922static void
2923RelationFlushRelation(Relation relation)
2924{
2925 if (relation->rd_createSubid != InvalidSubTransactionId ||
2926 relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId)
2927 {
2928 /*
2929 * New relcache entries are always rebuilt, not flushed; else we'd
2930 * forget the "new" status of the relation. Ditto for the
2931 * new-relfilenode status.
2932 *
2933 * The rel could have zero refcnt here, so temporarily increment the
2934 * refcnt to ensure it's safe to rebuild it. We can assume that the
2935 * current transaction has some lock on the rel already.
2936 */
2937 RelationIncrementReferenceCount(relation);
2938 RelationClearRelation(relation, true);
2939 RelationDecrementReferenceCount(relation);
2940 }
2941 else
2942 {
2943 /*
2944 * Pre-existing rels can be dropped from the relcache if not open.
2945 */
2946 bool rebuild = !RelationHasReferenceCountZero(relation);
2947
2948 RelationClearRelation(relation, rebuild);
2949 }
2950}
2951
2952/*
2953 * RelationForgetRelation - caller reports that it dropped the relation

Callers 1

Tested by

no test coverage detected