PostgreSQL Source Code  git master
planmain.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * planmain.h
4  * prototypes for various files in optimizer/plan
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/optimizer/planmain.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PLANMAIN_H
15 #define PLANMAIN_H
16 
17 #include "nodes/plannodes.h"
18 #include "nodes/relation.h"
19 
20 /* possible values for force_parallel_mode */
21 typedef enum
22 {
27 
28 /* GUC parameters */
29 #define DEFAULT_CURSOR_TUPLE_FRACTION 0.1
30 extern double cursor_tuple_fraction;
31 extern int force_parallel_mode;
33 
34 /* query_planner callback to compute query_pathkeys */
35 typedef void (*query_pathkeys_callback) (PlannerInfo *root, void *extra);
36 
37 /*
38  * prototypes for plan/planmain.c
39  */
40 extern RelOptInfo *query_planner(PlannerInfo *root, List *tlist,
41  query_pathkeys_callback qp_callback, void *qp_extra);
42 
43 /*
44  * prototypes for plan/planagg.c
45  */
46 extern void preprocess_minmax_aggregates(PlannerInfo *root, List *tlist);
47 
48 /*
49  * prototypes for plan/createplan.c
50  */
51 extern Plan *create_plan(PlannerInfo *root, Path *best_path);
52 extern ForeignScan *make_foreignscan(List *qptlist, List *qpqual,
53  Index scanrelid, List *fdw_exprs, List *fdw_private,
54  List *fdw_scan_tlist, List *fdw_recheck_quals,
55  Plan *outer_plan);
56 extern Plan *materialize_finished_plan(Plan *subplan);
57 extern bool is_projection_capable_path(Path *path);
58 extern bool is_projection_capable_plan(Plan *plan);
59 
60 /* External use of these functions is deprecated: */
61 extern Sort *make_sort_from_sortclauses(List *sortcls, Plan *lefttree);
62 extern Agg *make_agg(List *tlist, List *qual,
63  AggStrategy aggstrategy, AggSplit aggsplit,
64  int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators,
65  List *groupingSets, List *chain,
66  double dNumGroups, Plan *lefttree);
67 extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount);
68 
69 /*
70  * prototypes for plan/initsplan.c
71  */
72 extern int from_collapse_limit;
73 extern int join_collapse_limit;
74 
75 extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode);
76 extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist);
77 extern void add_vars_to_targetlist(PlannerInfo *root, List *vars,
78  Relids where_needed, bool create_new_ph);
79 extern void find_lateral_references(PlannerInfo *root);
80 extern void create_lateral_join_info(PlannerInfo *root);
83  RestrictInfo *restrictinfo);
84 extern void process_implied_equality(PlannerInfo *root,
85  Oid opno,
86  Oid collation,
87  Expr *item1,
88  Expr *item2,
89  Relids qualscope,
90  Relids nullable_relids,
91  Index security_level,
92  bool below_outer_join,
93  bool both_const);
95  Oid collation,
96  Expr *item1,
97  Expr *item2,
98  Relids qualscope,
99  Relids nullable_relids,
100  Index security_level);
101 extern void match_foreign_keys_to_quals(PlannerInfo *root);
102 
103 /*
104  * prototypes for plan/analyzejoins.c
105  */
106 extern List *remove_useless_joins(PlannerInfo *root, List *joinlist);
107 extern void reduce_unique_semijoins(PlannerInfo *root);
108 extern bool query_supports_distinctness(Query *query);
109 extern bool query_is_distinct_for(Query *query, List *colnos, List *opids);
110 extern bool innerrel_is_unique(PlannerInfo *root,
111  Relids outerrelids, RelOptInfo *innerrel,
112  JoinType jointype, List *restrictlist, bool force_cache);
113 
114 /*
115  * prototypes for plan/setrefs.c
116  */
117 extern Plan *set_plan_references(PlannerInfo *root, Plan *plan);
118 extern void record_plan_function_dependency(PlannerInfo *root, Oid funcid);
119 extern void extract_query_dependencies(Node *query,
120  List **relationOids,
121  List **invalItems,
122  bool *hasRowSecurity);
123 
124 #endif /* PLANMAIN_H */
bool is_projection_capable_plan(Plan *plan)
Definition: createplan.c:6614
void distribute_restrictinfo_to_rels(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:2227
void create_lateral_join_info(PlannerInfo *root)
Definition: initsplan.c:418
void build_base_rel_tlists(PlannerInfo *root, List *final_tlist)
Definition: initsplan.c:151
Plan * create_plan(PlannerInfo *root, Path *best_path)
Definition: createplan.c:304
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount)
Definition: createplan.c:6367
void match_foreign_keys_to_quals(PlannerInfo *root)
Definition: initsplan.c:2434
bool is_projection_capable_path(Path *path)
Definition: createplan.c:6569
Agg * make_agg(List *tlist, List *qual, AggStrategy aggstrategy, AggSplit aggsplit, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, List *groupingSets, List *chain, double dNumGroups, Plan *lefttree)
Definition: createplan.c:6027
Definition: nodes.h:511
void record_plan_function_dependency(PlannerInfo *root, Oid funcid)
Definition: setrefs.c:2558
unsigned int Oid
Definition: postgres_ext.h:31
void process_implied_equality(PlannerInfo *root, Oid opno, Oid collation, Expr *item1, Expr *item2, Relids qualscope, Relids nullable_relids, Index security_level, bool below_outer_join, bool both_const)
Definition: initsplan.c:2311
ForceParallelMode
Definition: planmain.h:21
void add_base_rels_to_query(PlannerInfo *root, Node *jtnode)
Definition: initsplan.c:105
JoinType
Definition: nodes.h:675
int from_collapse_limit
Definition: initsplan.c:37
int join_collapse_limit
Definition: initsplan.c:38
void preprocess_minmax_aggregates(PlannerInfo *root, List *tlist)
Definition: planagg.c:75
int force_parallel_mode
Definition: planner.c:63
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
Definition: createplan.c:5881
bool query_supports_distinctness(Query *query)
Definition: analyzejoins.c:745
List * remove_useless_joins(PlannerInfo *root, List *joinlist)
Definition: analyzejoins.c:60
unsigned int Index
Definition: c.h:413
void(* query_pathkeys_callback)(PlannerInfo *root, void *extra)
Definition: planmain.h:35
void find_lateral_references(PlannerInfo *root)
Definition: initsplan.c:272
void extract_query_dependencies(Node *query, List **relationOids, List **invalItems, bool *hasRowSecurity)
Definition: setrefs.c:2596
void add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed, bool create_new_ph)
Definition: initsplan.c:198
double cursor_tuple_fraction
Definition: planner.c:62
Plan * materialize_finished_plan(Plan *subplan)
Definition: createplan.c:5993
AggSplit
Definition: nodes.h:759
RestrictInfo * build_implied_join_equality(Oid opno, Oid collation, Expr *item1, Expr *item2, Relids qualscope, Relids nullable_relids, Index security_level)
Definition: initsplan.c:2376
void reduce_unique_semijoins(PlannerInfo *root)
Definition: analyzejoins.c:512
AggStrategy
Definition: nodes.h:737
bool innerrel_is_unique(PlannerInfo *root, Relids outerrelids, RelOptInfo *innerrel, JoinType jointype, List *restrictlist, bool force_cache)
Definition: analyzejoins.c:970
Plan * set_plan_references(PlannerInfo *root, Plan *plan)
Definition: setrefs.c:214
bool query_is_distinct_for(Query *query, List *colnos, List *opids)
Definition: analyzejoins.c:782
ForeignScan * make_foreignscan(List *qptlist, List *qpqual, Index scanrelid, List *fdw_exprs, List *fdw_private, List *fdw_scan_tlist, List *fdw_recheck_quals, Plan *outer_plan)
Definition: createplan.c:5263
Definition: plannodes.h:780
bool parallel_leader_participation
Definition: planner.c:64
RelOptInfo * query_planner(PlannerInfo *root, List *tlist, query_pathkeys_callback qp_callback, void *qp_extra)
Definition: planmain.c:54
Definition: regcomp.c:224
Definition: pg_list.h:45
List * deconstruct_jointree(PlannerInfo *root)
Definition: initsplan.c:713
int16 AttrNumber
Definition: attnum.h:21