aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/heap/heapam_handler.c1
-rw-r--r--src/backend/executor/nodeTidscan.c15
-rw-r--r--src/backend/utils/adt/tid.c5
-rw-r--r--src/include/access/tableam.h18
4 files changed, 25 insertions, 14 deletions
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index 00ca71a3d2a..56223921e72 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -542,6 +542,7 @@ static const TableAmRoutine heapam_methods = {
.tuple_lock = heapam_tuple_lock,
.tuple_fetch_row_version = heapam_fetch_row_version,
+ .tuple_get_latest_tid = heap_get_latest_tid,
.tuple_satisfies_snapshot = heapam_tuple_satisfies_snapshot,
};
diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c
index d8f9eb35570..156be56a57d 100644
--- a/src/backend/executor/nodeTidscan.c
+++ b/src/backend/executor/nodeTidscan.c
@@ -22,7 +22,6 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/sysattr.h"
#include "access/tableam.h"
#include "catalog/pg_type.h"
@@ -308,7 +307,6 @@ TidNext(TidScanState *node)
ScanDirection direction;
Snapshot snapshot;
Relation heapRelation;
- HeapTuple tuple;
TupleTableSlot *slot;
ItemPointerData *tidList;
int numTids;
@@ -333,12 +331,6 @@ TidNext(TidScanState *node)
numTids = node->tss_NumTids;
/*
- * We use node->tss_htup as the tuple pointer; note this can't just be a
- * local variable here, as the scan tuple slot will keep a pointer to it.
- */
- tuple = &(node->tss_htup);
-
- /*
* Initialize or advance scan position, depending on direction.
*/
bBackward = ScanDirectionIsBackward(direction);
@@ -365,7 +357,7 @@ TidNext(TidScanState *node)
while (node->tss_TidPtr >= 0 && node->tss_TidPtr < numTids)
{
- tuple->t_self = tidList[node->tss_TidPtr];
+ ItemPointerData tid = tidList[node->tss_TidPtr];
/*
* For WHERE CURRENT OF, the tuple retrieved from the cursor might
@@ -373,10 +365,9 @@ TidNext(TidScanState *node)
* current according to our snapshot.
*/
if (node->tss_isCurrentOf)
- heap_get_latest_tid(heapRelation, snapshot, &tuple->t_self);
+ table_get_latest_tid(heapRelation, snapshot, &tid);
- if (table_fetch_row_version(heapRelation, &tuple->t_self, snapshot,
- slot))
+ if (table_fetch_row_version(heapRelation, &tid, snapshot, slot))
return slot;
/* Bad TID or failed snapshot qual; try next */
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 8c62771261d..6ab26d8ea8b 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -22,6 +22,7 @@
#include "access/heapam.h"
#include "access/sysattr.h"
+#include "access/tableam.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "libpq/pqformat.h"
@@ -379,7 +380,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
ItemPointerCopy(tid, result);
snapshot = RegisterSnapshot(GetLatestSnapshot());
- heap_get_latest_tid(rel, snapshot, result);
+ table_get_latest_tid(rel, snapshot, result);
UnregisterSnapshot(snapshot);
table_close(rel, AccessShareLock);
@@ -414,7 +415,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
ItemPointerCopy(tid, result);
snapshot = RegisterSnapshot(GetLatestSnapshot());
- heap_get_latest_tid(rel, snapshot, result);
+ table_get_latest_tid(rel, snapshot, result);
UnregisterSnapshot(snapshot);
table_close(rel, AccessShareLock);
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index 29371f4c479..4699335cdfd 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -284,6 +284,14 @@ typedef struct TableAmRoutine
TupleTableSlot *slot);
/*
+ * Return the latest version of the tuple at `tid`, by updating `tid` to
+ * point at the newest version.
+ */
+ void (*tuple_get_latest_tid) (Relation rel,
+ Snapshot snapshot,
+ ItemPointer tid);
+
+ /*
* Does the tuple in `slot` satisfy `snapshot`? The slot needs to be of
* the appropriate type for the AM.
*/
@@ -657,6 +665,16 @@ table_fetch_row_version(Relation rel,
}
/*
+ * Return the latest version of the tuple at `tid`, by updating `tid` to
+ * point at the newest version.
+ */
+static inline void
+table_get_latest_tid(Relation rel, Snapshot snapshot, ItemPointer tid)
+{
+ rel->rd_tableam->tuple_get_latest_tid(rel, snapshot, tid);
+}
+
+/*
* Return true iff tuple in slot satisfies the snapshot.
*
* This assumes the slot's tuple is valid, and of the appropriate type for the