aboutsummaryrefslogtreecommitdiff
path: root/src/include/access/heapam.h
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-25 14:59:58 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-25 14:59:58 +0200
commitf83d709760d84253b539ee454ce9ce1ceb9ad9ac (patch)
treefaab56d6b5fc4c320ff10838238cbb2a14588409 /src/include/access/heapam.h
parentd44032d0146306971cd5ccf232fe37269717d6f2 (diff)
downloadpostgresql-f83d709760d84253b539ee454ce9ce1ceb9ad9ac.tar.gz
postgresql-f83d709760d84253b539ee454ce9ce1ceb9ad9ac.zip
Merge prune, freeze and vacuum WAL record formats
The new combined WAL record is now used for pruning, freezing and 2nd pass of vacuum. This is in preparation for changing VACUUM to write a combined prune+freeze record per page, instead of separate two records. The new WAL record format now supports that, but the code still always writes separate records for pruning and freezing. This reserves separate XLOG_HEAP2_* info codes for when the pruning record is emitted for on-access pruning or VACUUM, per Peter Geoghegan's suggestion. The record format is identical, but having separate info codes makes it easier analyze pruning and vacuuming with pg_waldump. The function to emit the new WAL record, log_heap_prune_and_freeze(), is in pruneheap.c. The existing heap_log_freeze_plan() and its subroutines are moved to pruneheap.c without changes, to keep them together with log_heap_prune_and_freeze(). Author: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://www.postgresql.org/message-id/CAAKRu_azf-zH%3DDgVbquZ3tFWjMY1w5pO8m-TXJaMdri8z3933g@mail.gmail.com Discussion: https://www.postgresql.org/message-id/CAAKRu_b2oE4GL%3Dq4g9mcByS9yT7wTQvEH9OLpabj28e%2BWKFi2A@mail.gmail.com
Diffstat (limited to 'src/include/access/heapam.h')
-rw-r--r--src/include/access/heapam.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index 4b133f68593..368c570a0f4 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -211,6 +211,14 @@ typedef struct PruneResult
int8 htsv[MaxHeapTuplesPerPage + 1];
} PruneResult;
+/* 'reason' codes for heap_page_prune() */
+typedef enum
+{
+ PRUNE_ON_ACCESS, /* on-access pruning */
+ PRUNE_VACUUM_SCAN, /* VACUUM 1st heap pass */
+ PRUNE_VACUUM_CLEANUP, /* VACUUM 2nd heap pass */
+} PruneReason;
+
/*
* Pruning calculates tuple visibility once and saves the results in an array
* of int8. See PruneResult.htsv for details. This helper function is meant to
@@ -322,12 +330,21 @@ extern void heap_page_prune(Relation relation, Buffer buffer,
struct GlobalVisState *vistest,
bool mark_unused_now,
PruneResult *presult,
+ PruneReason reason,
OffsetNumber *off_loc);
-extern void heap_page_prune_execute(Buffer buffer,
+extern void heap_page_prune_execute(Buffer buffer, bool lp_truncate_only,
OffsetNumber *redirected, int nredirected,
OffsetNumber *nowdead, int ndead,
OffsetNumber *nowunused, int nunused);
extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets);
+extern void log_heap_prune_and_freeze(Relation relation, Buffer buffer,
+ TransactionId conflict_xid,
+ bool lp_truncate_only,
+ PruneReason reason,
+ HeapTupleFreeze *frozen, int nfrozen,
+ OffsetNumber *redirected, int nredirected,
+ OffsetNumber *dead, int ndead,
+ OffsetNumber *unused, int nunused);
/* in heap/vacuumlazy.c */
struct VacuumParams;