diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 27cbac8..1fb5f4a 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -42,6 +42,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, @@ -294,6 +297,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 bfdadc3..9775aad 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 heap_page_prune_hook_type heap_page_prune_hook; + extern void heap_page_prune_opt(Relation relation, Buffer buffer, TransactionId OldestXmin); extern int heap_page_prune(Relation relation, Buffer buffer,