From: Hiroshi Inoue Date: Thu, 9 Aug 2001 19:22:24 +0000 (+0000) Subject: fix my old fault. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=76ffcadb3e0570d3a7470ba49a47943d557589b7;p=users%2Fbernd%2Fpostgres.git fix my old fault. --- diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 522e2b7977..bf12dad8d9 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -1256,7 +1256,8 @@ heap_get_latest_tid(Relation relation, { if (linkend) return NULL; - return heap_get_latest_tid(relation, snapshot, &ctid); + heap_get_latest_tid(relation, snapshot, &ctid); + *tid = ctid; } return tid; diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 822affed09..4e889d0787 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -1255,6 +1255,7 @@ ExecAppend(TupleTableSlot *slot, * insert the tuple */ newId = heap_insert(resultRelationDesc, tuple); + setLastTid(&(tuple->t_self)); IncrAppended(); (estate->es_processed)++; diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 97da97a01c..f039d69fce 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -124,22 +124,29 @@ tidne(PG_FUNCTION_ARGS) * * Maybe these implementations should be moved to another place */ +static ItemPointerData Current_last_tid = { {0, 0}, 0}; +void setLastTid(const ItemPointer tid) +{ + Current_last_tid = *tid; +} Datum currtid_byreloid(PG_FUNCTION_ARGS) { Oid reloid = PG_GETARG_OID(0); ItemPointer tid = PG_GETARG_ITEMPOINTER(1); - ItemPointer result, - ret; + ItemPointer result; Relation rel; result = (ItemPointer) palloc(sizeof(ItemPointerData)); - ItemPointerSetInvalid(result); + if (!reloid) + { + *result = Current_last_tid; + PG_RETURN_ITEMPOINTER(result); + } + ItemPointerCopy(tid, result); if ((rel = heap_open(reloid, AccessShareLock)) != NULL) { - ret = heap_get_latest_tid(rel, SnapshotNow, tid); - if (ret) - ItemPointerCopy(ret, result); + heap_get_latest_tid(rel, SnapshotNow, result); heap_close(rel, AccessShareLock); } else @@ -153,8 +160,7 @@ currtid_byrelname(PG_FUNCTION_ARGS) { text *relname = PG_GETARG_TEXT_P(0); ItemPointer tid = PG_GETARG_ITEMPOINTER(1); - ItemPointer result, - ret; + ItemPointer result; char *str; Relation rel; @@ -162,12 +168,10 @@ currtid_byrelname(PG_FUNCTION_ARGS) PointerGetDatum(relname))); result = (ItemPointer) palloc(sizeof(ItemPointerData)); - ItemPointerSetInvalid(result); + ItemPointerCopy(tid, result); if ((rel = heap_openr(str, AccessShareLock)) != NULL) { - ret = heap_get_latest_tid(rel, SnapshotNow, tid); - if (ret) - ItemPointerCopy(ret, result); + heap_get_latest_tid(rel, SnapshotNow, result); heap_close(rel, AccessShareLock); } else diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 089dfee6aa..2c1415c3ee 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -204,6 +204,7 @@ extern void heap_endscan(HeapScanDesc scan); extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw); extern void heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tup, Buffer *userbuf); extern ItemPointer heap_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid); +extern void setLastTid(const ItemPointer tid); extern Oid heap_insert(Relation relation, HeapTuple tup); extern int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid); extern int heap_update(Relation relation, ItemPointer otid, HeapTuple tup,