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-2024, 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
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  */
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);
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  */
69 
70 extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode);
72 extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist);
74  Relids where_needed);
79  RestrictInfo *restrictinfo);
81  RestrictInfo *restrictinfo);
83  RestrictInfo *restrictinfo);
85  Oid opno,
86  Oid collation,
87  Expr *item1,
88  Expr *item2,
89  Relids qualscope,
90  Index security_level,
91  bool both_const);
93  Oid opno,
94  Oid collation,
95  Expr *item1,
96  Expr *item2,
97  Relids qualscope,
98  Index security_level);
100 
101 /*
102  * prototypes for plan/analyzejoins.c
103  */
104 extern List *remove_useless_joins(PlannerInfo *root, List *joinlist);
106 extern bool query_supports_distinctness(Query *query);
107 extern bool query_is_distinct_for(Query *query, List *colnos, List *opids);
108 extern bool innerrel_is_unique(PlannerInfo *root,
109  Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel,
110  JoinType jointype, List *restrictlist, bool force_cache);
111 
112 /*
113  * prototypes for plan/setrefs.c
114  */
118  Aggref *aggref);
120 extern void record_plan_type_dependency(PlannerInfo *root, Oid typid);
122 
123 #endif /* PLANMAIN_H */
int16 AttrNumber
Definition: attnum.h:21
#define PGDLLIMPORT
Definition: c.h:1316
unsigned int Index
Definition: c.h:614
size_t Size
Definition: c.h:605
AggStrategy
Definition: nodes.h:352
AggSplit
Definition: nodes.h:374
LimitOption
Definition: nodes.h:429
JoinType
Definition: nodes.h:288
#define plan(x)
Definition: pg_regress.c:162
List * remove_useless_joins(PlannerInfo *root, List *joinlist)
Definition: analyzejoins.c:64
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
Definition: createplan.c:6415
void record_plan_type_dependency(PlannerInfo *root, Oid typid)
Definition: setrefs.c:3500
void preprocess_minmax_aggregates(PlannerInfo *root)
Definition: planagg.c:72
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:6593
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:740
PGDLLIMPORT int join_collapse_limit
Definition: initsplan.c:39
Plan * create_plan(PlannerInfo *root, Path *best_path)
Definition: createplan.c:337
void distribute_restrictinfo_to_rels(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:2836
void record_plan_function_dependency(PlannerInfo *root, Oid funcid)
Definition: setrefs.c:3460
bool is_projection_capable_path(Path *path)
Definition: createplan.c:7207
void match_foreign_keys_to_quals(PlannerInfo *root)
Definition: initsplan.c:3169
void find_lateral_references(PlannerInfo *root)
Definition: initsplan.c:358
void(* query_pathkeys_callback)(PlannerInfo *root, void *extra)
Definition: planmain.h:25
bool query_is_distinct_for(Query *query, List *colnos, List *opids)
Definition: analyzejoins.c:995
void add_base_rels_to_query(PlannerInfo *root, Node *jtnode)
Definition: initsplan.c:157
void build_base_rel_tlists(PlannerInfo *root, List *final_tlist)
Definition: initsplan.c:234
bool trivial_subqueryscan(SubqueryScan *plan)
Definition: setrefs.c:1464
bool restriction_is_always_true(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:2732
bool is_projection_capable_plan(Plan *plan)
Definition: createplan.c:7257
void add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed)
Definition: initsplan.c:279
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:5822
bool restriction_is_always_false(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:2781
RestrictInfo * build_implied_join_equality(PlannerInfo *root, Oid opno, Oid collation, Expr *item1, Expr *item2, Relids qualscope, Index security_level)
Definition: initsplan.c:3060
bool query_supports_distinctness(Query *query)
Definition: analyzejoins.c:958
PGDLLIMPORT double cursor_tuple_fraction
Definition: planner.c:66
Plan * materialize_finished_plan(Plan *subplan)
Definition: createplan.c:6527
RelOptInfo * query_planner(PlannerInfo *root, query_pathkeys_callback qp_callback, void *qp_extra)
Definition: planmain.c:54
Plan * set_plan_references(PlannerInfo *root, Plan *plan)
Definition: setrefs.c:287
void add_other_rels_to_query(PlannerInfo *root)
Definition: initsplan.c:195
bool extract_query_dependencies_walker(Node *node, PlannerInfo *context)
Definition: setrefs.c:3577
void reduce_unique_semijoins(PlannerInfo *root)
Definition: analyzejoins.c:730
void create_lateral_join_info(PlannerInfo *root)
Definition: initsplan.c:501
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
Definition: createplan.c:2152
Param * find_minmax_agg_replacement_param(PlannerInfo *root, Aggref *aggref)
Definition: setrefs.c:3427
PGDLLIMPORT int from_collapse_limit
Definition: initsplan.c:38
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:2921
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
Definition: createplan.c:6960
unsigned int Oid
Definition: postgres_ext.h:31
tree context
Definition: radixtree.h:1833
tree ctl root
Definition: radixtree.h:1884
Definition: plannodes.h:997
Definition: pg_list.h:54
Definition: nodes.h:129
Definition: regcomp.c:281