Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/backend/utils/cache/inval.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ static TransInvalidationInfo *transInvalInfo = NULL;
/* GUC storage */
int debug_discard_caches = 0;

/* Hook for extensions to receive custom invalidation messages */
ReceiveCustomInvalMessage_hook_type ReceiveCustomInvalMessage_hook = NULL;

/*
* Dynamically-registered callback functions. Current implementation
* assumes there won't be enough of these to justify a dynamically resizable
Expand Down Expand Up @@ -827,6 +830,18 @@ InvalidateSystemCaches(void)
InvalidateSystemCachesExtended(false);
}

/*
* ReceiveCustomInvalMessage
* Call the ReceiveCustomInvalMessage_hook if set, allowing extensions
* to process their own invalidation messages.
*/
void
ReceiveCustomInvalMessage(void)
{
if (ReceiveCustomInvalMessage_hook)
(*ReceiveCustomInvalMessage_hook) ();
}

/*
* AcceptInvalidationMessages
* Read and process invalidation messages from the shared invalidation
Expand All @@ -838,6 +853,9 @@ InvalidateSystemCaches(void)
void
AcceptInvalidationMessages(void)
{
/* Process any messages from external sources first. */
ReceiveCustomInvalMessage();

ReceiveSharedInvalidMessages(LocalExecuteInvalidationMessage,
InvalidateSystemCaches);

Expand Down
5 changes: 5 additions & 0 deletions src/include/utils/inval.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@

extern PGDLLIMPORT int debug_discard_caches;

/* Hook for extensions to receive custom invalidation messages */
typedef void (*ReceiveCustomInvalMessage_hook_type) (void);
extern PGDLLIMPORT ReceiveCustomInvalMessage_hook_type ReceiveCustomInvalMessage_hook;

typedef void (*SyscacheCallbackFunction) (Datum arg, int cacheid, uint32 hashvalue);
typedef void (*RelcacheCallbackFunction) (Datum arg, Oid relid);
typedef void (*UsercacheCallbackFunction) (Datum arg, Oid arg1, Oid arg2, Oid arg3);


extern void AcceptInvalidationMessages(void);
extern void ReceiveCustomInvalMessage(void);

extern void AtEOXact_Inval(bool isCommit);

Expand Down