1010 *
1111 *
1212 * IDENTIFICATION
13- * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.224 2007/01/30 01:33:36 tgl Exp $
13+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.225 2007/02/19 02:23:12 tgl Exp $
1414 *
1515 *-------------------------------------------------------------------------
1616 */
@@ -96,9 +96,10 @@ static BitmapHeapScan *make_bitmap_heapscan(List *qptlist,
9696static TidScan * make_tidscan (List * qptlist , List * qpqual , Index scanrelid ,
9797 List * tidquals );
9898static FunctionScan * make_functionscan (List * qptlist , List * qpqual ,
99- Index scanrelid );
99+ Index scanrelid , Node * funcexpr , List * funccolnames ,
100+ List * funccoltypes , List * funccoltypmods );
100101static ValuesScan * make_valuesscan (List * qptlist , List * qpqual ,
101- Index scanrelid );
102+ Index scanrelid , List * values_lists );
102103static BitmapAnd * make_bitmap_and (List * bitmapplans );
103104static BitmapOr * make_bitmap_or (List * bitmapplans );
104105static NestLoop * make_nestloop (List * tlist ,
@@ -1350,18 +1351,24 @@ create_functionscan_plan(PlannerInfo *root, Path *best_path,
13501351{
13511352 FunctionScan * scan_plan ;
13521353 Index scan_relid = best_path -> parent -> relid ;
1354+ RangeTblEntry * rte ;
13531355
13541356 /* it should be a function base rel... */
13551357 Assert (scan_relid > 0 );
1356- Assert (best_path -> parent -> rtekind == RTE_FUNCTION );
1358+ rte = rt_fetch (scan_relid , root -> parse -> rtable );
1359+ Assert (rte -> rtekind == RTE_FUNCTION );
13571360
13581361 /* Sort clauses into best execution order */
13591362 scan_clauses = order_qual_clauses (root , scan_clauses );
13601363
13611364 /* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */
13621365 scan_clauses = extract_actual_clauses (scan_clauses , false);
13631366
1364- scan_plan = make_functionscan (tlist , scan_clauses , scan_relid );
1367+ scan_plan = make_functionscan (tlist , scan_clauses , scan_relid ,
1368+ rte -> funcexpr ,
1369+ rte -> eref -> colnames ,
1370+ rte -> funccoltypes ,
1371+ rte -> funccoltypmods );
13651372
13661373 copy_path_costsize (& scan_plan -> scan .plan , best_path );
13671374
@@ -1379,18 +1386,21 @@ create_valuesscan_plan(PlannerInfo *root, Path *best_path,
13791386{
13801387 ValuesScan * scan_plan ;
13811388 Index scan_relid = best_path -> parent -> relid ;
1389+ RangeTblEntry * rte ;
13821390
13831391 /* it should be a values base rel... */
13841392 Assert (scan_relid > 0 );
1385- Assert (best_path -> parent -> rtekind == RTE_VALUES );
1393+ rte = rt_fetch (scan_relid , root -> parse -> rtable );
1394+ Assert (rte -> rtekind == RTE_VALUES );
13861395
13871396 /* Sort clauses into best execution order */
13881397 scan_clauses = order_qual_clauses (root , scan_clauses );
13891398
13901399 /* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */
13911400 scan_clauses = extract_actual_clauses (scan_clauses , false);
13921401
1393- scan_plan = make_valuesscan (tlist , scan_clauses , scan_relid );
1402+ scan_plan = make_valuesscan (tlist , scan_clauses , scan_relid ,
1403+ rte -> values_lists );
13941404
13951405 copy_path_costsize (& scan_plan -> scan .plan , best_path );
13961406
@@ -2342,7 +2352,11 @@ make_subqueryscan(List *qptlist,
23422352static FunctionScan *
23432353make_functionscan (List * qptlist ,
23442354 List * qpqual ,
2345- Index scanrelid )
2355+ Index scanrelid ,
2356+ Node * funcexpr ,
2357+ List * funccolnames ,
2358+ List * funccoltypes ,
2359+ List * funccoltypmods )
23462360{
23472361 FunctionScan * node = makeNode (FunctionScan );
23482362 Plan * plan = & node -> scan .plan ;
@@ -2353,14 +2367,19 @@ make_functionscan(List *qptlist,
23532367 plan -> lefttree = NULL ;
23542368 plan -> righttree = NULL ;
23552369 node -> scan .scanrelid = scanrelid ;
2370+ node -> funcexpr = funcexpr ;
2371+ node -> funccolnames = funccolnames ;
2372+ node -> funccoltypes = funccoltypes ;
2373+ node -> funccoltypmods = funccoltypmods ;
23562374
23572375 return node ;
23582376}
23592377
23602378static ValuesScan *
23612379make_valuesscan (List * qptlist ,
23622380 List * qpqual ,
2363- Index scanrelid )
2381+ Index scanrelid ,
2382+ List * values_lists )
23642383{
23652384 ValuesScan * node = makeNode (ValuesScan );
23662385 Plan * plan = & node -> scan .plan ;
@@ -2371,6 +2390,7 @@ make_valuesscan(List *qptlist,
23712390 plan -> lefttree = NULL ;
23722391 plan -> righttree = NULL ;
23732392 node -> scan .scanrelid = scanrelid ;
2393+ node -> values_lists = values_lists ;
23742394
23752395 return node ;
23762396}
0 commit comments