src/backend/access/heap/pruneheap.c | 13 +++++++++++++ src/include/access/heapam.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 3c69e1b..5bf7cea 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -43,6 +43,9 @@ typedef struct bool marked[MaxHeapTuplesPerPage + 1]; } PruneState; +/* Callback for each page pruning */ +heap_page_prune_hook_type heap_page_prune_hook = NULL; + /* Local functions */ static int heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum, @@ -311,6 +314,16 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, * and update FSM with the remaining space. */ + /* + * This callback allows extensions to synchronize their own status with + * heap image on the disk, when this buffer page is vacuumed. + */ + if (heap_page_prune_hook) + (*heap_page_prune_hook)(relation, + buffer, + ndeleted, + OldestXmin, + prstate.latestRemovedXid); return ndeleted; } diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 0f80257..e88e839 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -164,6 +164,13 @@ extern void heap_restrpos(HeapScanDesc scan); extern void heap_sync(Relation relation); /* in heap/pruneheap.c */ +typedef void (*heap_page_prune_hook_type)(Relation relation, + Buffer buffer, + int ndeleted, + TransactionId OldestXmin, + TransactionId latestRemovedXid); +extern PGDLLIMPORT heap_page_prune_hook_type heap_page_prune_hook; + extern void heap_page_prune_opt(Relation relation, Buffer buffer); extern int heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin,