1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * planmain.h |
4 | * prototypes for various files in optimizer/plan |
5 | * |
6 | * |
7 | * Portions Copyright (c) 1996-2019, 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 *); |
26 | |
27 | /* |
28 | * prototypes for plan/planmain.c |
29 | */ |
30 | extern RelOptInfo *query_planner(PlannerInfo *root, |
31 | query_pathkeys_callback qp_callback, void *); |
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, |
58 | double dNumGroups, Plan *lefttree); |
59 | extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount); |
60 | |
61 | /* |
62 | * prototypes for plan/initsplan.c |
63 | */ |
64 | extern int from_collapse_limit; |
65 | extern int join_collapse_limit; |
66 | |
67 | extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode); |
68 | extern void add_other_rels_to_query(PlannerInfo *root); |
69 | extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist); |
70 | extern void add_vars_to_targetlist(PlannerInfo *root, List *vars, |
71 | Relids where_needed, bool create_new_ph); |
72 | extern void find_lateral_references(PlannerInfo *root); |
73 | extern void create_lateral_join_info(PlannerInfo *root); |
74 | extern List *deconstruct_jointree(PlannerInfo *root); |
75 | extern void distribute_restrictinfo_to_rels(PlannerInfo *root, |
76 | RestrictInfo *restrictinfo); |
77 | extern void process_implied_equality(PlannerInfo *root, |
78 | Oid opno, |
79 | Oid collation, |
80 | Expr *item1, |
81 | Expr *item2, |
82 | Relids qualscope, |
83 | Relids nullable_relids, |
84 | Index security_level, |
85 | bool below_outer_join, |
86 | bool both_const); |
87 | extern RestrictInfo *build_implied_join_equality(Oid opno, |
88 | Oid collation, |
89 | Expr *item1, |
90 | Expr *item2, |
91 | Relids qualscope, |
92 | Relids nullable_relids, |
93 | Index security_level); |
94 | extern void match_foreign_keys_to_quals(PlannerInfo *root); |
95 | |
96 | /* |
97 | * prototypes for plan/analyzejoins.c |
98 | */ |
99 | extern List *remove_useless_joins(PlannerInfo *root, List *joinlist); |
100 | extern void reduce_unique_semijoins(PlannerInfo *root); |
101 | extern bool query_supports_distinctness(Query *query); |
102 | extern bool query_is_distinct_for(Query *query, List *colnos, List *opids); |
103 | extern bool innerrel_is_unique(PlannerInfo *root, |
104 | Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel, |
105 | JoinType jointype, List *restrictlist, bool force_cache); |
106 | |
107 | /* |
108 | * prototypes for plan/setrefs.c |
109 | */ |
110 | extern Plan *set_plan_references(PlannerInfo *root, Plan *plan); |
111 | extern void record_plan_function_dependency(PlannerInfo *root, Oid funcid); |
112 | extern void record_plan_type_dependency(PlannerInfo *root, Oid typid); |
113 | extern bool (Node *node, PlannerInfo *root); |
114 | |
115 | #endif /* PLANMAIN_H */ |
116 | |