1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * pathnode.h |
4 | * prototypes for pathnode.c, relnode.c. |
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/pathnode.h |
11 | * |
12 | *------------------------------------------------------------------------- |
13 | */ |
14 | #ifndef PATHNODE_H |
15 | #define PATHNODE_H |
16 | |
17 | #include "nodes/bitmapset.h" |
18 | #include "nodes/pathnodes.h" |
19 | |
20 | |
21 | /* |
22 | * prototypes for pathnode.c |
23 | */ |
24 | extern int compare_path_costs(Path *path1, Path *path2, |
25 | CostSelector criterion); |
26 | extern int compare_fractional_path_costs(Path *path1, Path *path2, |
27 | double fraction); |
28 | extern void set_cheapest(RelOptInfo *parent_rel); |
29 | extern void add_path(RelOptInfo *parent_rel, Path *new_path); |
30 | extern bool add_path_precheck(RelOptInfo *parent_rel, |
31 | Cost startup_cost, Cost total_cost, |
32 | List *pathkeys, Relids required_outer); |
33 | extern void add_partial_path(RelOptInfo *parent_rel, Path *new_path); |
34 | extern bool add_partial_path_precheck(RelOptInfo *parent_rel, |
35 | Cost total_cost, List *pathkeys); |
36 | |
37 | extern Path *create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, |
38 | Relids required_outer, int parallel_workers); |
39 | extern Path *create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, |
40 | Relids required_outer); |
41 | extern IndexPath *create_index_path(PlannerInfo *root, |
42 | IndexOptInfo *index, |
43 | List *indexclauses, |
44 | List *indexorderbys, |
45 | List *indexorderbycols, |
46 | List *pathkeys, |
47 | ScanDirection indexscandir, |
48 | bool indexonly, |
49 | Relids required_outer, |
50 | double loop_count, |
51 | bool partial_path); |
52 | extern BitmapHeapPath *create_bitmap_heap_path(PlannerInfo *root, |
53 | RelOptInfo *rel, |
54 | Path *bitmapqual, |
55 | Relids required_outer, |
56 | double loop_count, |
57 | int parallel_degree); |
58 | extern BitmapAndPath *create_bitmap_and_path(PlannerInfo *root, |
59 | RelOptInfo *rel, |
60 | List *bitmapquals); |
61 | extern BitmapOrPath *create_bitmap_or_path(PlannerInfo *root, |
62 | RelOptInfo *rel, |
63 | List *bitmapquals); |
64 | extern TidPath *create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, |
65 | List *tidquals, Relids required_outer); |
66 | extern AppendPath *create_append_path(PlannerInfo *root, RelOptInfo *rel, |
67 | List *subpaths, List *partial_subpaths, |
68 | List *pathkeys, Relids required_outer, |
69 | int parallel_workers, bool parallel_aware, |
70 | List *partitioned_rels, double rows); |
71 | extern MergeAppendPath *create_merge_append_path(PlannerInfo *root, |
72 | RelOptInfo *rel, |
73 | List *subpaths, |
74 | List *pathkeys, |
75 | Relids required_outer, |
76 | List *partitioned_rels); |
77 | extern GroupResultPath *create_group_result_path(PlannerInfo *root, |
78 | RelOptInfo *rel, |
79 | PathTarget *target, |
80 | List *havingqual); |
81 | extern MaterialPath *create_material_path(RelOptInfo *rel, Path *subpath); |
82 | extern UniquePath *create_unique_path(PlannerInfo *root, RelOptInfo *rel, |
83 | Path *subpath, SpecialJoinInfo *sjinfo); |
84 | extern GatherPath *create_gather_path(PlannerInfo *root, |
85 | RelOptInfo *rel, Path *subpath, PathTarget *target, |
86 | Relids required_outer, double *rows); |
87 | extern GatherMergePath *create_gather_merge_path(PlannerInfo *root, |
88 | RelOptInfo *rel, |
89 | Path *subpath, |
90 | PathTarget *target, |
91 | List *pathkeys, |
92 | Relids required_outer, |
93 | double *rows); |
94 | extern SubqueryScanPath *create_subqueryscan_path(PlannerInfo *root, |
95 | RelOptInfo *rel, Path *subpath, |
96 | List *pathkeys, Relids required_outer); |
97 | extern Path *create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, |
98 | List *pathkeys, Relids required_outer); |
99 | extern Path *create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, |
100 | Relids required_outer); |
101 | extern Path *create_tablefuncscan_path(PlannerInfo *root, RelOptInfo *rel, |
102 | Relids required_outer); |
103 | extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, |
104 | Relids required_outer); |
105 | extern Path *create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel, |
106 | Relids required_outer); |
107 | extern Path *create_resultscan_path(PlannerInfo *root, RelOptInfo *rel, |
108 | Relids required_outer); |
109 | extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, |
110 | Relids required_outer); |
111 | extern ForeignPath *create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, |
112 | PathTarget *target, |
113 | double rows, Cost startup_cost, Cost total_cost, |
114 | List *pathkeys, |
115 | Relids required_outer, |
116 | Path *fdw_outerpath, |
117 | List *fdw_private); |
118 | extern ForeignPath *create_foreign_join_path(PlannerInfo *root, RelOptInfo *rel, |
119 | PathTarget *target, |
120 | double rows, Cost startup_cost, Cost total_cost, |
121 | List *pathkeys, |
122 | Relids required_outer, |
123 | Path *fdw_outerpath, |
124 | List *fdw_private); |
125 | extern ForeignPath *create_foreign_upper_path(PlannerInfo *root, RelOptInfo *rel, |
126 | PathTarget *target, |
127 | double rows, Cost startup_cost, Cost total_cost, |
128 | List *pathkeys, |
129 | Path *fdw_outerpath, |
130 | List *fdw_private); |
131 | |
132 | extern Relids calc_nestloop_required_outer(Relids outerrelids, |
133 | Relids outer_paramrels, |
134 | Relids innerrelids, |
135 | Relids inner_paramrels); |
136 | extern Relids calc_non_nestloop_required_outer(Path *outer_path, Path *inner_path); |
137 | |
138 | extern NestPath *create_nestloop_path(PlannerInfo *root, |
139 | RelOptInfo *joinrel, |
140 | JoinType jointype, |
141 | JoinCostWorkspace *workspace, |
142 | JoinPathExtraData *, |
143 | Path *outer_path, |
144 | Path *inner_path, |
145 | List *restrict_clauses, |
146 | List *pathkeys, |
147 | Relids required_outer); |
148 | |
149 | extern MergePath *create_mergejoin_path(PlannerInfo *root, |
150 | RelOptInfo *joinrel, |
151 | JoinType jointype, |
152 | JoinCostWorkspace *workspace, |
153 | JoinPathExtraData *, |
154 | Path *outer_path, |
155 | Path *inner_path, |
156 | List *restrict_clauses, |
157 | List *pathkeys, |
158 | Relids required_outer, |
159 | List *mergeclauses, |
160 | List *outersortkeys, |
161 | List *innersortkeys); |
162 | |
163 | extern HashPath *create_hashjoin_path(PlannerInfo *root, |
164 | RelOptInfo *joinrel, |
165 | JoinType jointype, |
166 | JoinCostWorkspace *workspace, |
167 | JoinPathExtraData *, |
168 | Path *outer_path, |
169 | Path *inner_path, |
170 | bool parallel_hash, |
171 | List *restrict_clauses, |
172 | Relids required_outer, |
173 | List *hashclauses); |
174 | |
175 | extern ProjectionPath *create_projection_path(PlannerInfo *root, |
176 | RelOptInfo *rel, |
177 | Path *subpath, |
178 | PathTarget *target); |
179 | extern Path *apply_projection_to_path(PlannerInfo *root, |
180 | RelOptInfo *rel, |
181 | Path *path, |
182 | PathTarget *target); |
183 | extern ProjectSetPath *create_set_projection_path(PlannerInfo *root, |
184 | RelOptInfo *rel, |
185 | Path *subpath, |
186 | PathTarget *target); |
187 | extern SortPath *create_sort_path(PlannerInfo *root, |
188 | RelOptInfo *rel, |
189 | Path *subpath, |
190 | List *pathkeys, |
191 | double limit_tuples); |
192 | extern GroupPath *create_group_path(PlannerInfo *root, |
193 | RelOptInfo *rel, |
194 | Path *subpath, |
195 | List *groupClause, |
196 | List *qual, |
197 | double numGroups); |
198 | extern UpperUniquePath *create_upper_unique_path(PlannerInfo *root, |
199 | RelOptInfo *rel, |
200 | Path *subpath, |
201 | int numCols, |
202 | double numGroups); |
203 | extern AggPath *create_agg_path(PlannerInfo *root, |
204 | RelOptInfo *rel, |
205 | Path *subpath, |
206 | PathTarget *target, |
207 | AggStrategy aggstrategy, |
208 | AggSplit aggsplit, |
209 | List *groupClause, |
210 | List *qual, |
211 | const AggClauseCosts *aggcosts, |
212 | double numGroups); |
213 | extern GroupingSetsPath *create_groupingsets_path(PlannerInfo *root, |
214 | RelOptInfo *rel, |
215 | Path *subpath, |
216 | List *having_qual, |
217 | AggStrategy aggstrategy, |
218 | List *rollups, |
219 | const AggClauseCosts *agg_costs, |
220 | double numGroups); |
221 | extern MinMaxAggPath *create_minmaxagg_path(PlannerInfo *root, |
222 | RelOptInfo *rel, |
223 | PathTarget *target, |
224 | List *mmaggregates, |
225 | List *quals); |
226 | extern WindowAggPath *create_windowagg_path(PlannerInfo *root, |
227 | RelOptInfo *rel, |
228 | Path *subpath, |
229 | PathTarget *target, |
230 | List *windowFuncs, |
231 | WindowClause *winclause); |
232 | extern SetOpPath *create_setop_path(PlannerInfo *root, |
233 | RelOptInfo *rel, |
234 | Path *subpath, |
235 | SetOpCmd cmd, |
236 | SetOpStrategy strategy, |
237 | List *distinctList, |
238 | AttrNumber flagColIdx, |
239 | int firstFlag, |
240 | double numGroups, |
241 | double outputRows); |
242 | extern RecursiveUnionPath *create_recursiveunion_path(PlannerInfo *root, |
243 | RelOptInfo *rel, |
244 | Path *leftpath, |
245 | Path *rightpath, |
246 | PathTarget *target, |
247 | List *distinctList, |
248 | int wtParam, |
249 | double numGroups); |
250 | extern LockRowsPath *create_lockrows_path(PlannerInfo *root, RelOptInfo *rel, |
251 | Path *subpath, List *rowMarks, int epqParam); |
252 | extern ModifyTablePath *create_modifytable_path(PlannerInfo *root, |
253 | RelOptInfo *rel, |
254 | CmdType operation, bool canSetTag, |
255 | Index nominalRelation, Index rootRelation, |
256 | bool partColsUpdated, |
257 | List *resultRelations, List *subpaths, |
258 | List *subroots, |
259 | List *withCheckOptionLists, List *returningLists, |
260 | List *rowMarks, OnConflictExpr *onconflict, |
261 | int epqParam); |
262 | extern LimitPath *create_limit_path(PlannerInfo *root, RelOptInfo *rel, |
263 | Path *subpath, |
264 | Node *limitOffset, Node *limitCount, |
265 | int64 offset_est, int64 count_est); |
266 | extern void adjust_limit_rows_costs(double *rows, |
267 | Cost *startup_cost, Cost *total_cost, |
268 | int64 offset_est, int64 count_est); |
269 | |
270 | extern Path *reparameterize_path(PlannerInfo *root, Path *path, |
271 | Relids required_outer, |
272 | double loop_count); |
273 | extern Path *reparameterize_path_by_child(PlannerInfo *root, Path *path, |
274 | RelOptInfo *child_rel); |
275 | |
276 | /* |
277 | * prototypes for relnode.c |
278 | */ |
279 | extern void setup_simple_rel_arrays(PlannerInfo *root); |
280 | extern void setup_append_rel_array(PlannerInfo *root); |
281 | extern void expand_planner_arrays(PlannerInfo *root, int add_size); |
282 | extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid, |
283 | RelOptInfo *parent); |
284 | extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid); |
285 | extern RelOptInfo *find_join_rel(PlannerInfo *root, Relids relids); |
286 | extern RelOptInfo *build_join_rel(PlannerInfo *root, |
287 | Relids joinrelids, |
288 | RelOptInfo *outer_rel, |
289 | RelOptInfo *inner_rel, |
290 | SpecialJoinInfo *sjinfo, |
291 | List **restrictlist_ptr); |
292 | extern Relids min_join_parameterization(PlannerInfo *root, |
293 | Relids joinrelids, |
294 | RelOptInfo *outer_rel, |
295 | RelOptInfo *inner_rel); |
296 | extern RelOptInfo *fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, |
297 | Relids relids); |
298 | extern Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel); |
299 | extern ParamPathInfo *get_baserel_parampathinfo(PlannerInfo *root, |
300 | RelOptInfo *baserel, |
301 | Relids required_outer); |
302 | extern ParamPathInfo *get_joinrel_parampathinfo(PlannerInfo *root, |
303 | RelOptInfo *joinrel, |
304 | Path *outer_path, |
305 | Path *inner_path, |
306 | SpecialJoinInfo *sjinfo, |
307 | Relids required_outer, |
308 | List **restrict_clauses); |
309 | extern ParamPathInfo *get_appendrel_parampathinfo(RelOptInfo *appendrel, |
310 | Relids required_outer); |
311 | extern ParamPathInfo *find_param_path_info(RelOptInfo *rel, |
312 | Relids required_outer); |
313 | extern RelOptInfo *build_child_join_rel(PlannerInfo *root, |
314 | RelOptInfo *outer_rel, RelOptInfo *inner_rel, |
315 | RelOptInfo *parent_joinrel, List *restrictlist, |
316 | SpecialJoinInfo *sjinfo, JoinType jointype); |
317 | |
318 | #endif /* PATHNODE_H */ |
319 | |