8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -86,7 +86,7 @@ ExecMaterial(Material *node)
86
86
estate -> es_direction = ForwardScanDirection ;
87
87
88
88
/* ----------------
89
- * if we couldn't create the tempor current relations then
89
+ * if we couldn't create the temprelation then
90
90
* we print a warning and return NULL.
91
91
* ----------------
92
92
*/
@@ -97,13 +97,6 @@ ExecMaterial(Material *node)
97
97
return NULL ;
98
98
}
99
99
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
-
107
100
/* ----------------
108
101
* retrieve tuples from the subplan and
109
102
* insert them in the temporary relation
@@ -121,7 +114,6 @@ ExecMaterial(Material *node)
121
114
122
115
ExecClearTuple (slot );
123
116
}
124
- currentRelation = tempRelation ;
125
117
126
118
/* ----------------
127
119
* restore to user specified direction
@@ -134,6 +126,7 @@ ExecMaterial(Material *node)
134
126
* sorted relation and update the sortstate information
135
127
* ----------------
136
128
*/
129
+ currentRelation = tempRelation ;
137
130
currentScanDesc = heap_beginscan (currentRelation ,/* relation */
138
131
ScanDirectionIsBackward (dir ),
139
132
SnapshotSelf ,/* seeself */
@@ -265,15 +258,14 @@ ExecInitMaterial(Material *node, EState *estate, Plan *parent)
265
258
*create the temporary relation
266
259
* ----------------
267
260
*/
268
- /* len = ExecTargetListLength(node->plan.targetlist); */
269
261
tempDesc = ExecCreatR (tupType ,_NONAME_RELATION_ID_ );
270
262
271
263
/* ----------------
272
264
*save the relation descriptor in the sortstate
273
265
* ----------------
274
266
*/
275
267
matstate -> mat_TempRelation = tempDesc ;
276
- matstate -> csstate .css_currentRelation = tempDesc ;
268
+ matstate -> csstate .css_currentRelation = NULL ;
277
269
278
270
/* ----------------
279
271
*return relation oid of temporary relation in a list
@@ -312,12 +304,11 @@ ExecEndMaterial(Material *node)
312
304
matstate = node -> matstate ;
313
305
tempRelation = matstate -> mat_TempRelation ;
314
306
315
- heap_drop (tempRelation );
316
-
317
307
/* ----------------
318
- *close thetemp relation and shut down thescan.
308
+ *shut down thescan, but don't close thetemp relation
319
309
* ----------------
320
310
*/
311
+ matstate -> csstate .css_currentRelation = NULL ;
321
312
ExecCloseR ((Plan * )node );
322
313
323
314
/* ----------------
@@ -332,6 +323,13 @@ ExecEndMaterial(Material *node)
332
323
* ----------------
333
324
*/
334
325
ExecClearTuple (matstate -> csstate .css_ScanTupleSlot );
326
+
327
+ /* ----------------
328
+ *delete the temp relation
329
+ * ----------------
330
+ */
331
+ if (tempRelation != NULL )
332
+ heap_drop (tempRelation );
335
333
}
336
334
337
335
/* ----------------------------------------------------------------