Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e3da03

Browse files
committed
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 itcurrently does. It's not clear to me that these semantics make sensefor every AM, but it works for the in-core heap, and the out of corezheap. We can refine it further at a later point if necessary.Author: Andres FreundDiscussion:https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
1 parent71bdc99 commit2e3da03

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

‎src/backend/access/heap/heapam_handler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ static const TableAmRoutine heapam_methods = {
542542
.tuple_lock=heapam_tuple_lock,
543543

544544
.tuple_fetch_row_version=heapam_fetch_row_version,
545+
.tuple_get_latest_tid=heap_get_latest_tid,
545546
.tuple_satisfies_snapshot=heapam_tuple_satisfies_snapshot,
546547
};
547548

‎src/backend/executor/nodeTidscan.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323
#include"postgres.h"
2424

25-
#include"access/heapam.h"
2625
#include"access/sysattr.h"
2726
#include"access/tableam.h"
2827
#include"catalog/pg_type.h"
@@ -308,7 +307,6 @@ TidNext(TidScanState *node)
308307
ScanDirectiondirection;
309308
Snapshotsnapshot;
310309
RelationheapRelation;
311-
HeapTupletuple;
312310
TupleTableSlot*slot;
313311
ItemPointerData*tidList;
314312
intnumTids;
@@ -332,12 +330,6 @@ TidNext(TidScanState *node)
332330
tidList=node->tss_TidList;
333331
numTids=node->tss_NumTids;
334332

335-
/*
336-
* We use node->tss_htup as the tuple pointer; note this can't just be a
337-
* local variable here, as the scan tuple slot will keep a pointer to it.
338-
*/
339-
tuple=&(node->tss_htup);
340-
341333
/*
342334
* Initialize or advance scan position, depending on direction.
343335
*/
@@ -365,18 +357,17 @@ TidNext(TidScanState *node)
365357

366358
while (node->tss_TidPtr >=0&&node->tss_TidPtr<numTids)
367359
{
368-
tuple->t_self=tidList[node->tss_TidPtr];
360+
ItemPointerDatatid=tidList[node->tss_TidPtr];
369361

370362
/*
371363
* For WHERE CURRENT OF, the tuple retrieved from the cursor might
372364
* since have been updated; if so, we should fetch the version that is
373365
* current according to our snapshot.
374366
*/
375367
if (node->tss_isCurrentOf)
376-
heap_get_latest_tid(heapRelation,snapshot,&tuple->t_self);
368+
table_get_latest_tid(heapRelation,snapshot,&tid);
377369

378-
if (table_fetch_row_version(heapRelation,&tuple->t_self,snapshot,
379-
slot))
370+
if (table_fetch_row_version(heapRelation,&tid,snapshot,slot))
380371
returnslot;
381372

382373
/* Bad TID or failed snapshot qual; try next */

‎src/backend/utils/adt/tid.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include"access/heapam.h"
2424
#include"access/sysattr.h"
25+
#include"access/tableam.h"
2526
#include"catalog/namespace.h"
2627
#include"catalog/pg_type.h"
2728
#include"libpq/pqformat.h"
@@ -379,7 +380,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
379380
ItemPointerCopy(tid,result);
380381

381382
snapshot=RegisterSnapshot(GetLatestSnapshot());
382-
heap_get_latest_tid(rel,snapshot,result);
383+
table_get_latest_tid(rel,snapshot,result);
383384
UnregisterSnapshot(snapshot);
384385

385386
table_close(rel,AccessShareLock);
@@ -414,7 +415,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
414415
ItemPointerCopy(tid,result);
415416

416417
snapshot=RegisterSnapshot(GetLatestSnapshot());
417-
heap_get_latest_tid(rel,snapshot,result);
418+
table_get_latest_tid(rel,snapshot,result);
418419
UnregisterSnapshot(snapshot);
419420

420421
table_close(rel,AccessShareLock);

‎src/include/access/tableam.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ typedef struct TableAmRoutine
283283
Snapshotsnapshot,
284284
TupleTableSlot*slot);
285285

286+
/*
287+
* Return the latest version of the tuple at `tid`, by updating `tid` to
288+
* point at the newest version.
289+
*/
290+
void(*tuple_get_latest_tid) (Relationrel,
291+
Snapshotsnapshot,
292+
ItemPointertid);
293+
286294
/*
287295
* Does the tuple in `slot` satisfy `snapshot`? The slot needs to be of
288296
* the appropriate type for the AM.
@@ -656,6 +664,16 @@ table_fetch_row_version(Relation rel,
656664
returnrel->rd_tableam->tuple_fetch_row_version(rel,tid,snapshot,slot);
657665
}
658666

667+
/*
668+
* Return the latest version of the tuple at `tid`, by updating `tid` to
669+
* point at the newest version.
670+
*/
671+
staticinlinevoid
672+
table_get_latest_tid(Relationrel,Snapshotsnapshot,ItemPointertid)
673+
{
674+
rel->rd_tableam->tuple_get_latest_tid(rel,snapshot,tid);
675+
}
676+
659677
/*
660678
* Return true iff tuple in slot satisfies the snapshot.
661679
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp