PostgreSQL Source Code  git master
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-2023, 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
17 #include "nodes/pathnodes.h"
18 #include "nodes/plannodes.h"
20 /* GUC parameters */
25 /* query_planner callback to compute query_pathkeys */
26 typedef void (*query_pathkeys_callback) (PlannerInfo *root, void *extra);
28 /*
29  * prototypes for plan/planmain.c
30  */
32  query_pathkeys_callback qp_callback, void *qp_extra);
34 /*
35  * prototypes for plan/planagg.c
36  */
37 extern void preprocess_minmax_aggregates(PlannerInfo *root);
39 /*
40  * prototypes for plan/createplan.c
41  */
42 extern Plan *create_plan(PlannerInfo *root, Path *best_path);
43 extern ForeignScan *make_foreignscan(List *qptlist, List *qpqual,
44  Index scanrelid, List *fdw_exprs, List *fdw_private,
45  List *fdw_scan_tlist, List *fdw_recheck_quals,
46  Plan *outer_plan);
47 extern Plan *change_plan_targetlist(Plan *subplan, List *tlist,
48  bool tlist_parallel_safe);
49 extern Plan *materialize_finished_plan(Plan *subplan);
50 extern bool is_projection_capable_path(Path *path);
53 /* External use of these functions is deprecated: */
54 extern Sort *make_sort_from_sortclauses(List *sortcls, Plan *lefttree);
55 extern Agg *make_agg(List *tlist, List *qual,
56  AggStrategy aggstrategy, AggSplit aggsplit,
57  int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations,
58  List *groupingSets, List *chain, double dNumGroups,
59  Size transitionSpace, Plan *lefttree);
60 extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount,
61  LimitOption limitOption, int uniqNumCols,
62  AttrNumber *uniqColIdx, Oid *uniqOperators,
63  Oid *uniqCollations);
65 /*
66  * prototypes for plan/initsplan.c
67  */
71 extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode);
72 extern void add_other_rels_to_query(PlannerInfo *root);
73 extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist);
74 extern void add_vars_to_targetlist(PlannerInfo *root, List *vars,
75  Relids where_needed);
76 extern void find_lateral_references(PlannerInfo *root);
77 extern void create_lateral_join_info(PlannerInfo *root);
80  RestrictInfo *restrictinfo);
82  Oid opno,
83  Oid collation,
84  Expr *item1,
85  Expr *item2,
86  Relids qualscope,
87  Index security_level,
88  bool both_const);
90  Oid opno,
91  Oid collation,
92  Expr *item1,
93  Expr *item2,
94  Relids qualscope,
95  Index security_level);
96 extern void match_foreign_keys_to_quals(PlannerInfo *root);
98 /*
99  * prototypes for plan/analyzejoins.c
100  */
101 extern List *remove_useless_joins(PlannerInfo *root, List *joinlist);
102 extern void reduce_unique_semijoins(PlannerInfo *root);
103 extern bool query_supports_distinctness(Query *query);
104 extern bool query_is_distinct_for(Query *query, List *colnos, List *opids);
105 extern bool innerrel_is_unique(PlannerInfo *root,
106  Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel,
107  JoinType jointype, List *restrictlist, bool force_cache);
108 extern bool innerrel_is_unique_ext(PlannerInfo *root, Relids joinrelids,
109  Relids outerrelids, RelOptInfo *innerrel,
110  JoinType jointype, List *restrictlist,
111  bool force_cache, List **uclauses);
112 extern List *remove_useless_self_joins(PlannerInfo *root, List *jointree);
114 /*
115  * prototypes for plan/setrefs.c
116  */
117 extern Plan *set_plan_references(PlannerInfo *root, Plan *plan);
120  Aggref *aggref);
121 extern void record_plan_function_dependency(PlannerInfo *root, Oid funcid);
122 extern void record_plan_type_dependency(PlannerInfo *root, Oid typid);
123 extern bool extract_query_dependencies_walker(Node *node, PlannerInfo *context);
125 #endif /* PLANMAIN_H */
int16 AttrNumber
Definition: attnum.h:21
Definition: c.h:1326
unsigned int Index
Definition: c.h:603
size_t Size
Definition: c.h:594
Definition: nodes.h:363
Definition: nodes.h:385
Definition: nodes.h:440
Definition: nodes.h:299
#define plan(x)
Definition: pg_regress.c:162
List * remove_useless_joins(PlannerInfo *root, List *joinlist)
Definition: analyzejoins.c:94
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
Definition: createplan.c:6387
void record_plan_type_dependency(PlannerInfo *root, Oid typid)
Definition: setrefs.c:3485
void preprocess_minmax_aggregates(PlannerInfo *root)
Definition: planagg.c:73
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:6565
bool innerrel_is_unique(PlannerInfo *root, Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel, JoinType jointype, List *restrictlist, bool force_cache)
List * deconstruct_jointree(PlannerInfo *root)
Definition: initsplan.c:741
PGDLLIMPORT int join_collapse_limit
Definition: initsplan.c:40
PGDLLIMPORT bool enable_self_join_removal
Definition: analyzejoins.c:55
Plan * create_plan(PlannerInfo *root, Path *best_path)
Definition: createplan.c:335
void distribute_restrictinfo_to_rels(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:2631
void record_plan_function_dependency(PlannerInfo *root, Oid funcid)
Definition: setrefs.c:3445
bool is_projection_capable_path(Path *path)
Definition: createplan.c:7177
void match_foreign_keys_to_quals(PlannerInfo *root)
Definition: initsplan.c:2972
List * remove_useless_self_joins(PlannerInfo *root, List *jointree)
void find_lateral_references(PlannerInfo *root)
Definition: initsplan.c:359
void(* query_pathkeys_callback)(PlannerInfo *root, void *extra)
Definition: planmain.h:26
bool query_is_distinct_for(Query *query, List *colnos, List *opids)
void add_base_rels_to_query(PlannerInfo *root, Node *jtnode)
Definition: initsplan.c:158
void build_base_rel_tlists(PlannerInfo *root, List *final_tlist)
Definition: initsplan.c:235
bool trivial_subqueryscan(SubqueryScan *plan)
Definition: setrefs.c:1449
bool is_projection_capable_plan(Plan *plan)
Definition: createplan.c:7227
void add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed)
Definition: initsplan.c:280
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:5794
RestrictInfo * build_implied_join_equality(PlannerInfo *root, Oid opno, Oid collation, Expr *item1, Expr *item2, Relids qualscope, Index security_level)
Definition: initsplan.c:2863
bool query_supports_distinctness(Query *query)
PGDLLIMPORT double cursor_tuple_fraction
Definition: planner.c:72
Plan * materialize_finished_plan(Plan *subplan)
Definition: createplan.c:6499
RelOptInfo * query_planner(PlannerInfo *root, query_pathkeys_callback qp_callback, void *qp_extra)
Definition: planmain.c:55
Plan * set_plan_references(PlannerInfo *root, Plan *plan)
Definition: setrefs.c:288
void add_other_rels_to_query(PlannerInfo *root)
Definition: initsplan.c:196
bool innerrel_is_unique_ext(PlannerInfo *root, Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel, JoinType jointype, List *restrictlist, bool force_cache, List **uclauses)
bool extract_query_dependencies_walker(Node *node, PlannerInfo *context)
Definition: setrefs.c:3562
void reduce_unique_semijoins(PlannerInfo *root)
Definition: analyzejoins.c:774
void create_lateral_join_info(PlannerInfo *root)
Definition: initsplan.c:502
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
Definition: createplan.c:2150
Param * find_minmax_agg_replacement_param(PlannerInfo *root, Aggref *aggref)
Definition: setrefs.c:3412
PGDLLIMPORT int from_collapse_limit
Definition: initsplan.c:39
RestrictInfo * process_implied_equality(PlannerInfo *root, Oid opno, Oid collation, Expr *item1, Expr *item2, Relids qualscope, Index security_level, bool both_const)
Definition: initsplan.c:2724
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
Definition: createplan.c:6932
unsigned int Oid
Definition: postgres_ext.h:31
Definition: plannodes.h:995
Definition: pg_list.h:54
Definition: nodes.h:129
Definition: regcomp.c:281