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-2025, 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
24
25/* query_planner callback to compute query_pathkeys */
26typedef void (*query_pathkeys_callback) (PlannerInfo *root, void *extra);
27
28/*
29 * prototypes for plan/planmain.c
30 */
32 query_pathkeys_callback qp_callback, void *qp_extra);
33
34/*
35 * prototypes for plan/planagg.c
36 */
38
39/*
40 * prototypes for plan/createplan.c
41 */
42extern Plan *create_plan(PlannerInfo *root, Path *best_path);
43extern 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);
47extern Plan *change_plan_targetlist(Plan *subplan, List *tlist,
48 bool tlist_parallel_safe);
49extern Plan *materialize_finished_plan(Plan *subplan);
50extern bool is_projection_capable_path(Path *path);
52
53/* External use of these functions is deprecated: */
54extern Sort *make_sort_from_sortclauses(List *sortcls, Plan *lefttree);
55extern 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, Cardinality numGroups,
59 Size transitionSpace, Plan *lefttree);
60extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount,
61 LimitOption limitOption, int uniqNumCols,
62 AttrNumber *uniqColIdx, Oid *uniqOperators,
63 Oid *uniqCollations);
64
65/*
66 * prototypes for plan/initsplan.c
67 */
70
71extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode);
73extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist);
75 Relids where_needed);
77 Relids where_needed);
85 RestrictInfo *restrictinfo);
87 RestrictInfo *restrictinfo);
89 RestrictInfo *restrictinfo);
91 Oid opno,
92 Oid collation,
93 Expr *item1,
94 Expr *item2,
95 Relids qualscope,
96 Index security_level,
97 bool both_const);
99 Oid opno,
100 Oid collation,
101 Expr *item1,
102 Expr *item2,
103 Relids qualscope,
104 Index security_level);
107
108/*
109 * prototypes for plan/analyzejoins.c
110 */
111extern List *remove_useless_joins(PlannerInfo *root, List *joinlist);
113extern bool query_supports_distinctness(Query *query);
114extern bool query_is_distinct_for(Query *query, List *colnos, List *opids);
116 Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel,
117 JoinType jointype, List *restrictlist, bool force_cache);
118extern bool innerrel_is_unique_ext(PlannerInfo *root, Relids joinrelids,
119 Relids outerrelids, RelOptInfo *innerrel,
120 JoinType jointype, List *restrictlist,
121 bool force_cache, List **extra_clauses);
123
124/*
125 * prototypes for plan/setrefs.c
126 */
130 Aggref *aggref);
133extern bool extract_query_dependencies_walker(Node *node, PlannerInfo *context);
134
135#endif /* PLANMAIN_H */
int16 AttrNumber
Definition: attnum.h:21
#define PGDLLIMPORT
Definition: c.h:1310
unsigned int Index
Definition: c.h:624
size_t Size
Definition: c.h:615
double Cardinality
Definition: nodes.h:262
AggStrategy
Definition: nodes.h:363
AggSplit
Definition: nodes.h:385
LimitOption
Definition: nodes.h:440
JoinType
Definition: nodes.h:298
#define plan(x)
Definition: pg_regress.c:161
void record_plan_type_dependency(PlannerInfo *root, Oid typid)
Definition: setrefs.c:3615
void preprocess_minmax_aggregates(PlannerInfo *root)
Definition: planagg.c:74
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
Definition: createplan.c:6389
bool innerrel_is_unique(PlannerInfo *root, Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel, JoinType jointype, List *restrictlist, bool force_cache)
void rebuild_lateral_attr_needed(PlannerInfo *root)
Definition: initsplan.c:1176
PGDLLIMPORT bool enable_self_join_elimination
Definition: analyzejoins.c:53
Plan * set_plan_references(PlannerInfo *root, Plan *plan)
Definition: setrefs.c:288
PGDLLIMPORT int join_collapse_limit
Definition: initsplan.c:41
void distribute_restrictinfo_to_rels(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:3560
void record_plan_function_dependency(PlannerInfo *root, Oid funcid)
Definition: setrefs.c:3575
bool is_projection_capable_path(Path *path)
Definition: createplan.c:7217
void match_foreign_keys_to_quals(PlannerInfo *root)
Definition: initsplan.c:3964
void find_lateral_references(PlannerInfo *root)
Definition: initsplan.c:1027
void(* query_pathkeys_callback)(PlannerInfo *root, void *extra)
Definition: planmain.h:26
bool query_is_distinct_for(Query *query, List *colnos, List *opids)
void remove_useless_groupby_columns(PlannerInfo *root)
Definition: initsplan.c:419
RelOptInfo * query_planner(PlannerInfo *root, query_pathkeys_callback qp_callback, void *qp_extra)
Definition: planmain.c:54
void add_base_rels_to_query(PlannerInfo *root, Node *jtnode)
Definition: initsplan.c:165
void build_base_rel_tlists(PlannerInfo *root, List *final_tlist)
Definition: initsplan.c:242
bool trivial_subqueryscan(SubqueryScan *plan)
Definition: setrefs.c:1497
List * remove_useless_joins(PlannerInfo *root, List *joinlist)
Definition: analyzejoins.c:90
bool restriction_is_always_true(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:3424
bool is_projection_capable_plan(Plan *plan)
Definition: createplan.c:7267
RestrictInfo * build_implied_join_equality(PlannerInfo *root, Oid opno, Oid collation, Expr *item1, Expr *item2, Relids qualscope, Index security_level)
Definition: initsplan.c:3789
bool innerrel_is_unique_ext(PlannerInfo *root, Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel, JoinType jointype, List *restrictlist, bool force_cache, List **extra_clauses)
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
Definition: createplan.c:6893
void add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed)
Definition: initsplan.c:289
Param * find_minmax_agg_replacement_param(PlannerInfo *root, Aggref *aggref)
Definition: setrefs.c:3542
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:5795
bool restriction_is_always_false(PlannerInfo *root, RestrictInfo *restrictinfo)
Definition: initsplan.c:3489
List * deconstruct_jointree(PlannerInfo *root)
Definition: initsplan.c:1453
List * remove_useless_self_joins(PlannerInfo *root, List *joinlist)
void rebuild_joinclause_attr_needed(PlannerInfo *root)
Definition: initsplan.c:3892
bool query_supports_distinctness(Query *query)
void setup_eager_aggregation(PlannerInfo *root)
Definition: initsplan.c:644
PGDLLIMPORT double cursor_tuple_fraction
Definition: planner.c:68
void add_other_rels_to_query(PlannerInfo *root)
Definition: initsplan.c:203
Plan * materialize_finished_plan(Plan *subplan)
Definition: createplan.c:6501
bool extract_query_dependencies_walker(Node *node, PlannerInfo *context)
Definition: setrefs.c:3692
Agg * make_agg(List *tlist, List *qual, AggStrategy aggstrategy, AggSplit aggsplit, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations, List *groupingSets, List *chain, Cardinality numGroups, Size transitionSpace, Plan *lefttree)
Definition: createplan.c:6574
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
Definition: createplan.c:1991
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:3645
void reduce_unique_semijoins(PlannerInfo *root)
Definition: analyzejoins.c:844
void create_lateral_join_info(PlannerInfo *root)
Definition: initsplan.c:1214
PGDLLIMPORT int from_collapse_limit
Definition: initsplan.c:40
void add_vars_to_attr_needed(PlannerInfo *root, List *vars, Relids where_needed)
Definition: initsplan.c:360
Plan * create_plan(PlannerInfo *root, Path *best_path)
Definition: createplan.c:340
unsigned int Oid
Definition: postgres_ext.h:32
tree ctl root
Definition: radixtree.h:1857
Definition: pg_list.h:54
Definition: nodes.h:135
Definition: regcomp.c:282