Skip to content

Commit 58617ea

Browse files
Harry Leayushdsh
authored andcommitted
[MANFRED-31655] Fixes after community commit 1d7b02711f7
cr: https://code.amazon.com/reviews/CR-245879648 (cherry picked from commit 50b2b2b28cbcf50b235de7dfab57ce742ae88cc3)
1 parent f24fd54 commit 58617ea

1 file changed

Lines changed: 32 additions & 17 deletions

File tree

src/backend/utils/cache/inval.c

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,12 @@ RegisterCatcacheInvalidation(int cacheId,
590590
static void
591591
RegisterENRCatcacheInvalidation(int cacheId,
592592
uint32 hashValue,
593-
Oid dbId)
593+
Oid dbId,
594+
void *context)
594595
{
596+
InvalidationInfo *info = (InvalidationInfo *) context;
595597
SaveCatcacheMessage(cacheId, hashValue, dbId);
596-
AddCatcacheInvalidationMessage(&transInvalInfo->CurrentCmdInvalidMsgs,
598+
AddCatcacheInvalidationMessage(&info->CurrentCmdInvalidMsgs,
597599
cacheId, hashValue, dbId);
598600
}
599601

@@ -1515,16 +1517,17 @@ CacheInvalidateHeapTupleInplace(Relation relation,
15151517
}
15161518

15171519
/*
1518-
* This is nearly identical to CacheInvalidateHeapTuple but specifically called from
1519-
* ENR codepaths. This helps us avoid a larger refactor.
1520-
*
1521-
* We call our new callback RegisterENRCatcacheInvalidation instead.
1520+
* CacheInvalidateENRHeapTupleCommon
1521+
* Common logic for end-of-command and inplace variants in CacheInvalidateENRHeapTuple,
1522+
* similar to CacheInvalidateHeapTupleCommon for CacheInvalidateHeapTuple
15221523
*/
1523-
void
1524-
CacheInvalidateENRHeapTuple(Relation relation,
1524+
static void
1525+
CacheInvalidateENRHeapTupleCommon(Relation relation,
15251526
HeapTuple tuple,
1526-
HeapTuple newtuple)
1527+
HeapTuple newtuple,
1528+
InvalidationInfo *(*prepare_callback) (void))
15271529
{
1530+
InvalidationInfo *info;
15281531
Oid tupleRelId;
15291532
Oid databaseId;
15301533
Oid relationId;
@@ -1548,11 +1551,8 @@ CacheInvalidateENRHeapTuple(Relation relation,
15481551
if (IsToastRelation(relation))
15491552
return;
15501553

1551-
/*
1552-
* If we're not prepared to queue invalidation messages for this
1553-
* subtransaction level, get ready now.
1554-
*/
1555-
PrepareInvalidationState();
1554+
/* Allocate any required resources. */
1555+
info = PrepareInvalidationState();
15561556

15571557
/*
15581558
* First let the catcache do its thing
@@ -1561,11 +1561,12 @@ CacheInvalidateENRHeapTuple(Relation relation,
15611561
if (RelationInvalidatesSnapshotsOnly(tupleRelId))
15621562
{
15631563
databaseId = IsSharedRelation(tupleRelId) ? InvalidOid : MyDatabaseId;
1564-
RegisterSnapshotInvalidation(databaseId, tupleRelId);
1564+
RegisterSnapshotInvalidation(info, databaseId, tupleRelId);
15651565
}
15661566
else
15671567
PrepareToInvalidateCacheTuple(relation, tuple, newtuple,
1568-
RegisterENRCatcacheInvalidation);
1568+
RegisterENRCatcacheInvalidation,
1569+
info);
15691570

15701571
/*
15711572
* Now, is this tuple one of the primary definers of a relcache entry? See
@@ -1638,7 +1639,21 @@ CacheInvalidateENRHeapTuple(Relation relation,
16381639
/*
16391640
* Yes. We need to register a relcache invalidation event.
16401641
*/
1641-
RegisterRelcacheInvalidation(databaseId, relationId);
1642+
RegisterRelcacheInvalidation(info, databaseId, relationId);
1643+
}
1644+
1645+
/*
1646+
* This is nearly identical to CacheInvalidateHeapTuple but specifically called from
1647+
* ENR codepaths. This helps us avoid a larger refactor.
1648+
*
1649+
* We call our new callback RegisterENRCatcacheInvalidation instead.
1650+
*/
1651+
void
1652+
CacheInvalidateENRHeapTuple(Relation relation,
1653+
HeapTuple tuple,
1654+
HeapTuple newtuple)
1655+
{
1656+
CacheInvalidateENRHeapTupleCommon(relation, tuple, newtuple, PrepareInvalidationState);
16421657
}
16431658

16441659
/*

0 commit comments

Comments
 (0)