diff options
| author | Melanie Plageman <melanieplageman@gmail.com> | 2025-11-20 10:30:43 -0500 |
|---|---|---|
| committer | Melanie Plageman <melanieplageman@gmail.com> | 2025-11-20 10:32:14 -0500 |
| commit | 1937ed70621e203c99e651ce4430dd217743d150 (patch) | |
| tree | a62e02bf2d562cb61d151c7c0d6596268cc5817c /src/include/access/heapam.h | |
| parent | fa0ffa28778fbf4056a77f7b76361d295a737df6 (diff) | |
Refactor heap_page_prune_and_freeze() parameters into a struct
heap_page_prune_and_freeze() had accumulated an unwieldy number of input
parameters and upcoming work to handle VM updates in this function will
add even more.
Introduce a new PruneFreezeParams struct to group the function’s input
parameters, improving readability and maintainability.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://postgr.es/m/yn4zp35kkdsjx6wf47zcfmxgexxt4h2og47pvnw2x5ifyrs3qc%407uw6jyyxuyf7
Diffstat (limited to 'src/include/access/heapam.h')
| -rw-r--r-- | src/include/access/heapam.h | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 909db73b7bb..632c4332a8c 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -221,6 +221,56 @@ typedef struct HeapPageFreeze } HeapPageFreeze; + +/* 'reason' codes for heap_page_prune_and_freeze() */ +typedef enum +{ + PRUNE_ON_ACCESS, /* on-access pruning */ + PRUNE_VACUUM_SCAN, /* VACUUM 1st heap pass */ + PRUNE_VACUUM_CLEANUP, /* VACUUM 2nd heap pass */ +} PruneReason; + +/* + * Input parameters to heap_page_prune_and_freeze() + */ +typedef struct PruneFreezeParams +{ + Relation relation; /* relation containing buffer to be pruned */ + Buffer buffer; /* buffer to be pruned */ + + /* + * The reason pruning was performed. It is used to set the WAL record + * opcode which is used for debugging and analysis purposes. + */ + PruneReason reason; + + /* + * Contains flag bits: + * + * HEAP_PAGE_PRUNE_MARK_UNUSED_NOW indicates that dead items can be set + * LP_UNUSED during pruning. + * + * HEAP_PAGE_PRUNE_FREEZE indicates that we will also freeze tuples, and + * will return 'all_visible', 'all_frozen' flags to the caller. + */ + int options; + + /* + * vistest is used to distinguish whether tuples are DEAD or RECENTLY_DEAD + * (see heap_prune_satisfies_vacuum). + */ + GlobalVisState *vistest; + + /* + * Contains the cutoffs used for freezing. They are required if the + * HEAP_PAGE_PRUNE_FREEZE option is set. cutoffs->OldestXmin is also used + * to determine if dead tuples are HEAPTUPLE_RECENTLY_DEAD or + * HEAPTUPLE_DEAD. Currently only vacuum passes in cutoffs. Vacuum + * calculates them once, at the beginning of vacuuming the relation. + */ + struct VacuumCutoffs *cutoffs; +} PruneFreezeParams; + /* * Per-page state returned by heap_page_prune_and_freeze() */ @@ -264,13 +314,6 @@ typedef struct PruneFreezeResult OffsetNumber deadoffsets[MaxHeapTuplesPerPage]; } PruneFreezeResult; -/* 'reason' codes for heap_page_prune_and_freeze() */ -typedef enum -{ - PRUNE_ON_ACCESS, /* on-access pruning */ - PRUNE_VACUUM_SCAN, /* VACUUM 1st heap pass */ - PRUNE_VACUUM_CLEANUP, /* VACUUM 2nd heap pass */ -} PruneReason; /* ---------------- * function prototypes for heap access method @@ -367,12 +410,8 @@ extern TransactionId heap_index_delete_tuples(Relation rel, /* in heap/pruneheap.c */ extern void heap_page_prune_opt(Relation relation, Buffer buffer); -extern void heap_page_prune_and_freeze(Relation relation, Buffer buffer, - GlobalVisState *vistest, - int options, - struct VacuumCutoffs *cutoffs, +extern void heap_page_prune_and_freeze(PruneFreezeParams *params, PruneFreezeResult *presult, - PruneReason reason, OffsetNumber *off_loc, TransactionId *new_relfrozen_xid, MultiXactId *new_relmin_mxid); |
