mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-11 19:20:40 +08:00
Fix explain for union and inheritance. Rename Append structure
members to be clearer. Fix cost computation for these.
This commit is contained in:
parent
9fdbbdc877
commit
9e964f90fb
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.19 1998/04/27 16:57:09 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.20 1998/07/15 14:54:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -20,6 +20,7 @@
|
||||
#include <tcop/tcopprot.h>
|
||||
#include <lib/stringinfo.h>
|
||||
#include <commands/explain.h>
|
||||
#include <parser/parsetree.h>
|
||||
#include <parser/parse_node.h>
|
||||
#include <optimizer/planner.h>
|
||||
#include <access/xact.h>
|
||||
@ -269,6 +270,40 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
|
||||
}
|
||||
es->rtable = saved_rtable;
|
||||
}
|
||||
|
||||
if (nodeTag(plan) == T_Append)
|
||||
{
|
||||
List *saved_rtable = es->rtable;
|
||||
List *lst;
|
||||
int whichplan = 0;
|
||||
Append *appendplan = (Append *)plan;
|
||||
|
||||
foreach(lst, appendplan->appendplans)
|
||||
{
|
||||
Plan *subnode = (Plan *)lfirst(lst);
|
||||
|
||||
if (appendplan->inheritrelid > 0)
|
||||
{
|
||||
ResTarget *rtentry;
|
||||
|
||||
es->rtable = appendplan->inheritrtable;
|
||||
rtentry = nth(whichplan, appendplan->inheritrtable);
|
||||
Assert(rtentry != NULL);
|
||||
rt_store(appendplan->inheritrelid, es->rtable, rtentry);
|
||||
}
|
||||
else
|
||||
es->rtable = nth(whichplan, appendplan->unionrtables);
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
appendStringInfo(str, " ");
|
||||
appendStringInfo(str, " -> ");
|
||||
|
||||
explain_outNode(str, subnode, indent + 4, es);
|
||||
|
||||
whichplan++;
|
||||
}
|
||||
es->rtable = saved_rtable;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.18 1998/04/24 14:41:46 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.19 1998/07/15 14:54:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -712,16 +712,16 @@ NodeGetResultTupleSlot(Plan *node)
|
||||
case T_Append:
|
||||
{
|
||||
Append *n = (Append *) node;
|
||||
AppendState *unionstate;
|
||||
List *unionplans;
|
||||
AppendState *appendstate;
|
||||
List *appendplans;
|
||||
int whichplan;
|
||||
Plan *subplan;
|
||||
|
||||
unionstate = n->unionstate;
|
||||
unionplans = n->unionplans;
|
||||
whichplan = unionstate->as_whichplan;
|
||||
appendstate = n->appendstate;
|
||||
appendplans = n->appendplans;
|
||||
whichplan = appendstate->as_whichplan;
|
||||
|
||||
subplan = (Plan *) nth(whichplan, unionplans);
|
||||
subplan = (Plan *) nth(whichplan, appendplans);
|
||||
slot = NodeGetResultTupleSlot(subplan);
|
||||
break;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.12 1998/06/15 19:28:21 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.13 1998/07/15 14:54:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -79,31 +79,29 @@ static bool
|
||||
exec_append_initialize_next(Append *node)
|
||||
{
|
||||
EState *estate;
|
||||
AppendState *unionstate;
|
||||
AppendState *appendstate;
|
||||
TupleTableSlot *result_slot;
|
||||
List *rangeTable;
|
||||
|
||||
int whichplan;
|
||||
int nplans;
|
||||
List *rts;
|
||||
List *rtentries;
|
||||
List *rtables;
|
||||
List *rtable;
|
||||
ResTarget *rtentry;
|
||||
|
||||
Index unionrelid;
|
||||
|
||||
/* ----------------
|
||||
* get information from the append node
|
||||
* ----------------
|
||||
*/
|
||||
estate = node->plan.state;
|
||||
unionstate = node->unionstate;
|
||||
result_slot = unionstate->cstate.cs_ResultTupleSlot;
|
||||
appendstate = node->appendstate;
|
||||
result_slot = appendstate->cstate.cs_ResultTupleSlot;
|
||||
rangeTable = estate->es_range_table;
|
||||
|
||||
whichplan = unionstate->as_whichplan;
|
||||
nplans = unionstate->as_nplans;
|
||||
rts = node->unionrts;
|
||||
rtentries = node->unionrtentries;
|
||||
whichplan = appendstate->as_whichplan;
|
||||
nplans = appendstate->as_nplans;
|
||||
rtables = node->unionrtables;
|
||||
rtable = node->inheritrtable;
|
||||
|
||||
if (whichplan < 0)
|
||||
{
|
||||
@ -115,7 +113,7 @@ exec_append_initialize_next(Append *node)
|
||||
* at the end of the line by returning FALSE
|
||||
* ----------------
|
||||
*/
|
||||
unionstate->as_whichplan = 0;
|
||||
appendstate->as_whichplan = 0;
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
@ -126,7 +124,7 @@ exec_append_initialize_next(Append *node)
|
||||
* the last scan in our list..
|
||||
* ----------------
|
||||
*/
|
||||
unionstate->as_whichplan = nplans - 1;
|
||||
appendstate->as_whichplan = nplans - 1;
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
@ -139,29 +137,27 @@ exec_append_initialize_next(Append *node)
|
||||
* of the Append node??? - jolly )
|
||||
* ----------------
|
||||
*/
|
||||
if (node->unionrelid > 0)
|
||||
if (node->inheritrelid > 0)
|
||||
{
|
||||
rtentry = nth(whichplan, rtentries);
|
||||
rtentry = nth(whichplan, rtable);
|
||||
Assert(rtentry != NULL);
|
||||
|
||||
unionrelid = node->unionrelid;
|
||||
|
||||
rt_store(unionrelid, rangeTable, rtentry);
|
||||
rt_store(node->inheritrelid, rangeTable, rtentry);
|
||||
}
|
||||
else
|
||||
estate->es_range_table = nth(whichplan, rts);
|
||||
estate->es_range_table = nth(whichplan, rtables);
|
||||
|
||||
if (unionstate->as_junkFilter_list)
|
||||
if (appendstate->as_junkFilter_list)
|
||||
{
|
||||
estate->es_junkFilter =
|
||||
(JunkFilter *) nth(whichplan,
|
||||
unionstate->as_junkFilter_list);
|
||||
appendstate->as_junkFilter_list);
|
||||
}
|
||||
if (unionstate->as_result_relation_info_list)
|
||||
if (appendstate->as_result_relation_info_list)
|
||||
{
|
||||
estate->es_result_relation_info =
|
||||
(RelationInfo *) nth(whichplan,
|
||||
unionstate->as_result_relation_info_list);
|
||||
appendstate->as_result_relation_info_list);
|
||||
}
|
||||
result_slot->ttc_whichplan = whichplan;
|
||||
|
||||
@ -187,11 +183,11 @@ exec_append_initialize_next(Append *node)
|
||||
bool
|
||||
ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
{
|
||||
AppendState *unionstate;
|
||||
AppendState *appendstate;
|
||||
int nplans;
|
||||
List *resultList = NULL;
|
||||
List *rtentries;
|
||||
List *unionplans;
|
||||
List *rtable;
|
||||
List *appendplans;
|
||||
bool *initialized;
|
||||
int i;
|
||||
Plan *initNode;
|
||||
@ -205,9 +201,9 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
*/
|
||||
node->plan.state = estate;
|
||||
|
||||
unionplans = node->unionplans;
|
||||
nplans = length(unionplans);
|
||||
rtentries = node->unionrtentries;
|
||||
appendplans = node->appendplans;
|
||||
nplans = length(appendplans);
|
||||
rtable = node->inheritrtable;
|
||||
|
||||
CXT1_printf("ExecInitAppend: context is %d\n", CurrentMemoryContext);
|
||||
initialized = (bool *) palloc(nplans * sizeof(bool));
|
||||
@ -216,13 +212,13 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
* create new AppendState for our append node
|
||||
* ----------------
|
||||
*/
|
||||
unionstate = makeNode(AppendState);
|
||||
unionstate->as_whichplan = 0;
|
||||
unionstate->as_nplans = nplans;
|
||||
unionstate->as_initialized = initialized;
|
||||
unionstate->as_rtentries = rtentries;
|
||||
appendstate = makeNode(AppendState);
|
||||
appendstate->as_whichplan = 0;
|
||||
appendstate->as_nplans = nplans;
|
||||
appendstate->as_initialized = initialized;
|
||||
appendstate->as_rtentries = rtable;
|
||||
|
||||
node->unionstate = unionstate;
|
||||
node->appendstate = appendstate;
|
||||
|
||||
/* ----------------
|
||||
* Miscellanious initialization
|
||||
@ -234,7 +230,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
* never call ExecQual or ExecTargetList.
|
||||
* ----------------
|
||||
*/
|
||||
ExecAssignNodeBaseInfo(estate, &unionstate->cstate, parent);
|
||||
ExecAssignNodeBaseInfo(estate, &appendstate->cstate, parent);
|
||||
|
||||
#define APPEND_NSLOTS 1
|
||||
/* ----------------
|
||||
@ -242,7 +238,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
* to tuples, so we have to initialize them..
|
||||
* ----------------
|
||||
*/
|
||||
ExecInitResultTupleSlot(estate, &unionstate->cstate);
|
||||
ExecInitResultTupleSlot(estate, &appendstate->cstate);
|
||||
|
||||
/*
|
||||
* If the inherits rtentry is the result relation, we have to make a
|
||||
@ -252,12 +248,12 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
* e.g. replace p (age = p.age + 1) from p in person*
|
||||
*/
|
||||
if ((es_rri != (RelationInfo *) NULL) &&
|
||||
(node->unionrelid == es_rri->ri_RangeTableIndex))
|
||||
(node->inheritrelid == es_rri->ri_RangeTableIndex))
|
||||
{
|
||||
RelationInfo *rri;
|
||||
List *rtentryP;
|
||||
|
||||
foreach(rtentryP, rtentries)
|
||||
foreach(rtentryP, rtable)
|
||||
{
|
||||
Oid reloid;
|
||||
RangeTblEntry *rtentry = lfirst(rtentryP);
|
||||
@ -273,7 +269,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
resultList = lcons(rri, resultList);
|
||||
ExecOpenIndices(reloid, rri);
|
||||
}
|
||||
unionstate->as_result_relation_info_list = resultList;
|
||||
appendstate->as_result_relation_info_list = resultList;
|
||||
}
|
||||
/* ----------------
|
||||
* call ExecInitNode on each of the plans in our list
|
||||
@ -294,10 +290,10 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
* since it may use the range table.
|
||||
* ----------------
|
||||
*/
|
||||
unionstate->as_whichplan = i;
|
||||
appendstate->as_whichplan = i;
|
||||
exec_append_initialize_next(node);
|
||||
|
||||
initNode = (Plan *) nth(i, unionplans);
|
||||
initNode = (Plan *) nth(i, appendplans);
|
||||
initialized[i] = ExecInitNode(initNode, estate, (Plan *) node);
|
||||
|
||||
/* ---------------
|
||||
@ -308,7 +304,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
* ---------------
|
||||
*/
|
||||
if ((es_rri != (RelationInfo *) NULL) &&
|
||||
(node->unionrelid == es_rri->ri_RangeTableIndex))
|
||||
(node->inheritrelid == es_rri->ri_RangeTableIndex))
|
||||
{
|
||||
|
||||
targetList = initNode->targetlist;
|
||||
@ -317,7 +313,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
}
|
||||
|
||||
}
|
||||
unionstate->as_junkFilter_list = junkList;
|
||||
appendstate->as_junkFilter_list = junkList;
|
||||
if (junkList != NIL)
|
||||
estate->es_junkFilter = (JunkFilter *) lfirst(junkList);
|
||||
|
||||
@ -325,17 +321,17 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
* initialize the return type from the appropriate subplan.
|
||||
* ----------------
|
||||
*/
|
||||
initNode = (Plan *) nth(0, unionplans);
|
||||
ExecAssignResultType(&unionstate->cstate,
|
||||
initNode = (Plan *) nth(0, appendplans);
|
||||
ExecAssignResultType(&appendstate->cstate,
|
||||
/* ExecGetExecTupDesc(initNode), */
|
||||
ExecGetTupType(initNode));
|
||||
unionstate->cstate.cs_ProjInfo = NULL;
|
||||
appendstate->cstate.cs_ProjInfo = NULL;
|
||||
|
||||
/* ----------------
|
||||
* return the result from the first subplan's initialization
|
||||
* ----------------
|
||||
*/
|
||||
unionstate->as_whichplan = 0;
|
||||
appendstate->as_whichplan = 0;
|
||||
exec_append_initialize_next(node);
|
||||
#if 0
|
||||
result = (List *) initialized[0];
|
||||
@ -347,10 +343,10 @@ int
|
||||
ExecCountSlotsAppend(Append *node)
|
||||
{
|
||||
List *plan;
|
||||
List *unionplans = node->unionplans;
|
||||
List *appendplans = node->appendplans;
|
||||
int nSlots = 0;
|
||||
|
||||
foreach(plan, unionplans)
|
||||
foreach(plan, appendplans)
|
||||
nSlots += ExecCountSlotsNode((Plan *) lfirst(plan));
|
||||
return nSlots + APPEND_NSLOTS;
|
||||
}
|
||||
@ -367,10 +363,10 @@ TupleTableSlot *
|
||||
ExecProcAppend(Append *node)
|
||||
{
|
||||
EState *estate;
|
||||
AppendState *unionstate;
|
||||
AppendState *appendstate;
|
||||
|
||||
int whichplan;
|
||||
List *unionplans;
|
||||
List *appendplans;
|
||||
Plan *subnode;
|
||||
TupleTableSlot *result;
|
||||
TupleTableSlot *result_slot;
|
||||
@ -380,19 +376,19 @@ ExecProcAppend(Append *node)
|
||||
* get information from the node
|
||||
* ----------------
|
||||
*/
|
||||
unionstate = node->unionstate;
|
||||
appendstate = node->appendstate;
|
||||
estate = node->plan.state;
|
||||
direction = estate->es_direction;
|
||||
|
||||
unionplans = node->unionplans;
|
||||
whichplan = unionstate->as_whichplan;
|
||||
result_slot = unionstate->cstate.cs_ResultTupleSlot;
|
||||
appendplans = node->appendplans;
|
||||
whichplan = appendstate->as_whichplan;
|
||||
result_slot = appendstate->cstate.cs_ResultTupleSlot;
|
||||
|
||||
/* ----------------
|
||||
* figure out which subplan we are currently processing
|
||||
* ----------------
|
||||
*/
|
||||
subnode = (Plan *) nth(whichplan, unionplans);
|
||||
subnode = (Plan *) nth(whichplan, appendplans);
|
||||
|
||||
if (subnode == NULL)
|
||||
elog(DEBUG, "ExecProcAppend: subnode is NULL");
|
||||
@ -421,12 +417,12 @@ ExecProcAppend(Append *node)
|
||||
* direction and try processing again (recursively)
|
||||
* ----------------
|
||||
*/
|
||||
whichplan = unionstate->as_whichplan;
|
||||
whichplan = appendstate->as_whichplan;
|
||||
|
||||
if (ScanDirectionIsForward(direction))
|
||||
unionstate->as_whichplan = whichplan + 1;
|
||||
appendstate->as_whichplan = whichplan + 1;
|
||||
else
|
||||
unionstate->as_whichplan = whichplan - 1;
|
||||
appendstate->as_whichplan = whichplan - 1;
|
||||
|
||||
/* ----------------
|
||||
* return something from next node or an empty slot
|
||||
@ -454,9 +450,9 @@ ExecProcAppend(Append *node)
|
||||
void
|
||||
ExecEndAppend(Append *node)
|
||||
{
|
||||
AppendState *unionstate;
|
||||
AppendState *appendstate;
|
||||
int nplans;
|
||||
List *unionplans;
|
||||
List *appendplans;
|
||||
bool *initialized;
|
||||
int i;
|
||||
List *resultRelationInfoList;
|
||||
@ -466,10 +462,10 @@ ExecEndAppend(Append *node)
|
||||
* get information from the node
|
||||
* ----------------
|
||||
*/
|
||||
unionstate = node->unionstate;
|
||||
unionplans = node->unionplans;
|
||||
nplans = unionstate->as_nplans;
|
||||
initialized = unionstate->as_initialized;
|
||||
appendstate = node->appendstate;
|
||||
appendplans = node->appendplans;
|
||||
nplans = appendstate->as_nplans;
|
||||
initialized = appendstate->as_initialized;
|
||||
|
||||
/* ----------------
|
||||
* shut down each of the subscans
|
||||
@ -478,14 +474,14 @@ ExecEndAppend(Append *node)
|
||||
for (i = 0; i < nplans; i++)
|
||||
{
|
||||
if (initialized[i] == TRUE)
|
||||
ExecEndNode((Plan *) nth(i, unionplans), (Plan *) node);
|
||||
ExecEndNode((Plan *) nth(i, appendplans), (Plan *) node);
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* close out the different result relations
|
||||
* ----------------
|
||||
*/
|
||||
resultRelationInfoList = unionstate->as_result_relation_info_list;
|
||||
resultRelationInfoList = appendstate->as_result_relation_info_list;
|
||||
while (resultRelationInfoList != NIL)
|
||||
{
|
||||
Relation resultRelationDesc;
|
||||
@ -496,11 +492,11 @@ ExecEndAppend(Append *node)
|
||||
pfree(resultRelationInfo);
|
||||
resultRelationInfoList = lnext(resultRelationInfoList);
|
||||
}
|
||||
if (unionstate->as_result_relation_info_list)
|
||||
pfree(unionstate->as_result_relation_info_list);
|
||||
if (appendstate->as_result_relation_info_list)
|
||||
pfree(appendstate->as_result_relation_info_list);
|
||||
|
||||
/*
|
||||
* XXX should free unionstate->as_rtentries and
|
||||
* unionstate->as_junkfilter_list here
|
||||
* XXX should free appendstate->as_rtentries and
|
||||
* appendstate->as_junkfilter_list here
|
||||
*/
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.42 1998/06/15 19:28:30 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.43 1998/07/15 14:54:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -162,11 +162,11 @@ _copyAppend(Append *from)
|
||||
* copy remainder of node
|
||||
* ----------------
|
||||
*/
|
||||
Node_Copy(from, newnode, unionplans);
|
||||
Node_Copy(from, newnode, unionrts);
|
||||
newnode->unionrelid = from->unionrelid;
|
||||
Node_Copy(from, newnode, unionrtentries);
|
||||
Node_Copy(from, newnode, unionstate);
|
||||
Node_Copy(from, newnode, appendplans);
|
||||
Node_Copy(from, newnode, unionrtables);
|
||||
newnode->inheritrelid = from->inheritrelid;
|
||||
Node_Copy(from, newnode, inheritrtable);
|
||||
Node_Copy(from, newnode, appendstate);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.39 1998/07/14 01:45:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.40 1998/07/15 14:54:32 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||
@ -354,17 +354,17 @@ _outAppend(StringInfo str, Append *node)
|
||||
appendStringInfo(str, " APPEND ");
|
||||
_outPlanInfo(str, (Plan *) node);
|
||||
|
||||
appendStringInfo(str, " :unionplans ");
|
||||
_outNode(str, node->unionplans);
|
||||
appendStringInfo(str, " :appendplans ");
|
||||
_outNode(str, node->appendplans);
|
||||
|
||||
appendStringInfo(str, " :unionrts ");
|
||||
_outNode(str, node->unionrts);
|
||||
appendStringInfo(str, " :unionrtables ");
|
||||
_outNode(str, node->unionrtables);
|
||||
|
||||
sprintf(buf, " :unionrelid %d ", node->unionrelid);
|
||||
sprintf(buf, " :inheritrelid %d ", node->inheritrelid);
|
||||
appendStringInfo(str, buf);
|
||||
|
||||
appendStringInfo(str, " :unionrtentries ");
|
||||
_outNode(str, node->unionrtentries);
|
||||
appendStringInfo(str, " :inheritrtable ");
|
||||
_outNode(str, node->inheritrtable);
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.15 1998/06/15 19:28:32 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.16 1998/07/15 14:54:33 momjian Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -387,6 +387,23 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
|
||||
printf("\n");
|
||||
print_plan_recursive(p->lefttree, parsetree, indentLevel + 3, "l: ");
|
||||
print_plan_recursive(p->righttree, parsetree, indentLevel + 3, "r: ");
|
||||
|
||||
if (nodeTag(p) == T_Append)
|
||||
{
|
||||
List *lst;
|
||||
int whichplan = 0;
|
||||
Append *appendplan = (Append *)p;
|
||||
|
||||
foreach(lst, appendplan->appendplans)
|
||||
{
|
||||
Plan *subnode = (Plan *)lfirst(lst);
|
||||
|
||||
/* I don't think we need to fiddle with the range table here, bjm */
|
||||
print_plan_recursive(subnode, parsetree, indentLevel + 3, "a: ");
|
||||
|
||||
whichplan++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* print_plan
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.31 1998/07/14 01:45:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.32 1998/07/15 14:54:34 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Most of the read functions for plan nodes are tested. (In fact, they
|
||||
@ -322,18 +322,18 @@ _readAppend()
|
||||
|
||||
_getPlan((Plan *) local_node);
|
||||
|
||||
token = lsptok(NULL, &length); /* eat :unionplans */
|
||||
local_node->unionplans = nodeRead(true); /* now read it */
|
||||
token = lsptok(NULL, &length); /* eat :appendplans */
|
||||
local_node->appendplans = nodeRead(true); /* now read it */
|
||||
|
||||
token = lsptok(NULL, &length); /* eat :unionrts */
|
||||
local_node->unionrts = nodeRead(true); /* now read it */
|
||||
token = lsptok(NULL, &length); /* eat :unionrtables */
|
||||
local_node->unionrtables = nodeRead(true); /* now read it */
|
||||
|
||||
token = lsptok(NULL, &length); /* eat :unionrelid */
|
||||
token = lsptok(NULL, &length); /* get unionrelid */
|
||||
local_node->unionrelid = strtoul(token, NULL, 10);
|
||||
token = lsptok(NULL, &length); /* eat :inheritrelid */
|
||||
token = lsptok(NULL, &length); /* get inheritrelid */
|
||||
local_node->inheritrelid = strtoul(token, NULL, 10);
|
||||
|
||||
token = lsptok(NULL, &length); /* eat :unionrtentries */
|
||||
local_node->unionrtentries = nodeRead(true); /* now read it */
|
||||
token = lsptok(NULL, &length); /* eat :inheritrtable */
|
||||
local_node->inheritrtable = nodeRead(true); /* now read it */
|
||||
|
||||
return (local_node);
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ SS_finalize_plan(Plan *plan)
|
||||
break;
|
||||
|
||||
case T_Append:
|
||||
foreach(lst, ((Append *) plan)->unionplans)
|
||||
foreach(lst, ((Append *) plan)->appendplans)
|
||||
param_list = set_unioni(param_list,
|
||||
SS_finalize_plan((Plan *) lfirst(lst)));
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.24 1998/06/15 19:28:46 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.25 1998/07/15 14:54:37 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -48,8 +48,8 @@ static void
|
||||
fix_parsetree_attnums(Index rt_index, Oid old_relid,
|
||||
Oid new_relid, Query *parsetree);
|
||||
static Append *
|
||||
make_append(List *unionplans, List *unionrts, Index rt_index,
|
||||
List *union_rt_entries, List *tlist);
|
||||
make_append(List *appendplans, List *unionrtables, Index rt_index,
|
||||
List *inheritrtable, List *tlist);
|
||||
|
||||
|
||||
/*
|
||||
@ -224,7 +224,7 @@ plan_inherit_queries(Query *parse, Index rt_index)
|
||||
|
||||
List *rangetable = parse->rtable;
|
||||
RangeTblEntry *rt_entry = rt_fetch(rt_index, rangetable);
|
||||
List *union_rt_entries = NIL;
|
||||
List *inheritrtable = NIL;
|
||||
List *union_relids = NIL;
|
||||
|
||||
union_relids =
|
||||
@ -239,12 +239,12 @@ plan_inherit_queries(Query *parse, Index rt_index)
|
||||
rt_fetch(rt_index, rangetable)->inh = false;
|
||||
|
||||
union_plans = plan_inherit_query(union_relids, rt_index, rt_entry,
|
||||
parse, &union_rt_entries);
|
||||
parse, &inheritrtable);
|
||||
|
||||
return (make_append(union_plans,
|
||||
NULL,
|
||||
rt_index,
|
||||
union_rt_entries,
|
||||
inheritrtable,
|
||||
((Plan *) lfirst(union_plans))->targetlist));
|
||||
}
|
||||
|
||||
@ -494,19 +494,22 @@ fix_parsetree_attnums(Index rt_index,
|
||||
}
|
||||
|
||||
static Append *
|
||||
make_append(List *unionplans,
|
||||
List *unionrts,
|
||||
make_append(List *appendplans,
|
||||
List *unionrtables,
|
||||
Index rt_index,
|
||||
List *union_rt_entries,
|
||||
List *inheritrtable,
|
||||
List *tlist)
|
||||
{
|
||||
Append *node = makeNode(Append);
|
||||
|
||||
node->unionplans = unionplans;
|
||||
node->unionrts = unionrts;
|
||||
node->unionrelid = rt_index;
|
||||
node->unionrtentries = union_rt_entries;
|
||||
List *subnode;
|
||||
|
||||
node->appendplans = appendplans;
|
||||
node->unionrtables = unionrtables;
|
||||
node->inheritrelid = rt_index;
|
||||
node->inheritrtable = inheritrtable;
|
||||
node->plan.cost = 0.0;
|
||||
foreach(subnode, appendplans)
|
||||
node->plan.cost += ((Plan *)lfirst(subnode))->cost;
|
||||
node->plan.state = (EState *) NULL;
|
||||
node->plan.targetlist = tlist;
|
||||
node->plan.qual = NIL;
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: plannodes.h,v 1.15 1998/02/26 04:42:01 momjian Exp $
|
||||
* $Id: plannodes.h,v 1.16 1998/07/15 14:54:39 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,7 +24,7 @@
|
||||
* control nodes
|
||||
*
|
||||
* Result ResultState resstate;
|
||||
* Append AppendState unionstate;
|
||||
* Append AppendState appendstate;
|
||||
*
|
||||
* scan nodes
|
||||
*
|
||||
@ -138,11 +138,17 @@ typedef struct Result
|
||||
typedef struct Append
|
||||
{
|
||||
Plan plan;
|
||||
List *unionplans;
|
||||
List *unionrts;
|
||||
Index unionrelid;
|
||||
List *unionrtentries;
|
||||
AppendState *unionstate;
|
||||
List *appendplans;
|
||||
List *unionrtables; /*
|
||||
* List of range tables, one for each
|
||||
* union query.
|
||||
*/
|
||||
Index inheritrelid; /*
|
||||
* The range table has to be changed for
|
||||
* inheritance.
|
||||
*/
|
||||
List *inheritrtable;
|
||||
AppendState *appendstate;
|
||||
} Append;
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user