Skip to content

Commit c1f1a2e

Browse files
committed
Allow UNION/UNION ALL in subselects.
1 parent 2077ce1 commit c1f1a2e

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

src/backend/executor/execAmi.c

Lines changed: 5 additions & 1 deletion
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.21 1998/06/15 19:28:18 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.22 1998/07/15 22:16:17 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -369,6 +369,10 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
369369
ExecReScanMergeJoin((MergeJoin *) node, exprCtxt, parent);
370370
break;
371371

372+
case T_Append:
373+
ExecReScanAppend((Append *) node, exprCtxt, parent);
374+
break;
375+
372376
/*
373377
* Tee is never used
374378
case T_Tee:

src/backend/executor/nodeAppend.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.13 1998/07/15 14:54:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.14 1998/07/15 22:16:18 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
/* INTERFACE ROUTINES
1515
* ExecInitAppend - initialize the append node
1616
* ExecProcAppend - retrieve the next tuple from the node
1717
* ExecEndAppend - shut down the append node
18+
* ExecReScanAppend - rescan the append node
1819
*
1920
* NOTES
2021
* Each append node contains a list of one or more subplans which
@@ -34,7 +35,7 @@
3435
* nil nil ... ... ...
3536
* subplans
3637
*
37-
* Append nodes are currently used to unions, and to support inheritance
38+
* Append nodes are currently used for unions, and to support inheritance
3839
* queries, where several relations need to be scanned.
3940
* For example, in our standard person/student/employee/student-emp
4041
* example, where student and employee inherit from person
@@ -500,3 +501,25 @@ ExecEndAppend(Append *node)
500501
* appendstate->as_junkfilter_list here
501502
*/
502503
}
504+
void
505+
ExecReScanAppend(Append *node, ExprContext *exprCtxt, Plan *parent)
506+
{
507+
AppendState *appendstate = node->appendstate;
508+
int nplans = length(node->appendplans);
509+
int i;
510+
511+
for (i = 0; i < nplans; i++)
512+
{
513+
Plan *rescanNode;
514+
515+
appendstate->as_whichplan = i;
516+
rescanNode = (Plan *) nth(i, node->appendplans);
517+
if (rescanNode->chgParam == NULL)
518+
{
519+
exec_append_initialize_next(node);
520+
ExecReScan((Plan *)rescanNode, exprCtxt, (Plan *) node);
521+
}
522+
}
523+
appendstate->as_whichplan = 0;
524+
exec_append_initialize_next(node);
525+
}

src/backend/parser/gram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
*
219219
*
220220
* IDENTIFICATION
221-
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.15 1998/07/15 15:56:34 momjian Exp $
221+
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.16 1998/07/15 22:16:18 momjian Exp $
222222
*
223223
* HISTORY
224224
* AUTHOR DATE MAJOR EVENT

src/include/executor/nodeAppend.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nodeAppend.h,v 1.7 1997/11/26 01:12:44 momjian Exp $
9+
* $Id: nodeAppend.h,v 1.8 1998/07/15 22:16:21 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -21,5 +21,6 @@ extern bool ExecInitAppend(Append *node, EState *estate, Plan *parent);
2121
extern int ExecCountSlotsAppend(Append *node);
2222
extern TupleTableSlot *ExecProcAppend(Append *node);
2323
extern void ExecEndAppend(Append *node);
24+
extern void ExecReScanAppend(Append *node, ExprContext *exprCtxt, Plan *parent);
2425

2526
#endif /* NODEAPPEND_H */

0 commit comments

Comments
 (0)