1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

tableam: Add table_get_latest_tid, to wrap heap_get_latest_tid.

This primarily is to allow WHERE CURRENT OF to continue to work as it
currently does. It's not clear to me that these semantics make sense
for every AM, but it works for the in-core heap, and the out of core
zheap. We can refine it further at a later point if necessary.

Author: Andres Freund
Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
This commit is contained in:
Andres Freund
2019-03-25 17:14:48 -07:00
parent 71bdc99d0d
commit 2e3da03e9e
4 changed files with 25 additions and 14 deletions

View File

@ -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;
@ -332,12 +330,6 @@ TidNext(TidScanState *node)
tidList = node->tss_TidList;
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.
*/
@ -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 */