From: Hiroshi Inoue Date: Thu, 9 Aug 2001 19:22:24 +0000 (+0000) Subject: fix my old fault. X-Git-Tag: REL7_1_3~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59e0a858f9d8b5ec6632698fa6b2fa6834e58ca2;p=thirdparty%2Fpostgresql.git fix my old fault. --- diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 48e6c9f2724..87cf2ac4b4f 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.113.2.1 2001/05/17 00:48:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.113.2.2 2001/08/09 19:22:24 inoue Exp $ * * * INTERFACE ROUTINES @@ -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 0807d2531a8..df27f0b4d1f 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -27,7 +27,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.139.2.1 2001/05/15 00:34:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.139.2.2 2001/08/09 19:22:24 inoue Exp $ * *------------------------------------------------------------------------- */ @@ -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 7e3b4bfc257..81822c8dba9 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.24 2001/03/22 03:59:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.24.2.1 2001/08/09 19:22:24 inoue Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -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 4c499151b3e..3aab8d27e37 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: heapam.h,v 1.63 2001/03/22 04:00:27 momjian Exp $ + * $Id: heapam.h,v 1.63.2.1 2001/08/09 19:22:24 inoue Exp $ * *------------------------------------------------------------------------- */ @@ -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,