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-2021, 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/pathnodes.h"
18 #include "nodes/plannodes.h"
19 
20 /* GUC parameters */
21 #define DEFAULT_CURSOR_TUPLE_FRACTION 0.1
22 extern double cursor_tuple_fraction;
23 
24 /* query_planner callback to compute query_pathkeys */
25 typedef void (*query_pathkeys_callback) (PlannerInfo *root, void *extra);
26 
27 /*
28  * prototypes for plan/planmain.c
29  */
31  query_pathkeys_callback qp_callback, void *qp_extra);
32 
33 /*
34  * prototypes for plan/planagg.c
35  */
36 extern void preprocess_minmax_aggregates(PlannerInfo *root);
37 
38 /*
39  * prototypes for plan/createplan.c
40  */
41 extern Plan *create_plan(PlannerInfo *root, Path *best_path);
42 extern ForeignScan *make_foreignscan(List *qptlist, List *qpqual,
43  Index scanrelid, List *fdw_exprs, List *fdw_private,
44  List *fdw_scan_tlist, List *fdw_recheck_quals,
45  Plan *outer_plan);
46 extern Plan *change_plan_targetlist(Plan *subplan, List *tlist,
47  bool tlist_parallel_safe);
48 extern Plan *materialize_finished_plan(Plan *subplan);
49 extern bool is_projection_capable_path(Path *path);
50 extern bool is_projection_capable_plan(Plan *plan);
51 
52 /* External use of these functions is deprecated: */
53 extern Sort *make_sort_from_sortclauses(List *sortcls, Plan *lefttree);
54 extern Agg *make_agg(List *tlist, List *qual,
55  AggStrategy aggstrategy, AggSplit aggsplit,
56  int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations,
57  List *groupingSets, List *chain, double dNumGroups,
58  Size transitionSpace, Plan *lefttree);
59 extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount,
60  LimitOption limitOption, int uniqNumCols,
61  AttrNumber *uniqColIdx, Oid *uniqOperators,
62  Oid *uniqCollations);
63 
64 /*
65  * prototypes for plan/initsplan.c
66  */
67 extern int from_collapse_limit;
68 extern int join_collapse_limit;
69 
70 extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode);
71 extern void add_other_rels_to_query(PlannerInfo *root);
72 extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist);
73 extern void add_vars_to_targetlist(PlannerInfo *root, List *vars,
74  Relids where_needed, bool create_new_ph);
75 extern void find_lateral_references(PlannerInfo *root);
76 extern void create_lateral_join_info(PlannerInfo *root);
79  RestrictInfo *restrictinfo);
81  Oid opno,
82  Oid collation,
83  Expr *item1,
84  Expr *item2,
85  Relids qualscope,
86  Relids nullable_relids,
87  Index security_level,
88  bool below_outer_join,
89  bool both_const);
91  Oid opno,
92  Oid collation,
93  Expr *item1,
94  Expr *item2,
95  Relids qualscope,
96  Relids nullable_relids,
97  Index security_level);
98 extern void match_foreign_keys_to_quals(PlannerInfo *root);
99 
100 /*
101  * prototypes for plan/analyzejoins.c
102  */
103 extern List *remove_useless_joins(PlannerInfo *root, List *joinlist);
104 extern void reduce_unique_semijoins(PlannerInfo *root);
105 extern bool query_supports_distinctness(Query *query);
106 extern bool query_is_distinct_for(Query *query, List *colnos, List *opids);
107 extern bool innerrel_is_unique(PlannerInfo *root,
108  Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel,
109  JoinType jointype, List *restrictlist, bool force_cache);
110 
111 /*
112  * prototypes for plan/setrefs.c
113  */
114 extern Plan *set_plan_references(PlannerInfo *root, Plan *plan);
115 extern void record_plan_function_dependency(PlannerInfo *root, Oid funcid);
116 extern void record_plan_type_dependency(PlannerInfo *root, Oid typid);
117 extern bool extract_query_dependencies_walker(Node *node, PlannerInfo *root);
118 
119 #endif /* PLANMAIN_H */
bool is_projection_capable_plan(Plan *plan)
Definition: createplan.c:7069
void distribute_restrictinfo_to_rels(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:2175
void create_lateral_join_info(PlannerInfo *root)
Definition: initsplan.c:448
void record_plan_type_dependency(PlannerInfo *root, Oid typid)
Definition: setrefs.c:2945
void build_base_rel_tlists(PlannerInfo *root, List *final_tlist)
Definition: initsplan.c:181
Plan * create_plan(PlannerInfo *root, Path *best_path)
Definition: createplan.c:327
void match_foreign_keys_to_quals(PlannerInfo *root)
Definition: initsplan.c:2473
bool innerrel_is_unique(PlannerInfo *root, Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel, JoinType jointype, List *restrictlist, bool force_cache)
Definition: analyzejoins.c:964
bool is_projection_capable_path(Path *path)
Definition: createplan.c:7024
Definition: nodes.h:533
void record_plan_function_dependency(PlannerInfo *root, Oid funcid)
Definition: setrefs.c:2905
unsigned int Oid
Definition: postgres_ext.h:31
void preprocess_minmax_aggregates(PlannerInfo *root)
Definition: planagg.c:73
void add_base_rels_to_query(PlannerInfo *root, Node *jtnode)
Definition: initsplan.c:104
JoinType
Definition: nodes.h:700
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
Definition: createplan.c:6810
int from_collapse_limit
Definition: initsplan.c:38
RestrictInfo * 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:2263
void add_other_rels_to_query(PlannerInfo *root)
Definition: initsplan.c:142
int join_collapse_limit
Definition: initsplan.c:39
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
Definition: createplan.c:6300
Agg * make_agg(List *tlist, List *qual, AggStrategy aggstrategy, AggSplit aggsplit, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations, List *groupingSets, List *chain, double dNumGroups, Size transitionSpace, Plan *lefttree)
Definition: createplan.c:6446
bool query_supports_distinctness(Query *query)
Definition: analyzejoins.c:738
List * remove_useless_joins(PlannerInfo *root, List *joinlist)
Definition: analyzejoins.c:61
bool extract_query_dependencies_walker(Node *node, PlannerInfo *root)
Definition: setrefs.c:3022
unsigned int Index
Definition: c.h:549
RestrictInfo * build_implied_join_equality(PlannerInfo *root, Oid opno, Oid collation, Expr *item1, Expr *item2, Relids qualscope, Relids nullable_relids, Index security_level)
Definition: initsplan.c:2413
void(* query_pathkeys_callback)(PlannerInfo *root, void *extra)
Definition: planmain.h:25
void find_lateral_references(PlannerInfo *root)
Definition: initsplan.c:302
void add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed, bool create_new_ph)
Definition: initsplan.c:228
double cursor_tuple_fraction
Definition: planner.c:69
Plan * materialize_finished_plan(Plan *subplan)
Definition: createplan.c:6412
size_t Size
Definition: c.h:540
AggSplit
Definition: nodes.h:784
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
Definition: createplan.c:1966
LimitOption
Definition: nodes.h:839
void reduce_unique_semijoins(PlannerInfo *root)
Definition: analyzejoins.c:508
AggStrategy
Definition: nodes.h:762
Plan * set_plan_references(PlannerInfo *root, Plan *plan)
Definition: setrefs.c:250
bool query_is_distinct_for(Query *query, List *colnos, List *opids)
Definition: analyzejoins.c:775
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:5609
Definition: plannodes.h:829
Definition: regcomp.c:238
Definition: pg_list.h:50
List * deconstruct_jointree(PlannerInfo *root)
Definition: initsplan.c:685
int16 AttrNumber
Definition: attnum.h:21
RelOptInfo * query_planner(PlannerInfo *root, query_pathkeys_callback qp_callback, void *qp_extra)
Definition: planmain.c:55