Subject: [PATCH v18 17/18] tableam: Add function to determine newest xid among tuples.

From: Andres Freund <[email-masked]>
Date: Wed, 19 Dec 2018 12:52:18 -0800

Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:
---
 src/backend/access/heap/heapam_handler.c |  1 +
 src/backend/access/index/genam.c         |  2 +-
 src/include/access/tableam.h             | 17 +++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index b183b22ca16..eba8dbb28da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -2340,6 +2340,7 @@ static const TableAmRoutine heapam_methods = {
 	.tuple_fetch_row_version = heapam_fetch_row_version,
 	.tuple_get_latest_tid = heap_get_latest_tid,
 	.tuple_satisfies_snapshot = heapam_tuple_satisfies_snapshot,
+	.compute_xid_horizon_for_tuples = heap_compute_xid_horizon_for_tuples,
 
 	.relation_set_new_filenode = heapam_set_new_filenode,
 	.relation_nontransactional_truncate = heapam_relation_nontransactional_truncate,
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
index 3dbb264e728..70de8ff75f7 100644
--- a/src/backend/access/index/genam.c
+++ b/src/backend/access/index/genam.c
@@ -302,7 +302,7 @@ index_compute_xid_horizon_for_tuples(Relation irel,
 
 	/* determine the actual xid horizon */
 	latestRemovedXid =
-		heap_compute_xid_horizon_for_tuples(hrel, htids, nitems);
+		table_compute_xid_horizon_for_tuples(hrel, htids, nitems);
 
 	pfree(htids);
 
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index 2ed25ec748f..827fe6f35a7 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -240,6 +240,15 @@ typedef struct TableAmRoutine
 	bool		(*tuple_satisfies_snapshot) (Relation rel,
 											 TupleTableSlot *slot,
 											 Snapshot snapshot);
+	/*
+	 * Compute the newest xid among the tuples pointed to by items. This is
+	 * used to compute what snapshots to conflict with when replaying WAL
+	 * records for page-level index vacuums.
+	 */
+	TransactionId (*compute_xid_horizon_for_tuples) (Relation rel,
+													 ItemPointerData *items,
+													 int nitems);
+
 
 	/* ------------------------------------------------------------------------
 	 * Manipulations of physical tuples.
@@ -678,6 +687,14 @@ table_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot, Snapshot snap
 	return rel->rd_tableam->tuple_satisfies_snapshot(rel, slot, snapshot);
 }
 
+static inline TransactionId
+table_compute_xid_horizon_for_tuples(Relation rel,
+									 ItemPointerData *items,
+									 int nitems)
+{
+	return rel->rd_tableam->compute_xid_horizon_for_tuples(rel, items, nitems);
+}
+
 
 /* ----------------------------------------------------------------------------
  *  Functions for manipulations of physical tuples.
-- 
2.21.0.dirty

--yvn3crbc4qf4vymf
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v18-0018-tableam-Fetch-tuples-for-triggers-EPQ-using-a-pr.patch"