Skip to content

Commit 1a105ce

Browse files
committed
Support for subselects.
ExecReScan for nodeAgg, nodeHash, nodeHashjoin, nodeNestloop and nodeResult. Fixed ExecReScan for nodeMaterial. Get rid of #ifdef INDEXSCAN_PATCH. Get rid of ExecMarkPos and ExecRestrPos in nodeNestloop.
1 parent 13637df commit 1a105ce

15 files changed

+677
-153
lines changed

src/backend/executor/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for executor
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/executor/Makefile,v 1.5 1997/12/20 00:23:37 scrappy Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/executor/Makefile,v 1.6 1998/02/13 03:26:35 vadim Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -20,7 +20,7 @@ OBJS = execAmi.o execFlatten.o execJunk.o execMain.o \
2020
execUtils.o functions.o nodeAppend.o nodeAgg.o nodeHash.o \
2121
nodeHashjoin.o nodeIndexscan.o nodeMaterial.o nodeMergejoin.o \
2222
nodeNestloop.o nodeResult.o nodeSeqscan.o nodeSort.o \
23-
nodeUnique.o nodeTee.o nodeGroup.o spi.o
23+
nodeUnique.o nodeTee.o nodeGroup.o spi.o nodeSubplan.o
2424

2525
all: SUBSYS.o
2626

src/backend/executor/execAmi.c

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.16 1998/01/16 23:19:47 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.17 1998/02/13 03:26:36 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -37,6 +37,13 @@
3737
#include "executor/nodeIndexscan.h"
3838
#include "executor/nodeSort.h"
3939
#include "executor/nodeTee.h"
40+
#include "executor/nodeMaterial.h"
41+
#include "executor/nodeNestloop.h"
42+
#include "executor/nodeHashjoin.h"
43+
#include "executor/nodeHash.h"
44+
#include "executor/nodeAgg.h"
45+
#include "executor/nodeResult.h"
46+
#include "executor/nodeSubplan.h"
4047
#include "executor/execdebug.h"
4148
#include "optimizer/internal.h" /* for _TEMP_RELATION_ID_ */
4249
#include "access/genam.h"
@@ -287,35 +294,82 @@ ExecCloseR(Plan *node)
287294
void
288295
ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
289296
{
297+
298+
if ( node->chgParam != NULL ) /* Wow! */
299+
{
300+
List *lst;
301+
302+
foreach (lst, node->initPlan)
303+
{
304+
Plan *splan = ((SubPlan*) lfirst (lst))->plan;
305+
if ( splan->extParam != NULL ) /* don't care about child locParam */
306+
SetChangedParamList (splan, node->chgParam);
307+
if ( splan->chgParam != NULL )
308+
ExecReScanSetParamPlan ((SubPlan*) lfirst (lst), node);
309+
}
310+
foreach (lst, node->subPlan)
311+
{
312+
Plan *splan = ((SubPlan*) lfirst (lst))->plan;
313+
if ( splan->extParam != NULL )
314+
SetChangedParamList (splan, node->chgParam);
315+
}
316+
/* Well. Now set chgParam for left/right trees. */
317+
if ( node->lefttree != NULL )
318+
SetChangedParamList (node->lefttree, node->chgParam);
319+
if ( node->righttree != NULL )
320+
SetChangedParamList (node->righttree, node->chgParam);
321+
}
322+
290323
switch (nodeTag(node))
291324
{
292-
case T_SeqScan:
325+
case T_SeqScan:
293326
ExecSeqReScan((SeqScan *) node, exprCtxt, parent);
294-
return;
327+
break;
295328

296329
case T_IndexScan:
297330
ExecIndexReScan((IndexScan *) node, exprCtxt, parent);
298-
return;
331+
break;
299332

300333
case T_Material:
334+
ExecMaterialReScan((Material*) node, exprCtxt, parent);
335+
break;
301336

302-
/*
303-
* the first call to ExecReScan should have no effect because
304-
* everything is initialized properly already. the following
305-
* calls will be handled by ExecSeqReScan() because the nodes
306-
* below the Material node have already been materialized into
307-
* a temp relation.
308-
*/
309-
return;
337+
case T_NestLoop:
338+
ExecReScanNestLoop((NestLoop*) node, exprCtxt, parent);
339+
break;
340+
341+
case T_HashJoin:
342+
ExecReScanHashJoin((HashJoin*) node, exprCtxt, parent);
343+
break;
344+
345+
case T_Hash:
346+
ExecReScanHash((Hash*) node, exprCtxt, parent);
347+
break;
348+
349+
case T_Agg:
350+
ExecReScanAgg((Agg*) node, exprCtxt, parent);
351+
break;
310352

353+
case T_Result:
354+
ExecReScanResult((Result*) node, exprCtxt, parent);
355+
break;
356+
357+
/*
358+
* Tee is never used
311359
case T_Tee:
312360
ExecTeeReScan((Tee *) node, exprCtxt, parent);
313361
break;
314-
362+
*/
315363
default:
316-
elog(ERROR, "ExecReScan: not a seqscan or indexscan node.");
364+
elog(ERROR, "ExecReScan: node type %u not supported", nodeTag(node));
317365
return;
318366
}
367+
368+
if ( node->chgParam != NULL )
369+
{
370+
freeList (node->chgParam);
371+
node->chgParam = NULL;
372+
}
319373
}
320374

321375
/* ----------------------------------------------------------------
@@ -352,7 +406,7 @@ ExecMarkPos(Plan *node)
352406
{
353407
switch (nodeTag(node))
354408
{
355-
case T_SeqScan:
409+
case T_SeqScan:
356410
ExecSeqMarkPos((SeqScan *) node);
357411
break;
358412

@@ -365,7 +419,7 @@ ExecMarkPos(Plan *node)
365419
break;
366420

367421
default:
368-
/* elog(DEBUG, "ExecMarkPos: unsupported node type"); */
422+
elog(DEBUG, "ExecMarkPos: node type %u not supported", nodeTag(node));
369423
break;
370424
}
371425
return;
@@ -382,7 +436,7 @@ ExecRestrPos(Plan *node)
382436
{
383437
switch (nodeTag(node))
384438
{
385-
case T_SeqScan:
439+
case T_SeqScan:
386440
ExecSeqRestrPos((SeqScan *) node);
387441
return;
388442

@@ -395,7 +449,7 @@ ExecRestrPos(Plan *node)
395449
return;
396450

397451
default:
398-
/* elog(DEBUG, "ExecRestrPos: node type not supported"); */
452+
elog(DEBUG, "ExecRestrPos: node type %u not supported", nodeTag(node));
399453
return;
400454
}
401455
}

src/backend/executor/execMain.c

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.41 1998/02/10 04:00:45 momjian Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.42 1998/02/13 03:26:38 vadim Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -110,7 +110,14 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
110110

111111
/* sanity checks */
112112
Assert(queryDesc != NULL);
113-
113+
114+
if (queryDesc->plantree->nParamExec > 0)
115+
{
116+
estate->es_param_exec_vals = (ParamExecData*)
117+
palloc (queryDesc->plantree->nParamExec * sizeof (ParamExecData));
118+
memset (estate->es_param_exec_vals, 0 , queryDesc->plantree->nParamExec * sizeof (ParamExecData));
119+
}
120+
114121
result = InitPlan(queryDesc->operation,
115122
queryDesc->parsetree,
116123
queryDesc->plantree,
@@ -177,31 +184,6 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count)
177184
estate->es_processed = 0;
178185
estate->es_lastoid = InvalidOid;
179186

180-
#if 0
181-
182-
/*
183-
* It doesn't work in common case (i.g. if function has a aggregate).
184-
* Now we store parameter values before ExecutorStart. - vadim
185-
* 01/22/97
186-
*/
187-
#ifdef INDEXSCAN_PATCH
188-
189-
/*
190-
* If the plan is an index scan and some of the scan key are function
191-
* arguments rescan the indices after the parameter values have been
192-
* stored in the execution state. DZ - 27-8-1996
193-
*/
194-
if ((nodeTag(plan) == T_IndexScan) &&
195-
(((IndexScan *) plan)->indxstate->iss_RuntimeKeyInfo != NULL))
196-
{
197-
ExprContext *econtext;
198-
199-
econtext = ((IndexScan *) plan)->scan.scanstate->cstate.cs_ExprContext;
200-
ExecIndexReScan((IndexScan *) plan, econtext, plan);
201-
}
202-
#endif
203-
#endif
204-
205187
switch (feature)
206188
{
207189

@@ -1246,7 +1228,8 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
12461228
econtext->ecxt_outertuple = NULL; /* outer tuple slot */
12471229
econtext->ecxt_relation = NULL; /* relation */
12481230
econtext->ecxt_relid = 0; /* relid */
1249-
econtext->ecxt_param_list_info = NULL; /* param list info */
1231+
econtext->ecxt_param_list_info = NULL; /* param list info */
1232+
econtext->ecxt_param_exec_vals = NULL; /* exec param values */
12501233
econtext->ecxt_range_table = NULL; /* range table */
12511234
for (i = 0; i < ndef; i++)
12521235
{
@@ -1322,6 +1305,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
13221305
econtext->ecxt_relation = rel; /* relation */
13231306
econtext->ecxt_relid = 0; /* relid */
13241307
econtext->ecxt_param_list_info = NULL; /* param list info */
1308+
econtext->ecxt_param_exec_vals = NULL; /* exec param values */
13251309
econtext->ecxt_range_table = rtlist; /* range table */
13261310

13271311
for (i = 0; i < ncheck; i++)

src/backend/executor/execProcnode.c

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.7 1998/01/07 21:02:44 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.8 1998/02/13 03:26:40 vadim Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -89,6 +89,7 @@
8989
#include "executor/nodeHash.h"
9090
#include "executor/nodeHashjoin.h"
9191
#include "executor/nodeTee.h"
92+
#include "executor/nodeSubplan.h"
9293

9394
/* ------------------------------------------------------------------------
9495
* ExecInitNode
@@ -106,6 +107,7 @@ bool
106107
ExecInitNode(Plan *node, EState *estate, Plan *parent)
107108
{
108109
bool result;
110+
List *subp;
109111

110112
/* ----------------
111113
* do nothing when we get to the end
@@ -114,7 +116,14 @@ ExecInitNode(Plan *node, EState *estate, Plan *parent)
114116
*/
115117
if (node == NULL)
116118
return FALSE;
117-
119+
120+
foreach (subp, node->initPlan)
121+
{
122+
result = ExecInitSubPlan ((SubPlan*) lfirst (subp), estate, node);
123+
if ( result == FALSE )
124+
return (FALSE);
125+
}
126+
118127
switch (nodeTag(node))
119128
{
120129
/* ----------------
@@ -190,10 +199,19 @@ ExecInitNode(Plan *node, EState *estate, Plan *parent)
190199
break;
191200

192201
default:
193-
elog(DEBUG, "ExecInitNode: node not yet supported: %d",
194-
nodeTag(node));
202+
elog(ERROR, "ExecInitNode: node %d unsupported", nodeTag(node));
195203
result = FALSE;
196204
}
205+
206+
if ( result != FALSE )
207+
{
208+
foreach (subp, node->subPlan)
209+
{
210+
result = ExecInitSubPlan ((SubPlan*) lfirst (subp), estate, node);
211+
if ( result == FALSE )
212+
return (FALSE);
213+
}
214+
}
197215

198216
return result;
199217
}
@@ -217,7 +235,10 @@ ExecProcNode(Plan *node, Plan *parent)
217235
*/
218236
if (node == NULL)
219237
return NULL;
220-
238+
239+
if ( node->chgParam != NULL ) /* something changed */
240+
ExecReScan (node, NULL, parent); /* let ReScan handle this */
241+
221242
switch (nodeTag(node))
222243
{
223244
/* ----------------
@@ -293,9 +314,8 @@ ExecProcNode(Plan *node, Plan *parent)
293314
break;
294315

295316
default:
296-
elog(DEBUG, "ExecProcNode: node not yet supported: %d",
297-
nodeTag(node));
298-
result = FALSE;
317+
elog(ERROR, "ExecProcNode: node %d unsupported", nodeTag(node));
318+
result = NULL;
299319
}
300320

301321
return result;
@@ -389,13 +409,29 @@ ExecCountSlotsNode(Plan *node)
389409
void
390410
ExecEndNode(Plan *node, Plan *parent)
391411
{
412+
List *subp;
413+
392414
/* ----------------
393415
* do nothing when we get to the end
394416
* of a leaf on tree.
395417
* ----------------
396418
*/
397419
if (node == NULL)
398420
return;
421+
422+
foreach (subp, node->initPlan)
423+
{
424+
ExecEndSubPlan ((SubPlan*) lfirst (subp));
425+
}
426+
foreach (subp, node->subPlan)
427+
{
428+
ExecEndSubPlan ((SubPlan*) lfirst (subp));
429+
}
430+
if ( node->chgParam != NULL )
431+
{
432+
freeList (node->chgParam);
433+
node->chgParam = NULL;
434+
}
399435

400436
switch (nodeTag(node))
401437
{
@@ -476,8 +512,7 @@ ExecEndNode(Plan *node, Plan *parent)
476512
break;
477513

478514
default:
479-
elog(DEBUG, "ExecEndNode: node not yet supported",
480-
nodeTag(node));
515+
elog(ERROR, "ExecEndNode: node %d unsupported", nodeTag(node));
481516
break;
482517
}
483518
}

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