Skip to content

Commit 9f19842

Browse files
committed
Hmm, it seems nodeMaterial has been broken for a good long while;
closing a relcache entry more times than you open it is not cool.
1 parent bd2d098 commit 9f19842

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/backend/executor/nodeMaterial.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.29 2000/01/26 05:56:23 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.30 2000/03/02 04:06:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -86,7 +86,7 @@ ExecMaterial(Material *node)
8686
estate->es_direction = ForwardScanDirection;
8787

8888
/* ----------------
89-
* if we couldn't create the temp or current relations then
89+
* if we couldn't create the temp relation then
9090
* we print a warning and return NULL.
9191
* ----------------
9292
*/
@@ -97,13 +97,6 @@ ExecMaterial(Material *node)
9797
return NULL;
9898
}
9999

100-
currentRelation = matstate->csstate.css_currentRelation;
101-
if (currentRelation == NULL)
102-
{
103-
elog(DEBUG, "ExecMaterial: current relation is NULL! aborting...");
104-
return NULL;
105-
}
106-
107100
/* ----------------
108101
* retrieve tuples from the subplan and
109102
* insert them in the temporary relation
@@ -121,7 +114,6 @@ ExecMaterial(Material *node)
121114

122115
ExecClearTuple(slot);
123116
}
124-
currentRelation = tempRelation;
125117

126118
/* ----------------
127119
* restore to user specified direction
@@ -134,6 +126,7 @@ ExecMaterial(Material *node)
134126
* sorted relation and update the sortstate information
135127
* ----------------
136128
*/
129+
currentRelation = tempRelation;
137130
currentScanDesc = heap_beginscan(currentRelation, /* relation */
138131
ScanDirectionIsBackward(dir),
139132
SnapshotSelf, /* seeself */
@@ -265,15 +258,14 @@ ExecInitMaterial(Material *node, EState *estate, Plan *parent)
265258
* create the temporary relation
266259
* ----------------
267260
*/
268-
/* len = ExecTargetListLength(node->plan.targetlist); */
269261
tempDesc = ExecCreatR(tupType, _NONAME_RELATION_ID_);
270262

271263
/* ----------------
272264
* save the relation descriptor in the sortstate
273265
* ----------------
274266
*/
275267
matstate->mat_TempRelation = tempDesc;
276-
matstate->csstate.css_currentRelation = tempDesc;
268+
matstate->csstate.css_currentRelation = NULL;
277269

278270
/* ----------------
279271
* return relation oid of temporary relation in a list
@@ -312,12 +304,11 @@ ExecEndMaterial(Material *node)
312304
matstate = node->matstate;
313305
tempRelation = matstate->mat_TempRelation;
314306

315-
heap_drop(tempRelation);
316-
317307
/* ----------------
318-
* close the temp relation and shut down the scan.
308+
* shut down the scan, but don't close the temp relation
319309
* ----------------
320310
*/
311+
matstate->csstate.css_currentRelation = NULL;
321312
ExecCloseR((Plan *) node);
322313

323314
/* ----------------
@@ -332,6 +323,13 @@ ExecEndMaterial(Material *node)
332323
* ----------------
333324
*/
334325
ExecClearTuple(matstate->csstate.css_ScanTupleSlot);
326+
327+
/* ----------------
328+
* delete the temp relation
329+
* ----------------
330+
*/
331+
if (tempRelation != NULL)
332+
heap_drop(tempRelation);
335333
}
336334

337335
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy