10000 fix my old fault. · jaylevitt/postgres@59e0a85 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59e0a85

Browse files
author
Hiroshi Inoue
committed
fix my old fault.
1 parent 1dcabac commit 59e0a85

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/backend/access/heap/heapam.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.113.2.1 2001/05/17 00:48:45 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.113.2.2 2001/08/09 19:22:24 inoue Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1256,7 +1256,8 @@ heap_get_latest_tid(Relation relation,
12561256
{
12571257
if (linkend)
12581258
return NULL;
1259-
return heap_get_latest_tid(relation, snapshot, &ctid);
1259+
heap_get_latest_tid(relation, snapshot, &ctid);
1260+
*tid = ctid;
12601261
}
12611262

12621263
return tid;

src/backend/executor/execMain.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
*
2929
* IDENTIFICATION
30-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.139.2.1 2001/05/15 00:34:02 tgl Exp $
30+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.139.2.2 2001/08/09 19:22:24 inoue Exp $
3131
*
3232
*-------------------------------------------------------------------------
3333
*/
@@ -1255,6 +1255,7 @@ ExecAppend(TupleTableSlot *slot,
12551255
* insert the tuple
12561256
*/
12571257
newId = heap_insert(resultRelationDesc, tuple);
1258+
setLastTid(&(tuple->t_self));
12581259

12591260
IncrAppended();
12601261
(estate->es_processed)++;

src/backend/utils/adt/tid.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.24 2001/03/22 03:59:54 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.24.2.1 2001/08/09 19:22:24 inoue Exp $
1212
*
1313
* NOTES
1414
* input routine largely stolen from boxin().
@@ -124,22 +124,29 @@ tidne(PG_FUNCTION_ARGS)
124124
*
125125
* Maybe these implementations should be moved to another place
126126
*/
127+
static ItemPointerData Current_last_tid = { {0, 0}, 0};
128+
void setLastTid(const ItemPointer tid)
129+
{
130+
Current_last_tid = *tid;
131+
}
127132
Datum
128133
currtid_byreloid(PG_FUNCTION_ARGS)
129134
{
130135
Oid reloid = PG_GETARG_OID(0);
131136
ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
132-
ItemPointer result,
133-
ret;
137+
ItemPointer result;
134138
Relation rel;
135139

136140
result = (ItemPointer) palloc(sizeof(ItemPointerData));
137-
ItemPointerSetInvalid(result);
141+
if (!reloid)
142+
{
143+
*result = Current_last_tid;
144+
PG_RETURN_ITEMPOINTER(result);
145+
}
146+
ItemPointerCopy(tid, result);
138147
if ((rel = heap_open(reloid, AccessShareLock)) != NULL)
139148
{
140-
ret = heap_get_latest_tid(rel, SnapshotNow, tid);
141-
if (ret)
142-
ItemPointerCopy(ret, result);
149+
heap_get_latest_tid(rel, SnapshotNow, result);
143150
heap_close(rel, AccessShareLock);
144151
}
145152
else
@@ -153,21 +160,18 @@ currtid_byrelname(PG_FUNCTION_ARGS)
153160
{
154161
text *relname = PG_GETARG_TEXT_P(0);
155162
ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
156-
ItemPointer result,
157-
ret;
163+
ItemPointer result;
158164
char *str;
159165
Relation rel;
160166

161167
str = DatumGetCString(DirectFunctionCall1(textout,
162168
PointerGetDatum(relname)));
163169

164170
result = (ItemPointer) palloc(sizeof(ItemPointerData));
165-
ItemPointerSetInvalid(result);
171+
ItemPointerCopy(tid, result);
166172
if ((rel = heap_openr(str, AccessShareLock)) != NULL)
167173
{
168-
ret = heap_get_latest_tid(rel, SnapshotNow, tid);
169-
if (ret)
170-
ItemPointerCopy(ret, result);
174+
heap_get_latest_tid(rel, SnapshotNow, result);
171175
heap_close(rel, AccessShareLock);
172176
}
173177
else

src/include/access/heapam.h

Lines changed: 2 addition 28BE s & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: heapam.h,v 1.63 2001/03/22 04:00:27 momjian Exp $
10+
* $Id: heapam.h,v 1.63.2.1 2001/08/09 19:22:24 inoue Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -204,6 +204,7 @@ extern void heap_endscan(HeapScanDesc scan);
204204
extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw);
205205
extern void heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tup, Buffer *userbuf);
206206
extern ItemPointer heap_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid);
207+
extern void setLastTid(const ItemPointer tid);
207208
extern Oid heap_insert(Relation relation, HeapTuple tup);
208209
extern int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid);
209210
extern int heap_update(Relation relation, ItemPointer otid, HeapTuple tup,

0 commit comments

Comments
 (0)
0