Skip to content

Commit 53b2e00

Browse files
author
Hiroshi Inoue
committed
Keep the contents of ItemPointerData not the pointers so that
per tuple memory context doesn't discard them.
1 parent 793bcc6 commit 53b2e00

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/backend/executor/nodeTidscan.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.18 2001/06/22 19:16:22 wieck Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.19 2001/09/29 07:57:06 inoue Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -29,11 +29,11 @@
2929
#include "access/heapam.h"
3030
#include "parser/parsetree.h"
3131

32-
static int TidListCreate(List *, ExprContext *, ItemPointer *);
32+
static int TidListCreate(List *, ExprContext *, ItemPointerData []);
3333
static TupleTableSlot *TidNext(TidScan *node);
3434

3535
static int
36-
TidListCreate(List *evalList, ExprContext *econtext, ItemPointer *tidList)
36+
TidListCreate(List *evalList, ExprContext *econtext, ItemPointerData tidList[])
3737
{
3838
List *lst;
3939
ItemPointer itemptr;
@@ -49,7 +49,7 @@ TidListCreate(List *evalList, ExprContext *econtext, ItemPointer *tidList)
4949
NULL));
5050
if (!isNull && itemptr && ItemPointerIsValid(itemptr))
5151
{
52-
tidList[numTids] = itemptr;
52+
tidList[numTids] = *itemptr;
5353
numTids++;
5454
}
5555
}
@@ -80,8 +80,7 @@ TidNext(TidScan *node)
8080

8181
bool bBackward;
8282
int tidNumber;
83-
ItemPointer *tidList,
84-
itemptr;
83+
ItemPointerData* tidList;
8584

8685
/*
8786
* extract necessary information from tid scan node
@@ -146,14 +145,10 @@ TidNext(TidScan *node)
146145
{
147146
bool slot_is_valid = false;
148147

149-
itemptr = tidList[tidstate->tss_TidPtr];
150148
tuple->t_datamcxt = NULL;
151149
tuple->t_data = NULL;
152-
if (itemptr)
153-
{
154-
tuple->t_self = *(itemptr);
155-
heap_fetch(heapRelation, snapshot, tuple, &buffer, NULL);
156-
}
150+
tuple->t_self = tidList[tidstate->tss_TidPtr];
151+
heap_fetch(heapRelation, snapshot, tuple, &buffer, NULL);
157152
if (tuple->t_data != NULL)
158153
{
159154
bool prev_matches = false;
@@ -187,7 +182,7 @@ TidNext(TidScan *node)
187182
for (prev_tid = 0; prev_tid < tidstate->tss_TidPtr;
188183
prev_tid++)
189184
{
190-
if (ItemPointerEquals(tidList[prev_tid], &tuple->t_self))
185+
if (ItemPointerEquals(&tidList[prev_tid], &tuple->t_self))
191186
{
192187
prev_matches = true;
193188
break;
@@ -254,7 +249,7 @@ ExecTidReScan(TidScan *node, ExprContext *exprCtxt, Plan *parent)
254249
{
255250
EState *estate;
256251
TidScanState *tidstate;
257-
ItemPointer *tidList;
252+
ItemPointerData* tidList;
258253

259254
tidstate = node->tidstate;
260255
estate = node->scan.plan.state;
@@ -381,7 +376,7 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent)
381376
{
382377
TidScanState *tidstate;
383378
CommonScanState *scanstate;
384-
ItemPointer *tidList;
379+
ItemPointerData* tidList;
385380
int numTids;
386381
int tidPtr;
387382
List *rangeTable;
@@ -436,7 +431,7 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent)
436431
/*
437432
* get the tid node information
438433
*/
439-
tidList = (ItemPointer *) palloc(length(node->tideval) * sizeof(ItemPointer));
434+
tidList = (ItemPointerData *) palloc(length(node->tideval) * sizeof(ItemPointerData));
440435
numTids = 0;
441436
if (!node->needRescan)
442437
numTids = TidListCreate(node->tideval, scanstate->cstate.cs_ExprContext, tidList);

src/include/nodes/execnodes.h

Lines changed: 2 additions & 2 deletions
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: execnodes.h,v 1.62 2001/07/16 05:07:00 tgl Exp $
10+
* $Id: execnodes.h,v 1.63 2001/09/29 07:57:04 inoue Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -461,7 +461,7 @@ typedef struct TidScanState
461461
int tss_NumTids;
462462
int tss_TidPtr;
463463
int tss_MarkTidPtr;
464-
ItemPointer *tss_TidList;
464+
ItemPointerData* tss_TidList;
465465
HeapTupleData tss_htup;
466466
} TidScanState;
467467

0 commit comments

Comments
 (0)