From: Andres Freund Date: Wed, 19 Dec 2018 20:52:18 +0000 (-0800) Subject: tableam: Add function to determine newest xid among tuples. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=415cc80ca6e22144fd5ba4b936071b27e06a3830;p=users%2Fandresfreund%2Fpostgres.git tableam: Add function to determine newest xid among tuples. Author: Reviewed-By: Discussion: https://postgr.es/m/ Backpatch: --- diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index d6de803396..fec649b842 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2316,6 +2316,7 @@ static const TableAmRoutine heapam_methods = { .begin_index_fetch = heapam_begin_index_fetch, .reset_index_fetch = heapam_reset_index_fetch, .end_index_fetch = heapam_end_index_fetch, + .compute_xid_horizon_for_tuples = heap_compute_xid_horizon_for_tuples, .tuple_insert = heapam_heap_insert, .tuple_insert_speculative = heapam_heap_insert_speculative, diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 0b263aaf77..f4a527b126 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 b7db9fa473..d0240d46f7 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -113,6 +113,15 @@ typedef struct TableAmRoutine void (*reset_index_fetch) (struct IndexFetchTableData *data); void (*end_index_fetch) (struct IndexFetchTableData *data); + /* + * 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. @@ -443,6 +452,14 @@ table_end_index_fetch_table(struct IndexFetchTableData *scan) * ---------------------------------------------------------------------------- */ +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); +} + /* * Insert a tuple from a slot into table AM routine */