Header And Logo

PostgreSQL
| The world's most advanced open source database.

planmain.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * planmain.h
00004  *    prototypes for various files in optimizer/plan
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/include/optimizer/planmain.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef PLANMAIN_H
00015 #define PLANMAIN_H
00016 
00017 #include "nodes/plannodes.h"
00018 #include "nodes/relation.h"
00019 
00020 /* GUC parameters */
00021 #define DEFAULT_CURSOR_TUPLE_FRACTION 0.1
00022 extern double cursor_tuple_fraction;
00023 
00024 /* query_planner callback to compute query_pathkeys */
00025 typedef void (*query_pathkeys_callback) (PlannerInfo *root, void *extra);
00026 
00027 /*
00028  * prototypes for plan/planmain.c
00029  */
00030 extern void query_planner(PlannerInfo *root, List *tlist,
00031               double tuple_fraction, double limit_tuples,
00032               query_pathkeys_callback qp_callback, void *qp_extra,
00033               Path **cheapest_path, Path **sorted_path,
00034               double *num_groups);
00035 
00036 /*
00037  * prototypes for plan/planagg.c
00038  */
00039 extern void preprocess_minmax_aggregates(PlannerInfo *root, List *tlist);
00040 extern Plan *optimize_minmax_aggregates(PlannerInfo *root, List *tlist,
00041                            const AggClauseCosts *aggcosts, Path *best_path);
00042 
00043 /*
00044  * prototypes for plan/createplan.c
00045  */
00046 extern Plan *create_plan(PlannerInfo *root, Path *best_path);
00047 extern SubqueryScan *make_subqueryscan(List *qptlist, List *qpqual,
00048                   Index scanrelid, Plan *subplan);
00049 extern ForeignScan *make_foreignscan(List *qptlist, List *qpqual,
00050                  Index scanrelid, List *fdw_exprs, List *fdw_private);
00051 extern Append *make_append(List *appendplans, List *tlist);
00052 extern RecursiveUnion *make_recursive_union(List *tlist,
00053                      Plan *lefttree, Plan *righttree, int wtParam,
00054                      List *distinctList, long numGroups);
00055 extern Sort *make_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree,
00056                         List *pathkeys, double limit_tuples);
00057 extern Sort *make_sort_from_sortclauses(PlannerInfo *root, List *sortcls,
00058                            Plan *lefttree);
00059 extern Sort *make_sort_from_groupcols(PlannerInfo *root, List *groupcls,
00060                          AttrNumber *grpColIdx, Plan *lefttree);
00061 extern Agg *make_agg(PlannerInfo *root, List *tlist, List *qual,
00062          AggStrategy aggstrategy, const AggClauseCosts *aggcosts,
00063          int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators,
00064          long numGroups,
00065          Plan *lefttree);
00066 extern WindowAgg *make_windowagg(PlannerInfo *root, List *tlist,
00067                List *windowFuncs, Index winref,
00068                int partNumCols, AttrNumber *partColIdx, Oid *partOperators,
00069                int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators,
00070                int frameOptions, Node *startOffset, Node *endOffset,
00071                Plan *lefttree);
00072 extern Group *make_group(PlannerInfo *root, List *tlist, List *qual,
00073            int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators,
00074            double numGroups,
00075            Plan *lefttree);
00076 extern Plan *materialize_finished_plan(Plan *subplan);
00077 extern Unique *make_unique(Plan *lefttree, List *distinctList);
00078 extern LockRows *make_lockrows(Plan *lefttree, List *rowMarks, int epqParam);
00079 extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount,
00080            int64 offset_est, int64 count_est);
00081 extern SetOp *make_setop(SetOpCmd cmd, SetOpStrategy strategy, Plan *lefttree,
00082            List *distinctList, AttrNumber flagColIdx, int firstFlag,
00083            long numGroups, double outputRows);
00084 extern Result *make_result(PlannerInfo *root, List *tlist,
00085             Node *resconstantqual, Plan *subplan);
00086 extern ModifyTable *make_modifytable(PlannerInfo *root,
00087                  CmdType operation, bool canSetTag,
00088                  List *resultRelations, List *subplans, List *returningLists,
00089                  List *rowMarks, int epqParam);
00090 extern bool is_projection_capable_plan(Plan *plan);
00091 
00092 /*
00093  * prototypes for plan/initsplan.c
00094  */
00095 extern int  from_collapse_limit;
00096 extern int  join_collapse_limit;
00097 
00098 extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode);
00099 extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist);
00100 extern void add_vars_to_targetlist(PlannerInfo *root, List *vars,
00101                        Relids where_needed, bool create_new_ph);
00102 extern void find_lateral_references(PlannerInfo *root);
00103 extern void create_lateral_join_info(PlannerInfo *root);
00104 extern List *deconstruct_jointree(PlannerInfo *root);
00105 extern void distribute_restrictinfo_to_rels(PlannerInfo *root,
00106                                 RestrictInfo *restrictinfo);
00107 extern void process_implied_equality(PlannerInfo *root,
00108                          Oid opno,
00109                          Oid collation,
00110                          Expr *item1,
00111                          Expr *item2,
00112                          Relids qualscope,
00113                          Relids nullable_relids,
00114                          bool below_outer_join,
00115                          bool both_const);
00116 extern RestrictInfo *build_implied_join_equality(Oid opno,
00117                             Oid collation,
00118                             Expr *item1,
00119                             Expr *item2,
00120                             Relids qualscope,
00121                             Relids nullable_relids);
00122 
00123 /*
00124  * prototypes for plan/analyzejoins.c
00125  */
00126 extern List *remove_useless_joins(PlannerInfo *root, List *joinlist);
00127 
00128 /*
00129  * prototypes for plan/setrefs.c
00130  */
00131 extern Plan *set_plan_references(PlannerInfo *root, Plan *plan);
00132 extern void fix_opfuncids(Node *node);
00133 extern void set_opfuncid(OpExpr *opexpr);
00134 extern void set_sa_opfuncid(ScalarArrayOpExpr *opexpr);
00135 extern void record_plan_function_dependency(PlannerInfo *root, Oid funcid);
00136 extern void extract_query_dependencies(Node *query,
00137                            List **relationOids,
00138                            List **invalItems);
00139 
00140 #endif   /* PLANMAIN_H */