Created
February 18, 2016 15:52
-
-
Save danielgustafsson/1a9168b9f2797e6e0570 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c | |
index 62600d9..403c132 100644 | |
--- a/src/backend/commands/explain.c | |
+++ b/src/backend/commands/explain.c | |
@@ -8,7 +8,7 @@ | |
* Portions Copyright (c) 1994-5, Regents of the University of California | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.154 2007/02/14 01:58:56 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.155 2007/02/19 02:23:11 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -1373,6 +1373,7 @@ explain_outNode(StringInfo str, | |
{ | |
RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid, | |
es->rtable); | |
+ Node *funcexpr; | |
char *proname; | |
/* Assert it's on a RangeFunction */ | |
@@ -1384,10 +1385,10 @@ explain_outNode(StringInfo str, | |
* happen if the optimizer simplified away the function call, | |
* for example). | |
*/ | |
- if (rte->funcexpr && IsA(rte->funcexpr, FuncExpr)) | |
+ funcexpr = ((FunctionScan *) plan)->funcexpr; | |
+ if (funcexpr && IsA(funcexpr, FuncExpr)) | |
{ | |
- FuncExpr *funcexpr = (FuncExpr *) rte->funcexpr; | |
- Oid funcid = funcexpr->funcid; | |
+ Oid funcid = ((FuncExpr *) funcexpr)->funcid; | |
/* We only show the func name, not schema name */ | |
proname = get_func_name(funcid); | |
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c | |
index 65f89f5..3b38509 100644 | |
--- a/src/backend/executor/execAmi.c | |
+++ b/src/backend/executor/execAmi.c | |
@@ -6,7 +6,7 @@ | |
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group | |
* Portions Copyright (c) 1994, Regents of the University of California | |
* | |
- * $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.91 2007/02/15 03:07:13 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.92 2007/02/19 02:23:11 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -548,18 +548,20 @@ ExecMayReturnRawTuples(PlanState *node) | |
case T_IndexScanState: | |
case T_BitmapHeapScanState: | |
case T_TidScanState: | |
- case T_SubqueryScanState: | |
- case T_FunctionScanState: | |
- case T_ValuesScanState: | |
if (node->ps_ProjInfo == NULL) | |
return true; | |
break; | |
- | |
case T_SeqScanState: | |
insist_log(false, "SeqScan/AppendOnlyScan/AOCSScan are defunct"); | |
break; | |
+ case T_SubqueryScanState: | |
+ /* If not projecting, look at input plan */ | |
+ if (node->ps_ProjInfo == NULL) | |
+ return ExecMayReturnRawTuples(((SubqueryScanState *) node)->subplan); | |
+ break; | |
+ | |
/* Non-projecting nodes */ | |
case T_MotionState: | |
if (node->lefttree == NULL) | |
diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c | |
index db1c37d..95578e8 100644 | |
--- a/src/backend/executor/nodeFunctionscan.c | |
+++ b/src/backend/executor/nodeFunctionscan.c | |
@@ -9,7 +9,7 @@ | |
* | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.42 2007/01/05 22:19:28 momjian Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.43 2007/02/19 02:23:11 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -151,7 +151,6 @@ FunctionScanState * | |
ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags) | |
{ | |
FunctionScanState *scanstate; | |
- RangeTblEntry *rte; | |
Oid funcrettype; | |
TypeFuncClass functypclass; | |
TupleDesc tupdesc = NULL; | |
@@ -201,16 +200,10 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags) | |
ItemPointerSet(&scanstate->cdb_mark_ctid, 0, 0); | |
/* | |
- * get info about function | |
- */ | |
- rte = rt_fetch(node->scan.scanrelid, estate->es_range_table); | |
- Assert(rte->rtekind == RTE_FUNCTION); | |
- | |
- /* | |
* Now determine if the function returns a simple or composite type, and | |
* build an appropriate tupdesc. | |
*/ | |
- functypclass = get_expr_result_type(rte->funcexpr, | |
+ functypclass = get_expr_result_type(node->funcexpr, | |
&funcrettype, | |
&tupdesc); | |
@@ -224,7 +217,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags) | |
else if (functypclass == TYPEFUNC_SCALAR) | |
{ | |
/* Base data type, i.e. scalar */ | |
- char *attname = strVal(linitial(rte->eref->colnames)); | |
+ char *attname = strVal(linitial(node->funccolnames)); | |
tupdesc = CreateTemplateTupleDesc(1, false); | |
TupleDescInitEntry(tupdesc, | |
@@ -236,9 +229,9 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags) | |
} | |
else if (functypclass == TYPEFUNC_RECORD) | |
{ | |
- tupdesc = BuildDescFromLists(rte->eref->colnames, | |
- rte->funccoltypes, | |
- rte->funccoltypmods); | |
+ tupdesc = BuildDescFromLists(node->funccolnames, | |
+ node->funccoltypes, | |
+ node->funccoltypmods); | |
} | |
else | |
{ | |
@@ -260,7 +253,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags) | |
* Other node-specific setup | |
*/ | |
scanstate->tuplestorestate = NULL; | |
- scanstate->funcexpr = ExecInitExpr((Expr *) rte->funcexpr, | |
+ scanstate->funcexpr = ExecInitExpr((Expr *) node->funcexpr, | |
(PlanState *) scanstate); | |
/* | |
diff --git a/src/backend/executor/nodeValuesscan.c b/src/backend/executor/nodeValuesscan.c | |
index 244ddad..c532620 100644 | |
--- a/src/backend/executor/nodeValuesscan.c | |
+++ b/src/backend/executor/nodeValuesscan.c | |
@@ -10,7 +10,7 @@ | |
* | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/executor/nodeValuesscan.c,v 1.5 2007/01/05 22:19:28 momjian Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/executor/nodeValuesscan.c,v 1.6 2007/02/19 02:23:11 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -195,7 +195,6 @@ ValuesScanState * | |
ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags) | |
{ | |
ValuesScanState *scanstate; | |
- RangeTblEntry *rte; | |
TupleDesc tupdesc; | |
ListCell *vtl; | |
int i; | |
@@ -252,9 +251,7 @@ ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags) | |
/* | |
* get info about values list | |
*/ | |
- rte = rt_fetch(node->scan.scanrelid, estate->es_range_table); | |
- Assert(rte->rtekind == RTE_VALUES); | |
- tupdesc = ExecTypeFromExprList((List *) linitial(rte->values_lists)); | |
+ tupdesc = ExecTypeFromExprList((List *) linitial(node->values_lists)); | |
ExecAssignScanType(&scanstate->ss, tupdesc); | |
@@ -263,13 +260,13 @@ ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags) | |
*/ | |
scanstate->marked_idx = -1; | |
scanstate->curr_idx = -1; | |
- scanstate->array_len = list_length(rte->values_lists); | |
+ scanstate->array_len = list_length(node->values_lists); | |
/* convert list of sublists into array of sublists for easy addressing */ | |
scanstate->exprlists = (List **) | |
palloc(scanstate->array_len * sizeof(List *)); | |
i = 0; | |
- foreach(vtl, rte->values_lists) | |
+ foreach(vtl, node->values_lists) | |
{ | |
scanstate->exprlists[i++] = (List *) lfirst(vtl); | |
} | |
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c | |
index c11a494..2ee9bbd 100644 | |
--- a/src/backend/nodes/copyfuncs.c | |
+++ b/src/backend/nodes/copyfuncs.c | |
@@ -16,7 +16,7 @@ | |
* Portions Copyright (c) 1994, Regents of the University of California | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.365 2007/02/03 14:06:54 petere Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.366 2007/02/19 02:23:11 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -657,6 +657,14 @@ _copyFunctionScan(FunctionScan *from) | |
*/ | |
CopyScanFields((Scan *) from, (Scan *) newnode); | |
+ /* | |
+ * copy remainder of node | |
+ */ | |
+ COPY_NODE_FIELD(funcexpr); | |
+ COPY_NODE_FIELD(funccolnames); | |
+ COPY_NODE_FIELD(funccoltypes); | |
+ COPY_NODE_FIELD(funccoltypmods); | |
+ | |
return newnode; | |
} | |
@@ -673,6 +681,11 @@ _copyValuesScan(ValuesScan *from) | |
*/ | |
CopyScanFields((Scan *) from, (Scan *) newnode); | |
+ /* | |
+ * copy remainder of node | |
+ */ | |
+ COPY_NODE_FIELD(values_lists); | |
+ | |
return newnode; | |
} | |
diff --git a/src/backend/nodes/outfast.c b/src/backend/nodes/outfast.c | |
index 3fb28a6..6e4b591 100644 | |
--- a/src/backend/nodes/outfast.c | |
+++ b/src/backend/nodes/outfast.c | |
@@ -1513,6 +1513,9 @@ _outNode(StringInfo str, void *obj) | |
case T_PlannerInfo: | |
_outPlannerInfo(str, obj); | |
break; | |
+ case T_PlannerParamItem: | |
+ _outPlannerParamItem(str, obj); | |
+ break; | |
case T_RelOptInfo: | |
_outRelOptInfo(str, obj); | |
break; | |
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c | |
index cd0c1c2..330dc53 100644 | |
--- a/src/backend/nodes/outfuncs.c | |
+++ b/src/backend/nodes/outfuncs.c | |
@@ -9,7 +9,7 @@ | |
* | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.297 2007/02/12 17:19:30 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.299 2007/02/19 07:03:27 tgl Exp $ | |
* | |
* NOTES | |
* Every node type that can appear in stored rules' parsetrees *must* | |
@@ -690,6 +690,11 @@ _outFunctionScan(StringInfo str, FunctionScan *node) | |
WRITE_NODE_TYPE("FUNCTIONSCAN"); | |
_outScanInfo(str, (Scan *) node); | |
+ | |
+ WRITE_NODE_FIELD(funcexpr); | |
+ WRITE_NODE_FIELD(funccolnames); | |
+ WRITE_NODE_FIELD(funccoltypes); | |
+ WRITE_NODE_FIELD(funccoltypmods); | |
} | |
static void | |
@@ -698,6 +703,8 @@ _outValuesScan(StringInfo str, ValuesScan *node) | |
WRITE_NODE_TYPE("VALUESSCAN"); | |
_outScanInfo(str, (Scan *) node); | |
+ | |
+ WRITE_NODE_FIELD(values_lists); | |
} | |
static void | |
@@ -1982,7 +1989,10 @@ _outPlannerInfo(StringInfo str, PlannerInfo *node) | |
/* NB: this isn't a complete set of fields */ | |
WRITE_NODE_FIELD(parse); | |
+ WRITE_NODE_FIELD(glob); | |
+ WRITE_UINT_FIELD(query_level); | |
WRITE_NODE_FIELD(join_rel_list); | |
+ WRITE_NODE_FIELD(init_plans); | |
WRITE_NODE_FIELD(eq_classes); | |
WRITE_NODE_FIELD(canon_pathkeys); | |
WRITE_NODE_FIELD(left_join_clauses); | |
@@ -2246,6 +2256,15 @@ _outAppendRelInfo(StringInfo str, AppendRelInfo *node) | |
WRITE_OID_FIELD(parent_reloid); | |
} | |
+static void | |
+_outPlannerParamItem(StringInfo str, PlannerParamItem *node) | |
+{ | |
+ WRITE_NODE_TYPE("PLANNERPARAMITEM"); | |
+ | |
+ WRITE_NODE_FIELD(item); | |
+ WRITE_UINT_FIELD(abslevel); | |
+} | |
+ | |
/***************************************************************************** | |
* | |
* Stuff from parsenodes.h. | |
@@ -4575,6 +4594,9 @@ _outNode(StringInfo str, void *obj) | |
case T_AppendRelInfo: | |
_outAppendRelInfo(str, obj); | |
break; | |
+ case T_PlannerParamItem: | |
+ _outPlannerParamItem(str, obj); | |
+ break; | |
case T_GrantStmt: | |
diff --git a/src/backend/nodes/readfast.c b/src/backend/nodes/readfast.c | |
index 4ebb861..e1a9c3c 100644 | |
--- a/src/backend/nodes/readfast.c | |
+++ b/src/backend/nodes/readfast.c | |
@@ -1445,6 +1445,16 @@ _readGrantRoleStmt(void) | |
READ_DONE(); | |
} | |
+static PlannerParamItem * | |
+_readPlannerParamItem(void) | |
+{ | |
+ READ_LOCALS(PlannerParamItem); | |
+ READ_NODE_FIELD(item); | |
+ READ_UINT_FIELD(abslevel); | |
+ | |
+ READ_DONE(); | |
+} | |
+ | |
/* | |
* _readPlannedStmt | |
*/ | |
@@ -1823,6 +1833,11 @@ _readFunctionScan(void) | |
{ | |
READ_LOCALS(FunctionScan); | |
+ READ_NODE_FIELD(funcexpr); | |
+ READ_NODE_FIELD(funccolnames); | |
+ READ_NODE_FIELD(funccoltypes); | |
+ READ_NODE_FIELD(funccoltypmods); | |
+ | |
readScanInfo((Scan *)local_node); | |
READ_DONE(); | |
@@ -1836,6 +1851,8 @@ _readValuesScan(void) | |
{ | |
READ_LOCALS(ValuesScan); | |
+ READ_NODE_FIELD(values_lists); | |
+ | |
readScanInfo((Scan *)local_node); | |
READ_DONE(); | |
@@ -2643,6 +2660,9 @@ readNodeBinary(void) | |
case T_Plan: | |
return_value = _readPlan(); | |
break; | |
+ case T_PlannerParamItem: | |
+ return_value = _readPlannerParamItem(); | |
+ break; | |
case T_Result: | |
return_value = _readResult(); | |
break; | |
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c | |
index 77a029e..3754746 100644 | |
--- a/src/backend/optimizer/plan/createplan.c | |
+++ b/src/backend/optimizer/plan/createplan.c | |
@@ -11,7 +11,7 @@ | |
* | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.224 2007/01/30 01:33:36 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.225 2007/02/19 02:23:12 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -153,9 +153,10 @@ static TableFunctionScan* make_tablefunction(List *tlist, | |
static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid, | |
List *tidquals); | |
static FunctionScan *make_functionscan(List *qptlist, List *qpqual, | |
- Index scanrelid); | |
+ Index scanrelid, Node *funcexpr, List *funccolnames, | |
+ List *funccoltypes, List *funccoltypmods); | |
static ValuesScan *make_valuesscan(List *qptlist, List *qpqual, | |
- Index scanrelid); | |
+ Index scanrelid, List *values_lists); | |
static BitmapAnd *make_bitmap_and(List *bitmapplans); | |
static BitmapOr *make_bitmap_or(List *bitmapplans); | |
static Sort *make_sort(PlannerInfo *root, Plan *lefttree, int numCols, | |
@@ -2516,10 +2517,12 @@ create_functionscan_plan(PlannerInfo *root, Path *best_path, | |
{ | |
FunctionScan *scan_plan; | |
Index scan_relid = best_path->parent->relid; | |
+ RangeTblEntry *rte; | |
/* it should be a function base rel... */ | |
Assert(scan_relid > 0); | |
- Assert(best_path->parent->rtekind == RTE_FUNCTION); | |
+ rte = rt_fetch(scan_relid, root->parse->rtable); | |
+ Assert(rte->rtekind == RTE_FUNCTION); | |
/* Sort clauses into best execution order */ | |
scan_clauses = order_qual_clauses(root, scan_clauses); | |
@@ -2527,7 +2530,11 @@ create_functionscan_plan(PlannerInfo *root, Path *best_path, | |
/* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */ | |
scan_clauses = extract_actual_clauses(scan_clauses, false); | |
- scan_plan = make_functionscan(tlist, scan_clauses, scan_relid); | |
+ scan_plan = make_functionscan(tlist, scan_clauses, scan_relid, | |
+ rte->funcexpr, | |
+ rte->eref->colnames, | |
+ rte->funccoltypes, | |
+ rte->funccoltypmods); | |
copy_path_costsize(root, &scan_plan->scan.plan, best_path); | |
@@ -2580,10 +2587,12 @@ create_valuesscan_plan(PlannerInfo *root, Path *best_path, | |
{ | |
ValuesScan *scan_plan; | |
Index scan_relid = best_path->parent->relid; | |
+ RangeTblEntry *rte; | |
/* it should be a values base rel... */ | |
Assert(scan_relid > 0); | |
- Assert(best_path->parent->rtekind == RTE_VALUES); | |
+ rte = rt_fetch(scan_relid, root->parse->rtable); | |
+ Assert(rte->rtekind == RTE_VALUES); | |
/* Sort clauses into best execution order */ | |
scan_clauses = order_qual_clauses(root, scan_clauses); | |
@@ -2591,7 +2600,8 @@ create_valuesscan_plan(PlannerInfo *root, Path *best_path, | |
/* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */ | |
scan_clauses = extract_actual_clauses(scan_clauses, false); | |
- scan_plan = make_valuesscan(tlist, scan_clauses, scan_relid); | |
+ scan_plan = make_valuesscan(tlist, scan_clauses, scan_relid, | |
+ rte->values_lists); | |
copy_path_costsize(root, &scan_plan->scan.plan, best_path); | |
@@ -3875,7 +3885,11 @@ make_subqueryscan(PlannerInfo *root, | |
static FunctionScan * | |
make_functionscan(List *qptlist, | |
List *qpqual, | |
- Index scanrelid) | |
+ Index scanrelid, | |
+ Node *funcexpr, | |
+ List *funccolnames, | |
+ List *funccoltypes, | |
+ List *funccoltypmods) | |
{ | |
FunctionScan *node = makeNode(FunctionScan); | |
Plan *plan = &node->scan.plan; | |
@@ -3886,6 +3900,10 @@ make_functionscan(List *qptlist, | |
plan->lefttree = NULL; | |
plan->righttree = NULL; | |
node->scan.scanrelid = scanrelid; | |
+ node->funcexpr = funcexpr; | |
+ node->funccolnames = funccolnames; | |
+ node->funccoltypes = funccoltypes; | |
+ node->funccoltypmods = funccoltypmods; | |
return node; | |
} | |
@@ -3893,7 +3911,8 @@ make_functionscan(List *qptlist, | |
static ValuesScan * | |
make_valuesscan(List *qptlist, | |
List *qpqual, | |
- Index scanrelid) | |
+ Index scanrelid, | |
+ List *values_lists) | |
{ | |
ValuesScan *node = makeNode(ValuesScan); | |
Plan *plan = &node->scan.plan; | |
@@ -3904,6 +3923,7 @@ make_valuesscan(List *qptlist, | |
plan->lefttree = NULL; | |
plan->righttree = NULL; | |
node->scan.scanrelid = scanrelid; | |
+ node->values_lists = values_lists; | |
return node; | |
} | |
diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c | |
index 666cc55..24852fe 100644 | |
--- a/src/backend/optimizer/plan/planagg.c | |
+++ b/src/backend/optimizer/plan/planagg.c | |
@@ -9,7 +9,7 @@ | |
* | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.26 2007/02/06 06:50:26 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.27 2007/02/19 07:03:29 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -453,6 +453,7 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info) | |
*/ | |
memcpy(&subroot, root, sizeof(PlannerInfo)); | |
subroot.parse = subparse = (Query *) copyObject(root->parse); | |
+ subroot.init_plans = NIL; | |
subparse->commandType = CMD_SELECT; | |
subparse->resultRelation = 0; | |
subparse->resultRelations = NIL; | |
@@ -552,6 +553,9 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info) | |
info->param = SS_make_initplan_from_plan(&subroot, plan, | |
exprType((Node *) tle->expr), | |
-1); | |
+ | |
+ /* Make sure the InitPlan gets into the outer list */ | |
+ root->init_plans = list_concat(root->init_plans, subroot.init_plans); | |
} | |
/* | |
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c | |
index 7906a2a..a8a5bee 100644 | |
--- a/src/backend/optimizer/plan/planner.c | |
+++ b/src/backend/optimizer/plan/planner.c | |
@@ -9,7 +9,7 @@ | |
* | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.212 2007/01/20 20:45:39 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.213 2007/02/19 07:03:29 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -63,8 +63,6 @@ double cursor_tuple_fraction = DEFAULT_CURSOR_TUPLE_FRACTION; | |
/* Hook for plugins to get control in planner() */ | |
planner_hook_type planner_hook = NULL; | |
-ParamListInfo PlannerBoundParamList = NULL; /* current boundParams */ | |
- | |
/* Expression kind codes for preprocess_expression */ | |
#define EXPRKIND_QUAL 0 | |
#define EXPRKIND_TARGET 1 | |
@@ -329,9 +327,6 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) | |
} | |
/* | |
- * The planner can be called recursively (an example is when | |
- * eval_const_expressions tries to pre-evaluate an SQL function). | |
- * | |
* Set up global state for this planner invocation. This data is needed | |
* across all levels of sub-Query that might exist in the given command, | |
* so we keep it in a separate struct that's linked to by each per-Query | |
@@ -558,6 +553,7 @@ subquery_planner(PlannerGlobal *glob, | |
root->query_level = parent_root ? parent_root->query_level + 1 : 1; | |
root->parent_root = parent_root; | |
root->planner_cxt = CurrentMemoryContext; | |
+ root->init_plans = NIL; | |
root->eq_classes = NIL; | |
root->init_plans = NIL; | |
@@ -1032,6 +1028,7 @@ inheritance_planner(PlannerInfo *root) | |
subroot.in_info_list = (List *) | |
adjust_appendrel_attrs(&subroot, (Node *) root->in_info_list, | |
appinfo); | |
+ subroot.init_plans = NIL; | |
/* There shouldn't be any OJ info to translate, as yet */ | |
Assert(subroot.oj_info_list == NIL); | |
@@ -1106,6 +1103,9 @@ inheritance_planner(PlannerInfo *root) | |
subplans = lappend(subplans, subplan); | |
+ /* Make sure any initplans from this rel get into the outer list */ | |
+ root->init_plans = list_concat(root->init_plans, subroot.init_plans); | |
+ | |
/* Build target-relations list for the executor */ | |
resultRelations = lappend_int(resultRelations, appinfo->child_relid); | |
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c | |
index 6088fd3..b9492a6 100644 | |
--- a/src/backend/optimizer/plan/subselect.c | |
+++ b/src/backend/optimizer/plan/subselect.c | |
@@ -8,7 +8,7 @@ | |
* Portions Copyright (c) 1994, Regents of the University of California | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.118 2007/02/06 02:59:11 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.120 2007/02/19 07:03:30 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -1194,25 +1195,13 @@ finalize_plan(PlannerInfo *root, Plan *plan, List *rtable, | |
break; | |
case T_FunctionScan: | |
- { | |
- RangeTblEntry *rte; | |
- | |
- rte = rt_fetch(((FunctionScan *) plan)->scan.scanrelid, | |
- rtable); | |
- Assert(rte->rtekind == RTE_FUNCTION); | |
- finalize_primnode(rte->funcexpr, &context); | |
- } | |
+ finalize_primnode(((FunctionScan *) plan)->funcexpr, | |
+ &context); | |
break; | |
case T_ValuesScan: | |
- { | |
- RangeTblEntry *rte; | |
- | |
- rte = rt_fetch(((ValuesScan *) plan)->scan.scanrelid, | |
- rtable); | |
- Assert(rte->rtekind == RTE_VALUES); | |
- finalize_primnode((Node *) rte->values_lists, &context); | |
- } | |
+ finalize_primnode((Node *) ((ValuesScan *) plan)->values_lists, | |
+ &context); | |
break; | |
case T_Append: | |
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c | |
index b265b08..c9cc650 100644 | |
--- a/src/backend/optimizer/prep/prepjointree.c | |
+++ b/src/backend/optimizer/prep/prepjointree.c | |
@@ -16,7 +16,7 @@ | |
* | |
* | |
* IDENTIFICATION | |
- * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.46 2007/01/20 20:45:39 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.47 2007/02/19 07:03:30 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -277,7 +277,10 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, | |
*/ | |
subroot = makeNode(PlannerInfo); | |
subroot->parse = subquery; | |
+ subroot->glob = root->glob; | |
+ subroot->query_level = root->query_level; | |
subroot->planner_cxt = CurrentMemoryContext; | |
+ subroot->init_plans = NIL; | |
subroot->in_info_list = NIL; | |
subroot->append_rel_list = NIL; | |
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h | |
index 7df8d64..8487572 100644 | |
--- a/src/include/nodes/plannodes.h | |
+++ b/src/include/nodes/plannodes.h | |
@@ -9,7 +9,7 @@ | |
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group | |
* Portions Copyright (c) 1994, Regents of the University of California | |
* | |
- * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.89 2007/01/10 18:06:04 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.90 2007/02/19 02:23:12 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -646,7 +646,10 @@ typedef struct SubqueryScan | |
typedef struct FunctionScan | |
{ | |
Scan scan; | |
- /* no other fields needed at present */ | |
+ Node *funcexpr; /* expression tree for func call */ | |
+ List *funccolnames; /* output column names (string Value nodes) */ | |
+ List *funccoltypes; /* OID list of column type OIDs */ | |
+ List *funccoltypmods; /* integer list of column typmods */ | |
} FunctionScan; | |
/* ---------------- | |
@@ -666,7 +669,7 @@ typedef struct TableFunctionScan | |
typedef struct ValuesScan | |
{ | |
Scan scan; | |
- /* no other fields needed at present */ | |
+ List *values_lists; /* list of expression lists */ | |
} ValuesScan; | |
/* ---------------- | |
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h | |
index 0b5fabb..021253b 100644 | |
--- a/src/include/nodes/relation.h | |
+++ b/src/include/nodes/relation.h | |
@@ -8,7 +8,7 @@ | |
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group | |
* Portions Copyright (c) 1994, Regents of the University of California | |
* | |
- * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.135 2007/02/16 20:57:19 tgl Exp $ | |
+ * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.136 2007/02/19 07:03:33 tgl Exp $ | |
* | |
*------------------------------------------------------------------------- | |
*/ | |
@@ -132,6 +132,7 @@ typedef struct CtePlanInfo | |
List *pathkeys; | |
} CtePlanInfo; | |
+ | |
/*---------- | |
* PlannerInfo | |
* Per-query information for planning/optimization | |
@@ -192,7 +193,7 @@ typedef struct PlannerInfo | |
List *returningLists; /* list of lists of TargetEntry, or NIL */ | |
List *result_aosegnos; | |
- List *init_plans; /* init subplans for query */ | |
+ List *init_plans; /* init subplans for query */ | |
List *list_cteplaninfo; /* list of CtePlannerInfo, one for each CTE */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment