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

Function CacheInvalidateHeapTuple

src/backend/utils/cache/inval.c:1204–1337  ·  view source on GitHub ↗

* CacheInvalidateHeapTuple * Register the given tuple for invalidation at end of command * (ie, current command is creating or outdating this tuple). * Also, detect whether a relcache invalidation is implied. * * For an insert or delete, tuple is the target tuple and newtuple is NULL. * For an update, we are called just once, with tuple being the old tuple * version and newtuple the new

Source from the content-addressed store, hash-verified

1202 * effort during an update.
1203 */
1204void
1205CacheInvalidateHeapTuple(Relation relation,
1206 HeapTuple tuple,
1207 HeapTuple newtuple)
1208{
1209 Oid tupleRelId;
1210 Oid databaseId;
1211 Oid relationId;
1212
1213 /* Do nothing during bootstrap */
1214 if (IsBootstrapProcessingMode())
1215 return;
1216
1217 /*
1218 * We only need to worry about invalidation for tuples that are in system
1219 * catalogs; user-relation tuples are never in catcaches and can't affect
1220 * the relcache either.
1221 */
1222 if (!IsCatalogRelation(relation))
1223 return;
1224
1225 /*
1226 * IsCatalogRelation() will return true for TOAST tables of system
1227 * catalogs, but we don't care about those, either.
1228 */
1229 if (IsToastRelation(relation))
1230 return;
1231
1232 /*
1233 * If we're not prepared to queue invalidation messages for this
1234 * subtransaction level, get ready now.
1235 */
1236 PrepareInvalidationState();
1237
1238 /*
1239 * First let the catcache do its thing
1240 */
1241 tupleRelId = RelationGetRelid(relation);
1242 if (RelationInvalidatesSnapshotsOnly(tupleRelId))
1243 {
1244 databaseId = IsSharedRelation(tupleRelId) ? InvalidOid : MyDatabaseId;
1245 RegisterSnapshotInvalidation(databaseId, tupleRelId);
1246 }
1247 else
1248 PrepareToInvalidateCacheTuple(relation, tuple, newtuple,
1249 RegisterCatcacheInvalidation);
1250
1251 /*
1252 * Now, is this tuple one of the primary definers of a relcache entry? See
1253 * comments in file header for deeper explanation.
1254 *
1255 * Note we ignore newtuple here; we assume an update cannot move a tuple
1256 * from being part of one relcache entry to being part of another.
1257 */
1258 if (tupleRelId == RelationRelationId)
1259 {
1260 Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple);
1261

Callers 7

AlterDomainAddConstraintFunction · 0.85
heap_insertFunction · 0.85
heap_multi_insertFunction · 0.85
heap_deleteFunction · 0.85
heap_update_internalFunction · 0.85
heap_inplace_updateFunction · 0.85

Calls 8

IsCatalogRelationFunction · 0.85
IsToastRelationFunction · 0.85
PrepareInvalidationStateFunction · 0.85
IsSharedRelationFunction · 0.85

Tested by

no test coverage detected