mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Implement SQL-standard WITH clauses, including WITH RECURSIVE.
There are some unimplemented aspects: recursive queries must use UNION ALL (should allow UNION too), and we don't have SEARCH or CYCLE clauses. These might or might not get done for 8.4, but even without them it's a pretty useful feature. There are also a couple of small loose ends and definitional quibbles, which I'll send a memo about to pgsql-hackers shortly. But let's land the patch now so we can get on with other development. Yoshiyuki Asaba, with lots of help from Tatsuo Ishii and Tom Lane
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/cost.h,v 1.92 2008/08/22 00:16:04 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/cost.h,v 1.93 2008/10/04 21:56:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -72,6 +72,8 @@ extern void cost_functionscan(Path *path, PlannerInfo *root,
|
||||
RelOptInfo *baserel);
|
||||
extern void cost_valuesscan(Path *path, PlannerInfo *root,
|
||||
RelOptInfo *baserel);
|
||||
extern void cost_ctescan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
|
||||
extern void cost_recursive_union(Plan *runion, Plan *nrterm, Plan *rterm);
|
||||
extern void cost_sort(Path *path, PlannerInfo *root,
|
||||
List *pathkeys, Cost input_cost, double tuples, int width,
|
||||
double limit_tuples);
|
||||
@@ -104,6 +106,8 @@ extern void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
|
||||
List *restrictlist);
|
||||
extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
|
||||
extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
|
||||
extern void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel,
|
||||
Plan *cteplan);
|
||||
|
||||
/*
|
||||
* prototypes for clausesel.c
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.78 2008/08/14 18:48:00 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.79 2008/10/04 21:56:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -54,6 +54,8 @@ extern UniquePath *create_unique_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
extern Path *create_subqueryscan_path(RelOptInfo *rel, List *pathkeys);
|
||||
extern Path *create_functionscan_path(PlannerInfo *root, RelOptInfo *rel);
|
||||
extern Path *create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel);
|
||||
extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel);
|
||||
extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel);
|
||||
|
||||
extern NestPath *create_nestloop_path(PlannerInfo *root,
|
||||
RelOptInfo *joinrel,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.112 2008/09/09 18:58:09 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.113 2008/10/04 21:56:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -42,6 +42,8 @@ extern Plan *create_plan(PlannerInfo *root, Path *best_path);
|
||||
extern SubqueryScan *make_subqueryscan(List *qptlist, List *qpqual,
|
||||
Index scanrelid, Plan *subplan, List *subrtable);
|
||||
extern Append *make_append(List *appendplans, bool isTarget, List *tlist);
|
||||
extern RecursiveUnion *make_recursive_union(List *tlist,
|
||||
Plan *lefttree, Plan *righttree, int wtParam);
|
||||
extern Sort *make_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree,
|
||||
List *pathkeys, double limit_tuples);
|
||||
extern Sort *make_sort_from_sortclauses(PlannerInfo *root, List *sortcls,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/planner.h,v 1.44 2008/01/01 19:45:58 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/planner.h,v 1.45 2008/10/04 21:56:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -30,7 +30,8 @@ extern PlannedStmt *planner(Query *parse, int cursorOptions,
|
||||
extern PlannedStmt *standard_planner(Query *parse, int cursorOptions,
|
||||
ParamListInfo boundParams);
|
||||
extern Plan *subquery_planner(PlannerGlobal *glob, Query *parse,
|
||||
Index level, double tuple_fraction,
|
||||
PlannerInfo *parent_root,
|
||||
bool hasRecursion, double tuple_fraction,
|
||||
PlannerInfo **subroot);
|
||||
|
||||
#endif /* PLANNER_H */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/subselect.h,v 1.33 2008/08/17 01:20:00 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/subselect.h,v 1.34 2008/10/04 21:56:55 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "nodes/plannodes.h"
|
||||
#include "nodes/relation.h"
|
||||
|
||||
extern void SS_process_ctes(PlannerInfo *root);
|
||||
extern bool convert_ANY_sublink_to_join(PlannerInfo *root, SubLink *sublink,
|
||||
Relids available_rels,
|
||||
Node **new_qual, List **fromlist);
|
||||
@@ -28,5 +29,6 @@ extern void SS_finalize_plan(PlannerInfo *root, Plan *plan,
|
||||
bool attach_initplans);
|
||||
extern Param *SS_make_initplan_from_plan(PlannerInfo *root, Plan *plan,
|
||||
Oid resulttype, int32 resulttypmod);
|
||||
extern int SS_assign_worktable_param(PlannerInfo *root);
|
||||
|
||||
#endif /* SUBSELECT_H */
|
||||
|
||||
Reference in New Issue
Block a user