]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
fix my old fault.
authorHiroshi Inoue <inoue@tpf.co.jp>
Thu, 9 Aug 2001 19:22:24 +0000 (19:22 +0000)
committerHiroshi Inoue <inoue@tpf.co.jp>
Thu, 9 Aug 2001 19:22:24 +0000 (19:22 +0000)
src/backend/access/heap/heapam.c
src/backend/executor/execMain.c
src/backend/utils/adt/tid.c
src/include/access/heapam.h

index 48e6c9f2724b3b494570aea0192151a6419b68d3..87cf2ac4b4f0bcaa34ed0ebe235b4e1c937897fa 100644 (file)
@@ -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;
index 0807d2531a81d694872e37ea6c80b33dcf74d24e..df27f0b4d1f075ad75980d768001fb1e85a58bc2 100644 (file)
@@ -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)++;
index 7e3b4bfc257f8c64b5ab20f88083ab3763fe38fe..81822c8dba9edfb3e4acd906cf740895def2dea7 100644 (file)
@@ -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
index 4c499151b3e3e62fc1767db20972a12fb814d9bb..3aab8d27e37c213eafd552da8c60c715526ad81e 100644 (file)
@@ -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,