70#define CP_EXACT_TLIST 0x0001
71#define CP_SMALL_TLIST 0x0002
72#define CP_LABEL_TLIST 0x0004
73#define CP_IGNORE_TLIST 0x0008
126 List *tlist,
List *scan_clauses,
bool indexonly);
167 List **stripped_indexquals_p,
168 List **fixed_indexquals_p);
179 double limit_tuples);
181 List *pathkeys,
double limit_tuples);
187 List *indexorderby,
List *indexorderbyorig,
188 List *indexorderbyops,
198 List *indexqualorig);
202 List *bitmapqualorig,
219 Index scanrelid,
int ctePlanId,
int cteParam);
221 Index scanrelid,
char *enrname);
223 Index scanrelid,
int wtParam);
233 List *joinclauses,
List *otherclauses,
List *nestParams,
235 JoinType jointype,
bool inner_unique);
237 List *joinclauses,
List *otherclauses,
239 List *hashoperators,
List *hashcollations,
242 JoinType jointype,
bool inner_unique);
249 List *joinclauses,
List *otherclauses,
252 Oid *mergecollations,
253 bool *mergereversals,
254 bool *mergenullsfirst,
256 JoinType jointype,
bool inner_unique,
257 bool skip_mark_restore);
260 Oid *collations,
bool *nullsFirst);
262 int numCols,
int nPresortedCols,
264 Oid *collations,
bool *nullsFirst);
268 bool adjust_tlist_in_place,
271 Oid **p_sortOperators,
273 bool **p_nullsFirst);
277 List *pathkeys,
Relids relids,
int nPresortedCols);
283 Oid *collations,
List *param_exprs,
284 bool singlerow,
bool binary_mode,
288 double est_hit_ratio);
290 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
291 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
292 List *runCondition,
List *qual,
bool topWindow,
298 List *pathkeys,
int numCols,
301 int nworkers,
int rescan_param,
bool single_copy,
Plan *subplan);
312 CmdType operation,
bool canSetTag,
314 List *resultRelations,
315 List *updateColnosLists,
316 List *withCheckOptionLists,
List *returningLists,
318 List *mergeActionLists,
List *mergeJoinConditions,
348 root->curOuterRels = NULL;
374 if (
root->curOuterParams !=
NIL)
375 elog(
ERROR,
"failed to assign all NestLoopParams to plan nodes");
403 case T_IndexOnlyScan:
404 case T_BitmapHeapScan:
409 case T_TableFuncScan:
412 case T_WorkTableScan:
413 case T_NamedTuplestoreScan:
486 case T_IncrementalSort:
515 case T_RecursiveUnion:
538 elog(
ERROR,
"unrecognized node type: %d",
539 (
int) best_path->pathtype);
556 List *gating_clauses;
575 case T_IndexOnlyScan:
589 if (best_path->param_info)
591 best_path->param_info->ppi_clauses);
608 best_path->
pathtype == T_CustomScan);
609 if (best_path->
pathtype == T_ForeignScan)
610 join_clauses = ((
ForeignPath *) best_path)->fdw_restrictinfo;
612 join_clauses = ((
CustomPath *) best_path)->custom_restrictinfo;
637 if (best_path->
pathtype == T_IndexOnlyScan)
694 case T_IndexOnlyScan:
702 case T_BitmapHeapScan:
737 case T_TableFuncScan:
758 case T_NamedTuplestoreScan:
772 case T_WorkTableScan:
794 elog(
ERROR,
"unrecognized node type: %d",
821 Index *sortgrouprefs = path->pathtarget->sortgrouprefs;
825 foreach(v, path->pathtarget->exprs)
836 if (path->param_info)
905 path->pathtarget->exprs ==
NIL)
923 foreach(lc,
root->placeholder_list)
937 if (path->
pathtype == T_IndexOnlyScan)
943 if (!indexinfo->canreturn[
i])
962 foreach(lc, path->pathtarget->exprs)
966 if (path->pathtarget->sortgrouprefs[
i])
968 if (expr &&
IsA(expr,
Var))
970 int attno = ((
Var *) expr)->varattno;
998 if (!
root->hasPseudoConstantQuals)
1065 return &gplan->
plan;
1077 List *gating_clauses;
1079 switch (best_path->path.pathtype)
1094 elog(
ERROR,
"unrecognized node type: %d",
1095 (
int) best_path->path.pathtype);
1117 if (get_loc_restrictinfo(best_path) !=
NIL)
1137 case T_SubqueryScanPath:
1160 FdwRoutine *fdwroutine = path->parent->fdwroutine;
1169 Assert(fdwroutine != NULL);
1175 case T_ProjectionPath:
1196 plan->async_capable =
true;
1214 bool tlist_was_changed =
false;
1218 int nasyncplans = 0;
1220 int nodenumsortkeys = 0;
1222 Oid *nodeSortOperators = NULL;
1223 Oid *nodeCollations = NULL;
1224 bool *nodeNullsFirst = NULL;
1225 bool consider_async =
false;
1244 best_path->
path.parent);
1263 plan->plan.targetlist = tlist;
1265 plan->plan.lefttree = NULL;
1266 plan->plan.righttree = NULL;
1269 if (pathkeys !=
NIL)
1278 best_path->
path.parent->relids,
1286 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->plan.targetlist));
1295 foreach(subpaths, best_path->
subpaths)
1307 if (pathkeys !=
NIL)
1338 Assert(numsortkeys == nodenumsortkeys);
1339 if (memcmp(sortColIdx, nodeSortColIdx,
1341 elog(
ERROR,
"Append child's targetlist doesn't match Append");
1342 Assert(memcmp(sortOperators, nodeSortOperators,
1343 numsortkeys *
sizeof(
Oid)) == 0);
1344 Assert(memcmp(collations, nodeCollations,
1345 numsortkeys *
sizeof(
Oid)) == 0);
1346 Assert(memcmp(nullsFirst, nodeNullsFirst,
1347 numsortkeys *
sizeof(
bool)) == 0);
1361 sort_plan = (
Plan *)
1363 sortColIdx, sortOperators,
1364 collations, nullsFirst);
1374 sortColIdx, sortOperators,
1375 collations, nullsFirst);
1381 subplan = sort_plan;
1392 subplans =
lappend(subplans, subplan);
1396 plan->part_prune_index = -1;
1409 if (best_path->
path.param_info)
1411 List *prmquals = best_path->
path.param_info->ppi_clauses;
1420 if (prunequal !=
NIL)
1426 plan->appendplans = subplans;
1427 plan->nasyncplans = nasyncplans;
1441 plan->plan.parallel_safe);
1462 bool tlist_was_changed;
1475 plan->targetlist = tlist;
1477 plan->lefttree = NULL;
1478 plan->righttree = NULL;
1488 best_path->
path.parent->relids,
1493 &node->sortOperators,
1496 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->targetlist));
1503 foreach(subpaths, best_path->
subpaths)
1536 if (memcmp(sortColIdx, node->sortColIdx,
1538 elog(
ERROR,
"MergeAppend child's targetlist doesn't match MergeAppend");
1539 Assert(memcmp(sortOperators, node->sortOperators,
1540 numsortkeys *
sizeof(
Oid)) == 0);
1541 Assert(memcmp(collations, node->collations,
1542 numsortkeys *
sizeof(
Oid)) == 0);
1543 Assert(memcmp(nullsFirst, node->nullsFirst,
1544 numsortkeys *
sizeof(
bool)) == 0);
1558 sort_plan = (
Plan *)
1560 sortColIdx, sortOperators,
1561 collations, nullsFirst);
1571 sortColIdx, sortOperators,
1572 collations, nullsFirst);
1578 subplan = sort_plan;
1581 subplans =
lappend(subplans, subplan);
1601 if (prunequal !=
NIL)
1731 operators =
palloc(nkeys *
sizeof(
Oid));
1732 collations =
palloc(nkeys *
sizeof(
Oid));
1740 operators[
i] = opno;
1790 root->glob->parallelModeNeeded =
true;
1826 best_path->
subpath->parent->relids,
1827 gm_plan->sortColIdx,
1830 &gm_plan->sortColIdx,
1831 &gm_plan->sortOperators,
1832 &gm_plan->collations,
1833 &gm_plan->nullsFirst);
1845 root->glob->parallelModeNeeded =
true;
1863 bool needs_result_node =
false;
1889 best_path->
path.pathtarget);
1923 if (!needs_result_node)
1927 plan->targetlist = tlist;
1933 plan->plan_width = best_path->
path.pathtarget->width;
1973 plan->parallel_safe = parallel_safe;
2002 tlist_parallel_safe);
2040 best_path->
path.parent->relids : NULL);
2065 best_path->
spath.
path.parent->relids : NULL,
2141 best_path->
path.parent->relids : NULL);
2213 foreach(lc, groupClause)
2220 return new_grpColIdx;
2265 foreach(lc,
root->processed_groupClause)
2276 foreach(lc,
root->processed_groupClause)
2289 root->grouping_map = grouping_map;
2306 Plan *sort_plan = NULL;
2312 if (!rollup->
is_hashed && !is_first_sort)
2314 sort_plan = (
Plan *)
2321 is_first_sort =
false;
2353 chain =
lappend(chain, agg_plan);
2423 0, NULL, NULL, NULL);
2429 plan->plan_rows = 1;
2430 plan->plan_width = mminfo->
path->pathtarget->width;
2431 plan->parallel_aware =
false;
2442 best_path->
path.parent);
2477 Oid *partCollations;
2501 partCollations = (
Oid *)
palloc(
sizeof(
Oid) * numPart);
2510 partColIdx[partNumCols] = tle->
resno;
2511 partOperators[partNumCols] = sgc->
eqop;
2518 ordCollations = (
Oid *)
palloc(
sizeof(
Oid) * numOrder);
2527 ordColIdx[ordNumCols] = tle->
resno;
2528 ordOperators[ordNumCols] = sgc->
eqop;
2696 int numUniqkeys = 0;
2698 Oid *uniqOperators = NULL;
2699 Oid *uniqCollations = NULL;
2712 uniqOperators = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2713 uniqCollations = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2716 foreach(l,
parse->sortClause)
2721 uniqColIdx[numUniqkeys] = tle->
resno;
2722 uniqOperators[numUniqkeys] = sortcl->
eqop;
2732 numUniqkeys, uniqColIdx, uniqOperators, uniqCollations);
2757 Index scan_relid = best_path->parent->relid;
2770 if (best_path->param_info)
2772 scan_clauses = (
List *)
2795 Index scan_relid = best_path->parent->relid;
2813 if (best_path->param_info)
2815 scan_clauses = (
List *)
2851 Index baserelid = best_path->
path.parent->relid;
2855 List *stripped_indexquals;
2856 List *fixed_indexquals;
2857 List *fixed_indexorderbys;
2875 &stripped_indexquals,
2912 foreach(l, scan_clauses)
2916 if (rinfo->pseudoconstant)
2924 qpqual =
lappend(qpqual, rinfo);
2942 if (best_path->
path.param_info)
2944 stripped_indexquals = (
List *)
2948 indexorderbys = (
List *)
2980 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
2982 indexorderbyops =
lappend_oid(indexorderbyops, sortop);
2999 indextle->resjunk = !indexinfo->canreturn[
i];
3011 stripped_indexquals,
3012 fixed_indexorderbys,
3021 stripped_indexquals,
3022 fixed_indexorderbys,
3043 Index baserelid = best_path->
path.parent->relid;
3044 Plan *bitmapqualplan;
3045 List *bitmapqualorig;
3058 &bitmapqualorig, &indexquals,
3091 foreach(l, scan_clauses)
3096 if (rinfo->pseudoconstant)
3105 qpqual =
lappend(qpqual, rinfo);
3127 if (best_path->
path.param_info)
3131 bitmapqualorig = (
List *)
3197 &subqual, &subindexqual,
3199 subplans =
lappend(subplans, subplan);
3203 subindexECs =
list_concat(subindexECs, subindexEC);
3210 plan->plan_width = 0;
3211 plan->parallel_aware =
false;
3214 *indexqual = subindexquals;
3215 *indexECs = subindexECs;
3223 bool const_true_subqual =
false;
3224 bool const_true_subindexqual =
false;
3244 &subqual, &subindexqual,
3246 subplans =
lappend(subplans, subplan);
3248 const_true_subqual =
true;
3249 else if (!const_true_subqual)
3252 if (subindexqual ==
NIL)
3253 const_true_subindexqual =
true;
3254 else if (!const_true_subindexqual)
3255 subindexquals =
lappend(subindexquals,
3274 plan->plan_width = 0;
3275 plan->parallel_aware =
false;
3284 if (const_true_subqual)
3290 if (const_true_subindexqual)
3293 *indexqual = subindexquals;
3303 List *subindexquals;
3317 plan->startup_cost = 0.0;
3321 plan->plan_width = 0;
3322 plan->parallel_aware =
false;
3326 subindexquals =
NIL;
3333 Assert(!rinfo->pseudoconstant);
3337 if (rinfo->parent_ec)
3338 subindexECs =
lappend(subindexECs, rinfo->parent_ec);
3353 subquals =
lappend(subquals, pred);
3354 subindexquals =
lappend(subindexquals, pred);
3358 *indexqual = subindexquals;
3359 *indexECs = subindexECs;
3380 Index scan_relid = best_path->
path.parent->relid;
3411 foreach(l, scan_clauses)
3415 if (rinfo->pseudoconstant)
3421 qpqual =
lappend(qpqual, rinfo);
3423 scan_clauses = qpqual;
3449 if (best_path->
path.param_info)
3453 scan_clauses = (
List *)
3477 Index scan_relid = best_path->
path.parent->relid;
3493 foreach(l, scan_clauses)
3497 if (rinfo->pseudoconstant)
3501 qpqual =
lappend(qpqual, rinfo);
3503 scan_clauses = qpqual;
3514 if (best_path->
path.param_info)
3516 tidrangequals = (
List *)
3518 scan_clauses = (
List *)
3573 if (best_path->
path.param_info)
3577 scan_clauses = (
List *)
3601 Index scan_relid = best_path->parent->relid;
3618 if (best_path->param_info)
3620 scan_clauses = (
List *)
3644 Index scan_relid = best_path->parent->relid;
3661 if (best_path->param_info)
3663 scan_clauses = (
List *)
3687 Index scan_relid = best_path->parent->relid;
3704 if (best_path->param_info)
3706 scan_clauses = (
List *)
3709 values_lists = (
List *)
3731 Index scan_relid = best_path->parent->relid;
3744 Assert(!rte->self_reference);
3751 while (levelsup-- > 0)
3753 cteroot = cteroot->parent_root;
3782 if (ctesplan->
plan_id == plan_id)
3801 if (best_path->param_info)
3803 scan_clauses = (
List *)
3807 scan_plan =
make_ctescan(tlist, scan_clauses, scan_relid,
3808 plan_id, cte_param_id);
3826 Index scan_relid = best_path->parent->relid;
3840 if (best_path->param_info)
3842 scan_clauses = (
List *)
3865 Index scan_relid = best_path->parent->relid;
3879 if (best_path->param_info)
3881 scan_clauses = (
List *)
3903 Index scan_relid = best_path->parent->relid;
3911 Assert(rte->self_reference);
3923 while (levelsup-- > 0)
3925 cteroot = cteroot->parent_root;
3939 if (best_path->param_info)
3941 scan_clauses = (
List *)
3966 Plan *outer_plan = NULL;
3968 Assert(rel->fdwroutine != NULL);
3986 rel_oid = rte->relid;
4002 scan_plan = rel->fdwroutine->GetForeignPlan(
root, rel, rel_oid,
4004 tlist, scan_clauses,
4032 root->outer_join_rels);
4040 root->glob->dependsOnRole =
true;
4050 if (best_path->
path.param_info)
4052 scan_plan->
scan.plan.qual = (
List *)
4166 if (best_path->
path.param_info)
4198 bool outer_parallel_safe;
4229 root->curOuterRels = saveOuterRels;
4239 best_path->
jpath.path.parent->relids,
4240 &joinclauses, &otherclauses);
4250 if (best_path->
jpath.path.param_info)
4252 joinclauses = (
List *)
4254 otherclauses = (
List *)
4279 foreach(lc, nestParams)
4302 (
Node *) phv->phexpr);
4312 outer_tlist =
lappend(outer_tlist, tle);
4314 if (outer_parallel_safe)
4319 outer_parallel_safe);
4347 List *outerpathkeys;
4348 List *innerpathkeys;
4351 Oid *mergecollations;
4352 bool *mergereversals;
4353 bool *mergenullsfirst;
4384 best_path->
jpath.path.parent->relids,
4385 &joinclauses, &otherclauses);
4405 if (best_path->
jpath.path.param_info)
4407 joinclauses = (
List *)
4409 otherclauses = (
List *)
4426 Relids outer_relids = outer_path->parent->relids;
4443 sort_plan = (
Plan *)
4456 sort_plan = (
Plan *)
4464 outer_plan = sort_plan;
4477 Relids inner_relids = inner_path->parent->relids;
4515 inner_plan = matplan;
4527 mergefamilies = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4528 mergecollations = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4529 mergereversals = (
bool *)
palloc(nClauses *
sizeof(
bool));
4530 mergenullsfirst = (
bool *)
palloc(nClauses *
sizeof(
bool));
4544 bool first_inner_match =
false;
4547 if (rinfo->outer_is_left)
4549 oeclass = rinfo->left_ec;
4550 ieclass = rinfo->right_ec;
4554 oeclass = rinfo->right_ec;
4555 ieclass = rinfo->left_ec;
4575 if (oeclass != opeclass)
4579 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4581 opeclass = opathkey->pk_eclass;
4582 lop =
lnext(outerpathkeys, lop);
4583 if (oeclass != opeclass)
4584 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4605 ipeclass = ipathkey->pk_eclass;
4606 if (ieclass == ipeclass)
4609 lip =
lnext(innerpathkeys, lip);
4610 first_inner_match =
true;
4613 if (!first_inner_match)
4618 foreach(l2, innerpathkeys)
4623 ipeclass = ipathkey->pk_eclass;
4624 if (ieclass == ipeclass)
4627 if (ieclass != ipeclass)
4628 elog(
ERROR,
"inner pathkeys do not match mergeclauses");
4646 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation)
4647 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4648 if (first_inner_match &&
4651 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4655 mergecollations[
i] = opathkey->pk_eclass->ec_collation;
4708 bool skewInherit =
false;
4733 best_path->
jpath.path.parent->relids,
4734 &joinclauses, &otherclauses);
4754 if (best_path->
jpath.path.param_info)
4756 joinclauses = (
List *)
4758 otherclauses = (
List *)
4791 rte =
root->simple_rte_array[var->
varno];
4794 skewTable = rte->relid;
4796 skewInherit = rte->
inh;
4809 foreach(lc, hashclauses)
4814 hashcollations =
lappend_oid(hashcollations, hclause->inputcollid);
4840 if (best_path->
jpath.path.parallel_aware)
4913 root->curOuterRels))
4933 newphv->phexpr = (
Expr *)
4936 return (
Node *) newphv;
4966 List **stripped_indexquals_p,
List **fixed_indexquals_p)
4969 List *stripped_indexquals;
4970 List *fixed_indexquals;
4973 stripped_indexquals = fixed_indexquals =
NIL;
4986 stripped_indexquals =
lappend(stripped_indexquals, clause);
4989 fixed_indexquals =
lappend(fixed_indexquals, clause);
4993 *stripped_indexquals_p = stripped_indexquals;
4994 *fixed_indexquals_p = fixed_indexquals;
5009 List *fixed_indexorderbys;
5013 fixed_indexorderbys =
NIL;
5021 fixed_indexorderbys =
lappend(fixed_indexorderbys, clause);
5024 return fixed_indexorderbys;
5089 elog(
ERROR,
"unsupported indexqual type: %d",
5118 Assert(indexcol >= 0 && indexcol < index->ncolumns);
5120 if (
index->indexkeys[indexcol] != 0)
5124 ((
Var *) node)->varno ==
index->rel->relid &&
5125 ((
Var *) node)->varattno ==
index->indexkeys[indexcol])
5130 return (
Node *) result;
5133 elog(
ERROR,
"index key does not match expected index column");
5138 for (pos = 0; pos <
index->ncolumns; pos++)
5140 if (
index->indexkeys[pos] == 0)
5142 if (indexpr_item == NULL)
5143 elog(
ERROR,
"too few entries in indexprs list");
5144 if (pos == indexcol)
5151 if (
equal(node, indexkey))
5157 return (
Node *) result;
5160 elog(
ERROR,
"index key does not match expected index column");
5162 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5167 elog(
ERROR,
"index key does not match expected index column");
5203 temp->opresulttype = clause->opresulttype;
5204 temp->opretset = clause->opretset;
5205 temp->opcollid = clause->opcollid;
5206 temp->inputcollid = clause->inputcollid;
5211 t_list =
lappend(t_list, temp);
5212 restrictinfo->outer_is_left =
false;
5217 t_list =
lappend(t_list, clause);
5218 restrictinfo->outer_is_left =
true;
5264 Index security_level;
5282 foreach(lc, clauses)
5288 items[
i].clause = clause;
5305 items[
i].security_level = 0;
5310 items[
i].security_level = 0;
5321 QualItem newitem =
items[
i];
5325 for (
j =
i;
j > 0;
j--)
5327 QualItem *olditem = &
items[
j - 1];
5329 if (newitem.security_level > olditem->security_level ||
5330 (newitem.security_level == olditem->security_level &&
5331 newitem.cost >= olditem->cost))
5358 dest->plan_width = src->pathtarget->width;
5376 dest->parallel_aware =
false;
5393 Plan *lefttree =
plan->plan.lefttree;
5399 plan->plan.disabled_nodes,
5410 plan->plan.parallel_aware =
false;
5420 List *pathkeys,
double limit_tuples)
5422 Plan *lefttree =
plan->sort.plan.lefttree;
5428 plan->nPresortedCols,
5429 plan->sort.plan.disabled_nodes,
5441 plan->sort.plan.parallel_aware =
false;
5488 plan->targetlist = qptlist;
5489 plan->qual = qpqual;
5490 plan->lefttree = NULL;
5491 plan->righttree = NULL;
5506 plan->targetlist = qptlist;
5507 plan->qual = qpqual;
5508 plan->lefttree = NULL;
5509 plan->righttree = NULL;
5522 List *indexqualorig,
5524 List *indexorderbyorig,
5525 List *indexorderbyops,
5531 plan->targetlist = qptlist;
5532 plan->qual = qpqual;
5533 plan->lefttree = NULL;
5534 plan->righttree = NULL;
5561 plan->targetlist = qptlist;
5562 plan->qual = qpqual;
5563 plan->lefttree = NULL;
5564 plan->righttree = NULL;
5580 List *indexqualorig)
5587 plan->lefttree = NULL;
5588 plan->righttree = NULL;
5601 List *bitmapqualorig,
5607 plan->targetlist = qptlist;
5608 plan->qual = qpqual;
5609 plan->lefttree = lefttree;
5610 plan->righttree = NULL;
5626 plan->targetlist = qptlist;
5627 plan->qual = qpqual;
5628 plan->lefttree = NULL;
5629 plan->righttree = NULL;
5640 List *tidrangequals)
5645 plan->targetlist = qptlist;
5646 plan->qual = qpqual;
5647 plan->lefttree = NULL;
5648 plan->righttree = NULL;
5664 plan->targetlist = qptlist;
5665 plan->qual = qpqual;
5666 plan->lefttree = NULL;
5667 plan->righttree = NULL;
5680 bool funcordinality)
5685 plan->targetlist = qptlist;
5686 plan->qual = qpqual;
5687 plan->lefttree = NULL;
5688 plan->righttree = NULL;
5705 plan->targetlist = qptlist;
5706 plan->qual = qpqual;
5707 plan->lefttree = NULL;
5708 plan->righttree = NULL;
5724 plan->targetlist = qptlist;
5725 plan->qual = qpqual;
5726 plan->lefttree = NULL;
5727 plan->righttree = NULL;
5744 plan->targetlist = qptlist;
5745 plan->qual = qpqual;
5746 plan->lefttree = NULL;
5747 plan->righttree = NULL;
5765 plan->targetlist = qptlist;
5766 plan->qual = qpqual;
5767 plan->lefttree = NULL;
5768 plan->righttree = NULL;
5784 plan->targetlist = qptlist;
5785 plan->qual = qpqual;
5786 plan->lefttree = NULL;
5787 plan->righttree = NULL;
5800 List *fdw_scan_tlist,
5801 List *fdw_recheck_quals,
5808 plan->targetlist = qptlist;
5809 plan->qual = qpqual;
5810 plan->lefttree = outer_plan;
5811 plan->righttree = NULL;
5846 plan->targetlist = tlist;
5848 plan->lefttree = lefttree;
5849 plan->righttree = righttree;
5869 foreach(slitem, distinctList)
5875 dupColIdx[keyno] = tle->
resno;
5876 dupOperators[keyno] = sortcl->
eqop;
5881 node->dupColIdx = dupColIdx;
5882 node->dupOperators = dupOperators;
5883 node->dupCollations = dupCollations;
5898 plan->lefttree = NULL;
5899 plan->righttree = NULL;
5913 plan->lefttree = NULL;
5914 plan->righttree = NULL;
5933 plan->targetlist = tlist;
5934 plan->qual = otherclauses;
5935 plan->lefttree = lefttree;
5936 plan->righttree = righttree;
5950 List *hashoperators,
5951 List *hashcollations,
5961 plan->targetlist = tlist;
5962 plan->qual = otherclauses;
5963 plan->lefttree = lefttree;
5964 plan->righttree = righttree;
5988 plan->lefttree = lefttree;
5989 plan->righttree = NULL;
6005 Oid *mergecollations,
6006 bool *mergereversals,
6007 bool *mergenullsfirst,
6012 bool skip_mark_restore)
6017 plan->targetlist = tlist;
6018 plan->qual = otherclauses;
6019 plan->lefttree = lefttree;
6020 plan->righttree = righttree;
6023 node->mergeFamilies = mergefamilies;
6024 node->mergeCollations = mergecollations;
6025 node->mergeReversals = mergereversals;
6026 node->mergeNullsFirst = mergenullsfirst;
6043 Oid *collations,
bool *nullsFirst)
6054 plan->lefttree = lefttree;
6055 plan->righttree = NULL;
6057 node->sortColIdx = sortColIdx;
6058 node->sortOperators = sortOperators;
6059 node->collations = collations;
6060 node->nullsFirst = nullsFirst;
6074 Oid *collations,
bool *nullsFirst)
6084 plan->lefttree = lefttree;
6085 plan->righttree = NULL;
6088 node->
sort.sortColIdx = sortColIdx;
6089 node->
sort.sortOperators = sortOperators;
6090 node->
sort.collations = collations;
6091 node->
sort.nullsFirst = nullsFirst;
6141 bool adjust_tlist_in_place,
6144 Oid **p_sortOperators,
6146 bool **p_nullsFirst)
6161 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6162 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6163 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6167 foreach(
i, pathkeys)
6185 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6191 else if (reqColIdx != NULL)
6251 elog(
ERROR,
"could not find pathkey item to sort");
6257 if (!adjust_tlist_in_place &&
6267 adjust_tlist_in_place =
true;
6289 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6290 pathkey->
pk_cmptype, pk_datatype, pk_datatype,
6294 sortColIdx[numsortkeys] = tle->
resno;
6295 sortOperators[numsortkeys] = sortop;
6302 *p_numsortkeys = numsortkeys;
6303 *p_sortColIdx = sortColIdx;
6304 *p_sortOperators = sortOperators;
6305 *p_collations = collations;
6306 *p_nullsFirst = nullsFirst;
6341 sortColIdx, sortOperators,
6342 collations, nullsFirst);
6356 Relids relids,
int nPresortedCols)
6377 sortColIdx, sortOperators,
6378 collations, nullsFirst);
6402 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6403 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6404 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6412 sortColIdx[numsortkeys] = tle->
resno;
6413 sortOperators[numsortkeys] = sortcl->
sortop;
6420 sortColIdx, sortOperators,
6421 collations, nullsFirst);
6453 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6454 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6455 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6458 foreach(l, groupcls)
6464 elog(
ERROR,
"could not retrieve tle for sort-from-groupcols");
6466 sortColIdx[numsortkeys] = tle->
resno;
6467 sortOperators[numsortkeys] = grpcl->
sortop;
6474 sortColIdx, sortOperators,
6475 collations, nullsFirst);
6486 plan->lefttree = lefttree;
6487 plan->righttree = NULL;
6506 bool unsafe_initplans;
6521 &initplan_cost, &unsafe_initplans);
6545 List *param_exprs,
bool singlerow,
bool binary_mode,
6548 double est_hit_ratio)
6555 plan->lefttree = lefttree;
6556 plan->righttree = NULL;
6559 node->hashOperators = hashoperators;
6560 node->collations = collations;
6576 int numGroupCols,
AttrNumber *grpColIdx,
Oid *grpOperators,
Oid *grpCollations,
6578 Size transitionSpace,
Plan *lefttree)
6586 node->grpColIdx = grpColIdx;
6587 node->grpOperators = grpOperators;
6588 node->grpCollations = grpCollations;
6593 node->
chain = chain;
6596 plan->targetlist = tlist;
6597 plan->lefttree = lefttree;
6598 plan->righttree = NULL;
6605 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
6606 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
6607 List *runCondition,
List *qual,
bool topWindow,
Plan *lefttree)
6615 node->partColIdx = partColIdx;
6616 node->partOperators = partOperators;
6617 node->partCollations = partCollations;
6619 node->ordColIdx = ordColIdx;
6620 node->ordOperators = ordOperators;
6621 node->ordCollations = ordCollations;
6635 plan->targetlist = tlist;
6636 plan->lefttree = lefttree;
6637 plan->righttree = NULL;
6656 node->grpColIdx = grpColIdx;
6657 node->grpOperators = grpOperators;
6658 node->grpCollations = grpCollations;
6661 plan->targetlist = tlist;
6662 plan->lefttree = lefttree;
6663 plan->righttree = NULL;
6683 Oid *uniqCollations;
6688 plan->lefttree = lefttree;
6689 plan->righttree = NULL;
6699 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6701 foreach(lc, pathkeys)
6712 if (keyno >= numCols)
6723 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6736 foreach(
j,
plan->targetlist)
6751 elog(
ERROR,
"could not find pathkey item to sort");
6762 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6766 uniqColIdx[keyno] = tle->
resno;
6767 uniqOperators[keyno] = eqop;
6774 node->uniqColIdx = uniqColIdx;
6775 node->uniqOperators = uniqOperators;
6776 node->uniqCollations = uniqCollations;
6792 plan->targetlist = qptlist;
6793 plan->qual = qpqual;
6794 plan->lefttree = subplan;
6795 plan->righttree = NULL;
6822 bool *cmpNullsFirst;
6825 plan->targetlist = tlist;
6827 plan->lefttree = lefttree;
6828 plan->righttree = righttree;
6837 cmpNullsFirst = (
bool *)
palloc(
sizeof(
bool) * numCols);
6839 foreach(slitem, groupList)
6844 cmpColIdx[keyno] = tle->
resno;
6846 cmpOperators[keyno] = sortcl->
eqop;
6848 cmpOperators[keyno] = sortcl->
sortop;
6858 node->cmpColIdx = cmpColIdx;
6859 node->cmpOperators = cmpOperators;
6860 node->cmpCollations = cmpCollations;
6861 node->cmpNullsFirst = cmpNullsFirst;
6879 plan->lefttree = lefttree;
6880 plan->righttree = NULL;
6895 Oid *uniqOperators,
Oid *uniqCollations)
6902 plan->lefttree = lefttree;
6903 plan->righttree = NULL;
6909 node->uniqColIdx = uniqColIdx;
6910 node->uniqOperators = uniqOperators;
6911 node->uniqCollations = uniqCollations;
6923 Node *resconstantqual,
6931 plan->targetlist = tlist;
6933 plan->lefttree = subplan;
6934 plan->righttree = NULL;
6954 Node *resconstantqual,
6960 plan->targetlist = tlist;
6962 plan->lefttree = NULL;
6963 plan->righttree = NULL;
6983 plan->targetlist = tlist;
6985 plan->lefttree = subplan;
6986 plan->righttree = NULL;
6997 CmdType operation,
bool canSetTag,
6999 List *resultRelations,
7000 List *updateColnosLists,
7001 List *withCheckOptionLists,
List *returningLists,
7003 List *mergeActionLists,
List *mergeJoinConditions,
7007 bool returning_old_or_new =
false;
7008 bool returning_old_or_new_valid =
false;
7009 bool transition_tables =
false;
7010 bool transition_tables_valid =
false;
7011 List *fdw_private_list;
7019 updateColnosLists ==
NIL));
7086 fdw_private_list =
NIL;
7087 direct_modify_plans = NULL;
7089 foreach(lc, resultRelations)
7103 if (rti < root->simple_rel_array_size &&
7104 root->simple_rel_array[rti] != NULL)
7108 fdwroutine = resultRel->fdwroutine;
7115 rte->relkind == RELKIND_FOREIGN_TABLE)
7123 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
7124 errmsg(
"access to non-system foreign table is restricted")));
7140 if (operation ==
CMD_MERGE && fdwroutine != NULL)
7145 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7146 errmsg(
"cannot execute MERGE on relation \"%s\"",
7159 direct_modify =
false;
7160 if (fdwroutine != NULL &&
7165 withCheckOptionLists ==
NIL &&
7173 if (!returning_old_or_new_valid)
7175 returning_old_or_new =
7177 root->parse->returningList);
7178 returning_old_or_new_valid =
true;
7180 if (!returning_old_or_new)
7182 if (!transition_tables_valid)
7187 transition_tables_valid =
true;
7189 if (!transition_tables)
7197 if (!direct_modify &&
7198 fdwroutine != NULL &&
7203 fdw_private_list =
lappend(fdw_private_list, fdw_private);
7226 case T_IncrementalSort:
7233 case T_RecursiveUnion:
7283 case T_RecursiveUnion:
Datum sort(PG_FUNCTION_ARGS)
#define InvalidAttrNumber
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
void bms_free(Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
#define PG_USED_FOR_ASSERTS_ONLY
#define OidIsValid(objectId)
bool contain_mutable_functions(Node *clause)
bool is_parallel_safe(PlannerInfo *root, Node *node)
Bitmapset * pull_paramids(Expr *expr)
void CommuteOpExpr(OpExpr *clause)
void cost_material(Path *path, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double tuples, int width)
void cost_sort(Path *path, PlannerInfo *root, List *pathkeys, int input_disabled_nodes, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root)
void cost_incremental_sort(Path *path, PlannerInfo *root, List *pathkeys, int presorted_keys, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double input_tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
double clamp_row_est(double nrows)
bool enable_partition_pruning
bool enable_incremental_sort
static Plan * create_join_plan(PlannerInfo *root, JoinPath *best_path)
static bool use_physical_tlist(PlannerInfo *root, Path *path, int flags)
static ModifyTable * make_modifytable(PlannerInfo *root, Plan *subplan, CmdType operation, bool canSetTag, Index nominalRelation, Index rootRelation, List *resultRelations, List *updateColnosLists, List *withCheckOptionLists, List *returningLists, List *rowMarks, OnConflictExpr *onconflict, List *mergeActionLists, List *mergeJoinConditions, int epqParam)
static SeqScan * create_seqscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static WorkTableScan * make_worktablescan(List *qptlist, List *qpqual, Index scanrelid, int wtParam)
static Plan * create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, int flags)
static List * order_qual_clauses(PlannerInfo *root, List *clauses)
static MergeJoin * make_mergejoin(List *tlist, List *joinclauses, List *otherclauses, List *mergeclauses, Oid *mergefamilies, Oid *mergecollations, bool *mergereversals, bool *mergenullsfirst, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique, bool skip_mark_restore)
static GatherMerge * create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path)
static ValuesScan * create_valuesscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static void copy_generic_path_info(Plan *dest, Path *src)
static WindowAgg * make_windowagg(List *tlist, WindowClause *wc, int partNumCols, AttrNumber *partColIdx, Oid *partOperators, Oid *partCollations, int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators, Oid *ordCollations, List *runCondition, List *qual, bool topWindow, Plan *lefttree)
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
static BitmapOr * make_bitmap_or(List *bitmapplans)
static HashJoin * create_hashjoin_plan(PlannerInfo *root, HashPath *best_path)
static SeqScan * make_seqscan(List *qptlist, List *qpqual, Index scanrelid)
static TableFuncScan * create_tablefuncscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static CustomScan * create_customscan_plan(PlannerInfo *root, CustomPath *best_path, List *tlist, List *scan_clauses)
static Node * fix_indexqual_operand(Node *node, IndexOptInfo *index, int indexcol)
static void fix_indexqual_references(PlannerInfo *root, IndexPath *index_path, List **stripped_indexquals_p, List **fixed_indexquals_p)
static List * fix_indexorderby_references(PlannerInfo *root, IndexPath *index_path)
static AttrNumber * remap_groupColIdx(PlannerInfo *root, List *groupClause)
static Plan * create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
static void bitmap_subplan_mark_shared(Plan *plan)
static Unique * create_unique_plan(PlannerInfo *root, UniquePath *best_path, int flags)
static Result * make_one_row_result(List *tlist, Node *resconstantqual, RelOptInfo *rel)
static TidScan * make_tidscan(List *qptlist, List *qpqual, Index scanrelid, List *tidquals)
static MergeJoin * create_mergejoin_plan(PlannerInfo *root, MergePath *best_path)
static Plan * create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
static void label_sort_with_costsize(PlannerInfo *root, Sort *plan, double limit_tuples)
static ForeignScan * create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path, List *tlist, List *scan_clauses)
static BitmapHeapScan * create_bitmap_scan_plan(PlannerInfo *root, BitmapHeapPath *best_path, List *tlist, List *scan_clauses)
static IncrementalSort * make_incrementalsort(Plan *lefttree, int numCols, int nPresortedCols, AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst)
static Result * create_group_result_plan(PlannerInfo *root, GroupResultPath *best_path)
static Limit * create_limit_plan(PlannerInfo *root, LimitPath *best_path, int flags)
static Unique * make_unique_from_pathkeys(Plan *lefttree, List *pathkeys, int numCols, Relids relids)
static Agg * create_agg_plan(PlannerInfo *root, AggPath *best_path)
bool is_projection_capable_path(Path *path)
static CteScan * make_ctescan(List *qptlist, List *qpqual, Index scanrelid, int ctePlanId, int cteParam)
static TidScan * create_tidscan_plan(PlannerInfo *root, TidPath *best_path, List *tlist, List *scan_clauses)
static TidRangeScan * make_tidrangescan(List *qptlist, List *qpqual, Index scanrelid, List *tidrangequals)
static Plan * create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, List **qual, List **indexqual, List **indexECs)
static RecursiveUnion * make_recursive_union(List *tlist, Plan *lefttree, Plan *righttree, int wtParam, List *distinctList, Cardinality numGroups)
static Node * fix_indexqual_clause(PlannerInfo *root, IndexOptInfo *index, int indexcol, Node *clause, List *indexcolnos)
static WorkTableScan * create_worktablescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Plan * create_gating_plan(PlannerInfo *root, Path *path, Plan *plan, List *gating_quals)
static Memoize * make_memoize(Plan *lefttree, Oid *hashoperators, Oid *collations, List *param_exprs, bool singlerow, bool binary_mode, uint32 est_entries, Bitmapset *keyparamids, Cardinality est_calls, Cardinality est_unique_keys, double est_hit_ratio)
static FunctionScan * create_functionscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Result * create_resultscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static BitmapHeapScan * make_bitmap_heapscan(List *qptlist, List *qpqual, Plan *lefttree, List *bitmapqualorig, Index scanrelid)
static Node * replace_nestloop_params_mutator(Node *node, PlannerInfo *root)
static SetOp * create_setop_plan(PlannerInfo *root, SetOpPath *best_path, int flags)
bool is_projection_capable_plan(Plan *plan)
static CteScan * create_ctescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Sort * create_sort_plan(PlannerInfo *root, SortPath *best_path, int flags)
static ProjectSet * make_project_set(List *tlist, Plan *subplan)
static Sort * make_sort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids)
static HashJoin * make_hashjoin(List *tlist, List *joinclauses, List *otherclauses, List *hashclauses, List *hashoperators, List *hashcollations, List *hashkeys, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique)
static Gather * make_gather(List *qptlist, List *qpqual, int nworkers, int rescan_param, bool single_copy, Plan *subplan)
static Gather * create_gather_plan(PlannerInfo *root, GatherPath *best_path)
static Sort * make_sort(Plan *lefttree, int numCols, AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst)
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
static ProjectSet * create_project_set_plan(PlannerInfo *root, ProjectSetPath *best_path)
static void label_incrementalsort_with_costsize(PlannerInfo *root, IncrementalSort *plan, List *pathkeys, double limit_tuples)
static SetOp * make_setop(SetOpCmd cmd, SetOpStrategy strategy, List *tlist, Plan *lefttree, Plan *righttree, List *groupList, Cardinality numGroups)
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)
static Group * create_group_plan(PlannerInfo *root, GroupPath *best_path)
static ModifyTable * create_modifytable_plan(PlannerInfo *root, ModifyTablePath *best_path)
static Result * create_minmaxagg_plan(PlannerInfo *root, MinMaxAggPath *best_path)
static LockRows * create_lockrows_plan(PlannerInfo *root, LockRowsPath *best_path, int flags)
static Material * create_material_plan(PlannerInfo *root, MaterialPath *best_path, int flags)
static List * get_gating_quals(PlannerInfo *root, List *quals)
static Plan * create_scan_plan(PlannerInfo *root, Path *best_path, int flags)
static Group * make_group(List *tlist, List *qual, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations, Plan *lefttree)
static LockRows * make_lockrows(Plan *lefttree, List *rowMarks, int epqParam)
static IncrementalSort * create_incrementalsort_plan(PlannerInfo *root, IncrementalSortPath *best_path, int flags)
static NamedTuplestoreScan * create_namedtuplestorescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Plan * create_projection_plan(PlannerInfo *root, ProjectionPath *best_path, int flags)
static IndexOnlyScan * make_indexonlyscan(List *qptlist, List *qpqual, Index scanrelid, Oid indexid, List *indexqual, List *recheckqual, List *indexorderby, List *indextlist, ScanDirection indexscandir)
static List * build_path_tlist(PlannerInfo *root, Path *path)
static IndexScan * make_indexscan(List *qptlist, List *qpqual, Index scanrelid, Oid indexid, List *indexqual, List *indexqualorig, List *indexorderby, List *indexorderbyorig, List *indexorderbyops, ScanDirection indexscandir)
static FunctionScan * make_functionscan(List *qptlist, List *qpqual, Index scanrelid, List *functions, bool funcordinality)
static TableFuncScan * make_tablefuncscan(List *qptlist, List *qpqual, Index scanrelid, TableFunc *tablefunc)
static SubqueryScan * create_subqueryscan_plan(PlannerInfo *root, SubqueryScanPath *best_path, List *tlist, List *scan_clauses)
static Plan * inject_projection_plan(Plan *subplan, List *tlist, bool parallel_safe)
static TidRangeScan * create_tidrangescan_plan(PlannerInfo *root, TidRangePath *best_path, List *tlist, List *scan_clauses)
static List * get_switched_clauses(List *clauses, Relids outerrelids)
static void copy_plan_costsize(Plan *dest, Plan *src)
static ValuesScan * make_valuesscan(List *qptlist, List *qpqual, Index scanrelid, List *values_lists)
Plan * materialize_finished_plan(Plan *subplan)
static SampleScan * make_samplescan(List *qptlist, List *qpqual, Index scanrelid, TableSampleClause *tsc)
static NestLoop * create_nestloop_plan(PlannerInfo *root, NestPath *best_path)
static Memoize * create_memoize_plan(PlannerInfo *root, MemoizePath *best_path, int flags)
static Result * make_gating_result(List *tlist, Node *resconstantqual, Plan *subplan)
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)
static NamedTuplestoreScan * make_namedtuplestorescan(List *qptlist, List *qpqual, Index scanrelid, char *enrname)
static bool mark_async_capable_plan(Plan *plan, Path *path)
static Material * make_material(Plan *lefttree)
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
static NestLoop * make_nestloop(List *tlist, List *joinclauses, List *otherclauses, List *nestParams, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique)
static BitmapIndexScan * make_bitmap_indexscan(Index scanrelid, Oid indexid, List *indexqual, List *indexqualorig)
static SubqueryScan * make_subqueryscan(List *qptlist, List *qpqual, Index scanrelid, Plan *subplan)
static Hash * make_hash(Plan *lefttree, List *hashkeys, Oid skewTable, AttrNumber skewColumn, bool skewInherit)
static WindowAgg * create_windowagg_plan(PlannerInfo *root, WindowAggPath *best_path)
static Node * replace_nestloop_params(PlannerInfo *root, Node *expr)
static BitmapAnd * make_bitmap_and(List *bitmapplans)
static Plan * create_groupingsets_plan(PlannerInfo *root, GroupingSetsPath *best_path)
static RecursiveUnion * create_recursiveunion_plan(PlannerInfo *root, RecursiveUnionPath *best_path)
static Sort * make_sort_from_groupcols(List *groupcls, AttrNumber *grpColIdx, Plan *lefttree)
static Scan * create_indexscan_plan(PlannerInfo *root, IndexPath *best_path, List *tlist, List *scan_clauses, bool indexonly)
static Plan * prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids, const AttrNumber *reqColIdx, bool adjust_tlist_in_place, int *p_numsortkeys, AttrNumber **p_sortColIdx, Oid **p_sortOperators, Oid **p_collations, bool **p_nullsFirst)
static IncrementalSort * make_incrementalsort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids, int nPresortedCols)
static SampleScan * create_samplescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
Plan * create_plan(PlannerInfo *root, Path *best_path)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
bool is_redundant_with_indexclauses(RestrictInfo *rinfo, List *indexclauses)
EquivalenceMember * find_ec_member_matching_expr(EquivalenceClass *ec, Expr *expr, Relids relids)
EquivalenceMember * find_computable_ec_member(PlannerInfo *root, EquivalenceClass *ec, List *exprs, Relids relids, bool require_parallel_safe)
bool is_redundant_derived_clause(RestrictInfo *rinfo, List *clauselist)
#define CUSTOMPATH_SUPPORT_PROJECTION
FdwRoutine * GetFdwRoutineByRelId(Oid relid)
Assert(PointerIsAligned(start, uint64))
if(TABLE==NULL||TABLE_index==NULL)
List * list_difference(const List *list1, const List *list2)
List * lappend(List *list, void *datum)
List * list_difference_ptr(const List *list1, const List *list2)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lappend_oid(List *list, Oid datum)
bool list_member_ptr(const List *list, const void *datum)
bool list_member(const List *list, const void *datum)
List * list_copy_head(const List *oldlist, int len)
List * list_concat_unique(List *list1, const List *list2)
char * get_rel_name(Oid relid)
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Datum lca(PG_FUNCTION_ARGS)
Datum subpath(PG_FUNCTION_ARGS)
Expr * make_orclause(List *orclauses)
Expr * make_ands_explicit(List *andclauses)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Node * makeBoolConst(bool value, bool isnull)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
void * palloc0(Size size)
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
#define expression_tree_mutator(n, m, c)
static bool is_opclause(const void *clause)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
#define castNode(_type_, nodeptr)
void process_subquery_nestloop_params(PlannerInfo *root, List *subplan_params)
List * identify_current_nestloop_params(PlannerInfo *root, Relids leftrelids, Relids outerrelids)
Param * replace_nestloop_param_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
int assign_special_exec_param(PlannerInfo *root)
Param * replace_nestloop_param_var(PlannerInfo *root, Var *var)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
int make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, List *subpaths, List *prunequal)
bool pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
bool pathkeys_contained_in(List *keys1, List *keys2)
Path * reparameterize_path_by_child(PlannerInfo *root, Path *path, RelOptInfo *child_rel)
#define IS_DUMMY_APPEND(p)
#define PATH_REQ_OUTER(path)
#define planner_rt_fetch(rti, root)
#define IS_OTHER_REL(rel)
#define IS_UPPER_REL(rel)
int errdetail_relkind_not_supported(char relkind)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define for_each_from(cell, lst, N)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
static int list_nth_int(const List *list, int n)
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
bool has_stored_generated_columns(PlannerInfo *root, Index rti)
bool has_row_triggers(PlannerInfo *root, Index rti, CmdType event)
List * build_physical_tlist(PlannerInfo *root, RelOptInfo *rel)
bool has_transition_tables(PlannerInfo *root, Index rti, CmdType event)
List * infer_arbiter_indexes(PlannerInfo *root)
int restrict_nonsystem_relation_kind
bool predicate_implied_by(List *predicate_list, List *clause_list, bool weak)
List * extract_update_targetlist_colnos(List *tlist)
#define IS_SPECIAL_VARNO(varno)
static const struct fns functions
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
List * extract_actual_clauses(List *restrictinfo_list, bool pseudoconstant)
void extract_actual_join_clauses(List *restrictinfo_list, Relids joinrelids, List **joinquals, List **otherquals)
List * get_actual_clauses(List *restrictinfo_list)
bool trivial_subqueryscan(SubqueryScan *plan)
void check_stack_depth(void)
Selectivity bitmapselectivity
Selectivity bitmapselectivity
struct Plan *(* PlanCustomPath)(PlannerInfo *root, RelOptInfo *rel, struct CustomPath *best_path, List *tlist, List *clauses, List *custom_plans)
const struct CustomPathMethods * methods
Bitmapset * custom_relids
BeginDirectModify_function BeginDirectModify
PlanForeignModify_function PlanForeignModify
PlanDirectModify_function PlanDirectModify
IterateDirectModify_function IterateDirectModify
EndDirectModify_function EndDirectModify
IsForeignPathAsyncCapable_function IsForeignPathAsyncCapable
Bitmapset * fs_base_relids
Cardinality inner_rows_total
struct RestrictInfo * rinfo
ScanDirection indexorderdir
ScanDirection indexscandir
Selectivity indexselectivity
ScanDirection indexorderdir
Cardinality est_unique_keys
Cardinality est_unique_keys
List * withCheckOptionLists
List * mergeJoinConditions
OnConflictExpr * onconflict
List * mergeJoinConditions
Bitmapset * fdwDirectModifyPlans
List * withCheckOptionLists
OnConflictAction onConflictAction
struct TableSampleClause * tablesample
struct PathTarget * reltarget
struct TableSampleClause * tablesample
SubqueryScanStatus scanstatus
void SS_attach_initplans(PlannerInfo *root, Plan *plan)
void SS_compute_initplan_cost(List *init_plans, Cost *initplan_cost_p, bool *unsafe_initplans_p)
void SS_make_initplan_from_plan(PlannerInfo *root, PlannerInfo *subroot, Plan *plan, Param *prm)
#define FirstLowInvalidHeapAttributeNumber
#define RESTRICT_RELKIND_FOREIGN_TABLE
Oid * extract_grouping_ops(List *groupClause)
TargetEntry * tlist_member(Expr *node, List *targetlist)
bool tlist_same_exprs(List *tlist1, List *tlist2)
void apply_tlist_labeling(List *dest_tlist, List *src_tlist)
void apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target)
AttrNumber * extract_grouping_cols(List *groupClause, List *tlist)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
Oid * extract_grouping_collations(List *groupClause, List *tlist)
#define FirstNormalObjectId
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
bool contain_vars_returning_old_or_new(Node *node)