mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Remove the Query structure from the executor's API. This allows us to stop
storing mostly-redundant Query trees in prepared statements, portals, etc. To replace Query, a new node type called PlannedStmt is inserted by the planner at the top of a completed plan tree; this carries just the fields of Query that are still needed at runtime. The statement lists kept in portals etc. now consist of intermixed PlannedStmt and bare utility-statement nodes --- no Query. This incidentally allows us to remove some fields from Query and Plan nodes that shouldn't have been there in the first place. Still to do: simplify the execution-time range table; at the moment the range table passed to the executor still contains Query trees for subqueries. initdb forced due to change of stored rules.
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.366 2007/02/19 02:23:11 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.367 2007/02/20 17:32:15 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -64,6 +64,27 @@
|
||||
* ****************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* _copyPlannedStmt
|
||||
*/
|
||||
static PlannedStmt *
|
||||
_copyPlannedStmt(PlannedStmt *from)
|
||||
{
|
||||
PlannedStmt *newnode = makeNode(PlannedStmt);
|
||||
|
||||
COPY_SCALAR_FIELD(commandType);
|
||||
COPY_SCALAR_FIELD(canSetTag);
|
||||
COPY_NODE_FIELD(planTree);
|
||||
COPY_NODE_FIELD(rtable);
|
||||
COPY_NODE_FIELD(resultRelations);
|
||||
COPY_NODE_FIELD(into);
|
||||
COPY_NODE_FIELD(returningLists);
|
||||
COPY_NODE_FIELD(rowMarks);
|
||||
COPY_SCALAR_FIELD(nParamExec);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* CopyPlanFields
|
||||
*
|
||||
@ -84,7 +105,6 @@ CopyPlanFields(Plan *from, Plan *newnode)
|
||||
COPY_NODE_FIELD(initPlan);
|
||||
COPY_BITMAPSET_FIELD(extParam);
|
||||
COPY_BITMAPSET_FIELD(allParam);
|
||||
COPY_SCALAR_FIELD(nParamExec);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -698,6 +718,23 @@ _copyRangeVar(RangeVar *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyIntoClause
|
||||
*/
|
||||
static IntoClause *
|
||||
_copyIntoClause(IntoClause *from)
|
||||
{
|
||||
IntoClause *newnode = makeNode(IntoClause);
|
||||
|
||||
COPY_NODE_FIELD(rel);
|
||||
COPY_NODE_FIELD(colNames);
|
||||
COPY_NODE_FIELD(options);
|
||||
COPY_SCALAR_FIELD(onCommit);
|
||||
COPY_STRING_FIELD(tableSpaceName);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't need a _copyExpr because Expr is an abstract supertype which
|
||||
* should never actually get instantiated. Also, since it has no common
|
||||
@ -1762,9 +1799,6 @@ _copyQuery(Query *from)
|
||||
COPY_NODE_FIELD(utilityStmt);
|
||||
COPY_SCALAR_FIELD(resultRelation);
|
||||
COPY_NODE_FIELD(into);
|
||||
COPY_NODE_FIELD(intoOptions);
|
||||
COPY_SCALAR_FIELD(intoOnCommit);
|
||||
COPY_STRING_FIELD(intoTableSpaceName);
|
||||
COPY_SCALAR_FIELD(hasAggs);
|
||||
COPY_SCALAR_FIELD(hasSubLinks);
|
||||
COPY_NODE_FIELD(rtable);
|
||||
@ -1779,8 +1813,6 @@ _copyQuery(Query *from)
|
||||
COPY_NODE_FIELD(limitCount);
|
||||
COPY_NODE_FIELD(rowMarks);
|
||||
COPY_NODE_FIELD(setOperations);
|
||||
COPY_NODE_FIELD(resultRelations);
|
||||
COPY_NODE_FIELD(returningLists);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -1832,10 +1864,6 @@ _copySelectStmt(SelectStmt *from)
|
||||
|
||||
COPY_NODE_FIELD(distinctClause);
|
||||
COPY_NODE_FIELD(into);
|
||||
COPY_NODE_FIELD(intoColNames);
|
||||
COPY_NODE_FIELD(intoOptions);
|
||||
COPY_SCALAR_FIELD(intoOnCommit);
|
||||
COPY_STRING_FIELD(intoTableSpaceName);
|
||||
COPY_NODE_FIELD(targetList);
|
||||
COPY_NODE_FIELD(fromClause);
|
||||
COPY_NODE_FIELD(whereClause);
|
||||
@ -2768,9 +2796,6 @@ _copyExecuteStmt(ExecuteStmt *from)
|
||||
|
||||
COPY_STRING_FIELD(name);
|
||||
COPY_NODE_FIELD(into);
|
||||
COPY_NODE_FIELD(intoOptions);
|
||||
COPY_SCALAR_FIELD(into_on_commit);
|
||||
COPY_STRING_FIELD(into_tbl_space);
|
||||
COPY_NODE_FIELD(params);
|
||||
|
||||
return newnode;
|
||||
@ -2902,6 +2927,9 @@ copyObject(void *from)
|
||||
/*
|
||||
* PLAN NODES
|
||||
*/
|
||||
case T_PlannedStmt:
|
||||
retval = _copyPlannedStmt(from);
|
||||
break;
|
||||
case T_Plan:
|
||||
retval = _copyPlan(from);
|
||||
break;
|
||||
@ -2990,6 +3018,9 @@ copyObject(void *from)
|
||||
case T_RangeVar:
|
||||
retval = _copyRangeVar(from);
|
||||
break;
|
||||
case T_IntoClause:
|
||||
retval = _copyIntoClause(from);
|
||||
break;
|
||||
case T_Var:
|
||||
retval = _copyVar(from);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user