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);
304 List *groupList,
long numGroups);
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;
2704 int numUniqkeys = 0;
2706 Oid *uniqOperators = NULL;
2707 Oid *uniqCollations = NULL;
2720 uniqOperators = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2721 uniqCollations = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2724 foreach(l,
parse->sortClause)
2729 uniqColIdx[numUniqkeys] = tle->
resno;
2730 uniqOperators[numUniqkeys] = sortcl->
eqop;
2740 numUniqkeys, uniqColIdx, uniqOperators, uniqCollations);
2765 Index scan_relid = best_path->parent->relid;
2778 if (best_path->param_info)
2780 scan_clauses = (
List *)
2803 Index scan_relid = best_path->parent->relid;
2821 if (best_path->param_info)
2823 scan_clauses = (
List *)
2859 Index baserelid = best_path->
path.parent->relid;
2863 List *stripped_indexquals;
2864 List *fixed_indexquals;
2865 List *fixed_indexorderbys;
2883 &stripped_indexquals,
2920 foreach(l, scan_clauses)
2924 if (rinfo->pseudoconstant)
2932 qpqual =
lappend(qpqual, rinfo);
2950 if (best_path->
path.param_info)
2952 stripped_indexquals = (
List *)
2956 indexorderbys = (
List *)
2988 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
2990 indexorderbyops =
lappend_oid(indexorderbyops, sortop);
3007 indextle->resjunk = !indexinfo->canreturn[
i];
3019 stripped_indexquals,
3020 fixed_indexorderbys,
3029 stripped_indexquals,
3030 fixed_indexorderbys,
3051 Index baserelid = best_path->
path.parent->relid;
3052 Plan *bitmapqualplan;
3053 List *bitmapqualorig;
3066 &bitmapqualorig, &indexquals,
3099 foreach(l, scan_clauses)
3104 if (rinfo->pseudoconstant)
3113 qpqual =
lappend(qpqual, rinfo);
3135 if (best_path->
path.param_info)
3139 bitmapqualorig = (
List *)
3205 &subqual, &subindexqual,
3207 subplans =
lappend(subplans, subplan);
3211 subindexECs =
list_concat(subindexECs, subindexEC);
3218 plan->plan_width = 0;
3219 plan->parallel_aware =
false;
3222 *indexqual = subindexquals;
3223 *indexECs = subindexECs;
3231 bool const_true_subqual =
false;
3232 bool const_true_subindexqual =
false;
3252 &subqual, &subindexqual,
3254 subplans =
lappend(subplans, subplan);
3256 const_true_subqual =
true;
3257 else if (!const_true_subqual)
3260 if (subindexqual ==
NIL)
3261 const_true_subindexqual =
true;
3262 else if (!const_true_subindexqual)
3263 subindexquals =
lappend(subindexquals,
3282 plan->plan_width = 0;
3283 plan->parallel_aware =
false;
3292 if (const_true_subqual)
3298 if (const_true_subindexqual)
3301 *indexqual = subindexquals;
3311 List *subindexquals;
3325 plan->startup_cost = 0.0;
3329 plan->plan_width = 0;
3330 plan->parallel_aware =
false;
3334 subindexquals =
NIL;
3341 Assert(!rinfo->pseudoconstant);
3345 if (rinfo->parent_ec)
3346 subindexECs =
lappend(subindexECs, rinfo->parent_ec);
3361 subquals =
lappend(subquals, pred);
3362 subindexquals =
lappend(subindexquals, pred);
3366 *indexqual = subindexquals;
3367 *indexECs = subindexECs;
3388 Index scan_relid = best_path->
path.parent->relid;
3419 foreach(l, scan_clauses)
3423 if (rinfo->pseudoconstant)
3429 qpqual =
lappend(qpqual, rinfo);
3431 scan_clauses = qpqual;
3457 if (best_path->
path.param_info)
3461 scan_clauses = (
List *)
3485 Index scan_relid = best_path->
path.parent->relid;
3501 foreach(l, scan_clauses)
3505 if (rinfo->pseudoconstant)
3509 qpqual =
lappend(qpqual, rinfo);
3511 scan_clauses = qpqual;
3522 if (best_path->
path.param_info)
3524 tidrangequals = (
List *)
3526 scan_clauses = (
List *)
3581 if (best_path->
path.param_info)
3585 scan_clauses = (
List *)
3609 Index scan_relid = best_path->parent->relid;
3626 if (best_path->param_info)
3628 scan_clauses = (
List *)
3652 Index scan_relid = best_path->parent->relid;
3669 if (best_path->param_info)
3671 scan_clauses = (
List *)
3695 Index scan_relid = best_path->parent->relid;
3712 if (best_path->param_info)
3714 scan_clauses = (
List *)
3717 values_lists = (
List *)
3739 Index scan_relid = best_path->parent->relid;
3752 Assert(!rte->self_reference);
3759 while (levelsup-- > 0)
3761 cteroot = cteroot->parent_root;
3790 if (ctesplan->
plan_id == plan_id)
3809 if (best_path->param_info)
3811 scan_clauses = (
List *)
3815 scan_plan =
make_ctescan(tlist, scan_clauses, scan_relid,
3816 plan_id, cte_param_id);
3834 Index scan_relid = best_path->parent->relid;
3848 if (best_path->param_info)
3850 scan_clauses = (
List *)
3873 Index scan_relid = best_path->parent->relid;
3887 if (best_path->param_info)
3889 scan_clauses = (
List *)
3911 Index scan_relid = best_path->parent->relid;
3919 Assert(rte->self_reference);
3931 while (levelsup-- > 0)
3933 cteroot = cteroot->parent_root;
3947 if (best_path->param_info)
3949 scan_clauses = (
List *)
3974 Plan *outer_plan = NULL;
3976 Assert(rel->fdwroutine != NULL);
3994 rel_oid = rte->relid;
4010 scan_plan = rel->fdwroutine->GetForeignPlan(
root, rel, rel_oid,
4012 tlist, scan_clauses,
4040 root->outer_join_rels);
4048 root->glob->dependsOnRole =
true;
4058 if (best_path->
path.param_info)
4060 scan_plan->
scan.plan.qual = (
List *)
4174 if (best_path->
path.param_info)
4206 bool outer_parallel_safe;
4237 root->curOuterRels = saveOuterRels;
4247 best_path->
jpath.path.parent->relids,
4248 &joinclauses, &otherclauses);
4258 if (best_path->
jpath.path.param_info)
4260 joinclauses = (
List *)
4262 otherclauses = (
List *)
4287 foreach(lc, nestParams)
4310 (
Node *) phv->phexpr);
4320 outer_tlist =
lappend(outer_tlist, tle);
4322 if (outer_parallel_safe)
4327 outer_parallel_safe);
4355 List *outerpathkeys;
4356 List *innerpathkeys;
4359 Oid *mergecollations;
4360 bool *mergereversals;
4361 bool *mergenullsfirst;
4392 best_path->
jpath.path.parent->relids,
4393 &joinclauses, &otherclauses);
4413 if (best_path->
jpath.path.param_info)
4415 joinclauses = (
List *)
4417 otherclauses = (
List *)
4434 Relids outer_relids = outer_path->parent->relids;
4451 sort_plan = (
Plan *)
4464 sort_plan = (
Plan *)
4472 outer_plan = sort_plan;
4485 Relids inner_relids = inner_path->parent->relids;
4523 inner_plan = matplan;
4535 mergefamilies = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4536 mergecollations = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4537 mergereversals = (
bool *)
palloc(nClauses *
sizeof(
bool));
4538 mergenullsfirst = (
bool *)
palloc(nClauses *
sizeof(
bool));
4552 bool first_inner_match =
false;
4555 if (rinfo->outer_is_left)
4557 oeclass = rinfo->left_ec;
4558 ieclass = rinfo->right_ec;
4562 oeclass = rinfo->right_ec;
4563 ieclass = rinfo->left_ec;
4583 if (oeclass != opeclass)
4587 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4589 opeclass = opathkey->pk_eclass;
4590 lop =
lnext(outerpathkeys, lop);
4591 if (oeclass != opeclass)
4592 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4613 ipeclass = ipathkey->pk_eclass;
4614 if (ieclass == ipeclass)
4617 lip =
lnext(innerpathkeys, lip);
4618 first_inner_match =
true;
4621 if (!first_inner_match)
4626 foreach(l2, innerpathkeys)
4631 ipeclass = ipathkey->pk_eclass;
4632 if (ieclass == ipeclass)
4635 if (ieclass != ipeclass)
4636 elog(
ERROR,
"inner pathkeys do not match mergeclauses");
4654 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation)
4655 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4656 if (first_inner_match &&
4659 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4663 mergecollations[
i] = opathkey->pk_eclass->ec_collation;
4716 bool skewInherit =
false;
4741 best_path->
jpath.path.parent->relids,
4742 &joinclauses, &otherclauses);
4762 if (best_path->
jpath.path.param_info)
4764 joinclauses = (
List *)
4766 otherclauses = (
List *)
4799 rte =
root->simple_rte_array[var->
varno];
4802 skewTable = rte->relid;
4804 skewInherit = rte->
inh;
4817 foreach(lc, hashclauses)
4822 hashcollations =
lappend_oid(hashcollations, hclause->inputcollid);
4848 if (best_path->
jpath.path.parallel_aware)
4921 root->curOuterRels))
4941 newphv->phexpr = (
Expr *)
4944 return (
Node *) newphv;
4974 List **stripped_indexquals_p,
List **fixed_indexquals_p)
4977 List *stripped_indexquals;
4978 List *fixed_indexquals;
4981 stripped_indexquals = fixed_indexquals =
NIL;
4994 stripped_indexquals =
lappend(stripped_indexquals, clause);
4997 fixed_indexquals =
lappend(fixed_indexquals, clause);
5001 *stripped_indexquals_p = stripped_indexquals;
5002 *fixed_indexquals_p = fixed_indexquals;
5017 List *fixed_indexorderbys;
5021 fixed_indexorderbys =
NIL;
5029 fixed_indexorderbys =
lappend(fixed_indexorderbys, clause);
5032 return fixed_indexorderbys;
5097 elog(
ERROR,
"unsupported indexqual type: %d",
5126 Assert(indexcol >= 0 && indexcol < index->ncolumns);
5128 if (
index->indexkeys[indexcol] != 0)
5132 ((
Var *) node)->varno ==
index->rel->relid &&
5133 ((
Var *) node)->varattno ==
index->indexkeys[indexcol])
5138 return (
Node *) result;
5141 elog(
ERROR,
"index key does not match expected index column");
5146 for (pos = 0; pos <
index->ncolumns; pos++)
5148 if (
index->indexkeys[pos] == 0)
5150 if (indexpr_item == NULL)
5151 elog(
ERROR,
"too few entries in indexprs list");
5152 if (pos == indexcol)
5159 if (
equal(node, indexkey))
5165 return (
Node *) result;
5168 elog(
ERROR,
"index key does not match expected index column");
5170 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5175 elog(
ERROR,
"index key does not match expected index column");
5211 temp->opresulttype = clause->opresulttype;
5212 temp->opretset = clause->opretset;
5213 temp->opcollid = clause->opcollid;
5214 temp->inputcollid = clause->inputcollid;
5219 t_list =
lappend(t_list, temp);
5220 restrictinfo->outer_is_left =
false;
5225 t_list =
lappend(t_list, clause);
5226 restrictinfo->outer_is_left =
true;
5272 Index security_level;
5290 foreach(lc, clauses)
5296 items[
i].clause = clause;
5313 items[
i].security_level = 0;
5318 items[
i].security_level = 0;
5329 QualItem newitem =
items[
i];
5333 for (
j =
i;
j > 0;
j--)
5335 QualItem *olditem = &
items[
j - 1];
5337 if (newitem.security_level > olditem->security_level ||
5338 (newitem.security_level == olditem->security_level &&
5339 newitem.cost >= olditem->cost))
5366 dest->plan_width = src->pathtarget->width;
5384 dest->parallel_aware =
false;
5401 Plan *lefttree =
plan->plan.lefttree;
5407 plan->plan.disabled_nodes,
5418 plan->plan.parallel_aware =
false;
5428 List *pathkeys,
double limit_tuples)
5430 Plan *lefttree =
plan->sort.plan.lefttree;
5436 plan->nPresortedCols,
5437 plan->sort.plan.disabled_nodes,
5449 plan->sort.plan.parallel_aware =
false;
5496 plan->targetlist = qptlist;
5497 plan->qual = qpqual;
5498 plan->lefttree = NULL;
5499 plan->righttree = NULL;
5514 plan->targetlist = qptlist;
5515 plan->qual = qpqual;
5516 plan->lefttree = NULL;
5517 plan->righttree = NULL;
5530 List *indexqualorig,
5532 List *indexorderbyorig,
5533 List *indexorderbyops,
5539 plan->targetlist = qptlist;
5540 plan->qual = qpqual;
5541 plan->lefttree = NULL;
5542 plan->righttree = NULL;
5569 plan->targetlist = qptlist;
5570 plan->qual = qpqual;
5571 plan->lefttree = NULL;
5572 plan->righttree = NULL;
5588 List *indexqualorig)
5595 plan->lefttree = NULL;
5596 plan->righttree = NULL;
5609 List *bitmapqualorig,
5615 plan->targetlist = qptlist;
5616 plan->qual = qpqual;
5617 plan->lefttree = lefttree;
5618 plan->righttree = NULL;
5634 plan->targetlist = qptlist;
5635 plan->qual = qpqual;
5636 plan->lefttree = NULL;
5637 plan->righttree = NULL;
5648 List *tidrangequals)
5653 plan->targetlist = qptlist;
5654 plan->qual = qpqual;
5655 plan->lefttree = NULL;
5656 plan->righttree = NULL;
5672 plan->targetlist = qptlist;
5673 plan->qual = qpqual;
5674 plan->lefttree = NULL;
5675 plan->righttree = NULL;
5688 bool funcordinality)
5693 plan->targetlist = qptlist;
5694 plan->qual = qpqual;
5695 plan->lefttree = NULL;
5696 plan->righttree = NULL;
5713 plan->targetlist = qptlist;
5714 plan->qual = qpqual;
5715 plan->lefttree = NULL;
5716 plan->righttree = NULL;
5732 plan->targetlist = qptlist;
5733 plan->qual = qpqual;
5734 plan->lefttree = NULL;
5735 plan->righttree = NULL;
5752 plan->targetlist = qptlist;
5753 plan->qual = qpqual;
5754 plan->lefttree = NULL;
5755 plan->righttree = NULL;
5773 plan->targetlist = qptlist;
5774 plan->qual = qpqual;
5775 plan->lefttree = NULL;
5776 plan->righttree = NULL;
5792 plan->targetlist = qptlist;
5793 plan->qual = qpqual;
5794 plan->lefttree = NULL;
5795 plan->righttree = NULL;
5808 List *fdw_scan_tlist,
5809 List *fdw_recheck_quals,
5816 plan->targetlist = qptlist;
5817 plan->qual = qpqual;
5818 plan->lefttree = outer_plan;
5819 plan->righttree = NULL;
5854 plan->targetlist = tlist;
5856 plan->lefttree = lefttree;
5857 plan->righttree = righttree;
5877 foreach(slitem, distinctList)
5883 dupColIdx[keyno] = tle->
resno;
5884 dupOperators[keyno] = sortcl->
eqop;
5889 node->dupColIdx = dupColIdx;
5890 node->dupOperators = dupOperators;
5891 node->dupCollations = dupCollations;
5906 plan->lefttree = NULL;
5907 plan->righttree = NULL;
5921 plan->lefttree = NULL;
5922 plan->righttree = NULL;
5941 plan->targetlist = tlist;
5942 plan->qual = otherclauses;
5943 plan->lefttree = lefttree;
5944 plan->righttree = righttree;
5958 List *hashoperators,
5959 List *hashcollations,
5969 plan->targetlist = tlist;
5970 plan->qual = otherclauses;
5971 plan->lefttree = lefttree;
5972 plan->righttree = righttree;
5996 plan->lefttree = lefttree;
5997 plan->righttree = NULL;
6013 Oid *mergecollations,
6014 bool *mergereversals,
6015 bool *mergenullsfirst,
6020 bool skip_mark_restore)
6025 plan->targetlist = tlist;
6026 plan->qual = otherclauses;
6027 plan->lefttree = lefttree;
6028 plan->righttree = righttree;
6031 node->mergeFamilies = mergefamilies;
6032 node->mergeCollations = mergecollations;
6033 node->mergeReversals = mergereversals;
6034 node->mergeNullsFirst = mergenullsfirst;
6051 Oid *collations,
bool *nullsFirst)
6062 plan->lefttree = lefttree;
6063 plan->righttree = NULL;
6065 node->sortColIdx = sortColIdx;
6066 node->sortOperators = sortOperators;
6067 node->collations = collations;
6068 node->nullsFirst = nullsFirst;
6082 Oid *collations,
bool *nullsFirst)
6092 plan->lefttree = lefttree;
6093 plan->righttree = NULL;
6096 node->
sort.sortColIdx = sortColIdx;
6097 node->
sort.sortOperators = sortOperators;
6098 node->
sort.collations = collations;
6099 node->
sort.nullsFirst = nullsFirst;
6149 bool adjust_tlist_in_place,
6152 Oid **p_sortOperators,
6154 bool **p_nullsFirst)
6169 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6170 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6171 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6175 foreach(
i, pathkeys)
6193 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6199 else if (reqColIdx != NULL)
6259 elog(
ERROR,
"could not find pathkey item to sort");
6265 if (!adjust_tlist_in_place &&
6275 adjust_tlist_in_place =
true;
6297 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6298 pathkey->
pk_cmptype, pk_datatype, pk_datatype,
6302 sortColIdx[numsortkeys] = tle->
resno;
6303 sortOperators[numsortkeys] = sortop;
6310 *p_numsortkeys = numsortkeys;
6311 *p_sortColIdx = sortColIdx;
6312 *p_sortOperators = sortOperators;
6313 *p_collations = collations;
6314 *p_nullsFirst = nullsFirst;
6349 sortColIdx, sortOperators,
6350 collations, nullsFirst);
6364 Relids relids,
int nPresortedCols)
6385 sortColIdx, sortOperators,
6386 collations, nullsFirst);
6410 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6411 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6412 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6420 sortColIdx[numsortkeys] = tle->
resno;
6421 sortOperators[numsortkeys] = sortcl->
sortop;
6428 sortColIdx, sortOperators,
6429 collations, nullsFirst);
6461 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6462 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6463 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6466 foreach(l, groupcls)
6472 elog(
ERROR,
"could not retrieve tle for sort-from-groupcols");
6474 sortColIdx[numsortkeys] = tle->
resno;
6475 sortOperators[numsortkeys] = grpcl->
sortop;
6482 sortColIdx, sortOperators,
6483 collations, nullsFirst);
6494 plan->lefttree = lefttree;
6495 plan->righttree = NULL;
6514 bool unsafe_initplans;
6529 &initplan_cost, &unsafe_initplans);
6553 List *param_exprs,
bool singlerow,
bool binary_mode,
6556 double est_hit_ratio)
6563 plan->lefttree = lefttree;
6564 plan->righttree = NULL;
6567 node->hashOperators = hashoperators;
6568 node->collations = collations;
6584 int numGroupCols,
AttrNumber *grpColIdx,
Oid *grpOperators,
Oid *grpCollations,
6585 List *groupingSets,
List *chain,
double dNumGroups,
6586 Size transitionSpace,
Plan *lefttree)
6598 node->grpColIdx = grpColIdx;
6599 node->grpOperators = grpOperators;
6600 node->grpCollations = grpCollations;
6605 node->
chain = chain;
6608 plan->targetlist = tlist;
6609 plan->lefttree = lefttree;
6610 plan->righttree = NULL;
6617 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
6618 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
6619 List *runCondition,
List *qual,
bool topWindow,
Plan *lefttree)
6627 node->partColIdx = partColIdx;
6628 node->partOperators = partOperators;
6629 node->partCollations = partCollations;
6631 node->ordColIdx = ordColIdx;
6632 node->ordOperators = ordOperators;
6633 node->ordCollations = ordCollations;
6647 plan->targetlist = tlist;
6648 plan->lefttree = lefttree;
6649 plan->righttree = NULL;
6668 node->grpColIdx = grpColIdx;
6669 node->grpOperators = grpOperators;
6670 node->grpCollations = grpCollations;
6673 plan->targetlist = tlist;
6674 plan->lefttree = lefttree;
6675 plan->righttree = NULL;
6695 Oid *uniqCollations;
6700 plan->lefttree = lefttree;
6701 plan->righttree = NULL;
6711 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6713 foreach(lc, pathkeys)
6724 if (keyno >= numCols)
6735 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6748 foreach(
j,
plan->targetlist)
6763 elog(
ERROR,
"could not find pathkey item to sort");
6774 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6778 uniqColIdx[keyno] = tle->
resno;
6779 uniqOperators[keyno] = eqop;
6786 node->uniqColIdx = uniqColIdx;
6787 node->uniqOperators = uniqOperators;
6788 node->uniqCollations = uniqCollations;
6804 plan->targetlist = qptlist;
6805 plan->qual = qpqual;
6806 plan->lefttree = subplan;
6807 plan->righttree = NULL;
6825 List *groupList,
long numGroups)
6834 bool *cmpNullsFirst;
6837 plan->targetlist = tlist;
6839 plan->lefttree = lefttree;
6840 plan->righttree = righttree;
6849 cmpNullsFirst = (
bool *)
palloc(
sizeof(
bool) * numCols);
6851 foreach(slitem, groupList)
6856 cmpColIdx[keyno] = tle->
resno;
6858 cmpOperators[keyno] = sortcl->
eqop;
6860 cmpOperators[keyno] = sortcl->
sortop;
6870 node->cmpColIdx = cmpColIdx;
6871 node->cmpOperators = cmpOperators;
6872 node->cmpCollations = cmpCollations;
6873 node->cmpNullsFirst = cmpNullsFirst;
6891 plan->lefttree = lefttree;
6892 plan->righttree = NULL;
6907 Oid *uniqOperators,
Oid *uniqCollations)
6914 plan->lefttree = lefttree;
6915 plan->righttree = NULL;
6921 node->uniqColIdx = uniqColIdx;
6922 node->uniqOperators = uniqOperators;
6923 node->uniqCollations = uniqCollations;
6935 Node *resconstantqual,
6943 plan->targetlist = tlist;
6945 plan->lefttree = subplan;
6946 plan->righttree = NULL;
6966 Node *resconstantqual,
6972 plan->targetlist = tlist;
6974 plan->lefttree = NULL;
6975 plan->righttree = NULL;
6995 plan->targetlist = tlist;
6997 plan->lefttree = subplan;
6998 plan->righttree = NULL;
7009 CmdType operation,
bool canSetTag,
7011 List *resultRelations,
7012 List *updateColnosLists,
7013 List *withCheckOptionLists,
List *returningLists,
7015 List *mergeActionLists,
List *mergeJoinConditions,
7019 bool returning_old_or_new =
false;
7020 bool returning_old_or_new_valid =
false;
7021 bool transition_tables =
false;
7022 bool transition_tables_valid =
false;
7023 List *fdw_private_list;
7031 updateColnosLists ==
NIL));
7098 fdw_private_list =
NIL;
7099 direct_modify_plans = NULL;
7101 foreach(lc, resultRelations)
7115 if (rti < root->simple_rel_array_size &&
7116 root->simple_rel_array[rti] != NULL)
7120 fdwroutine = resultRel->fdwroutine;
7127 rte->relkind == RELKIND_FOREIGN_TABLE)
7135 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
7136 errmsg(
"access to non-system foreign table is restricted")));
7152 if (operation ==
CMD_MERGE && fdwroutine != NULL)
7157 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7158 errmsg(
"cannot execute MERGE on relation \"%s\"",
7171 direct_modify =
false;
7172 if (fdwroutine != NULL &&
7177 withCheckOptionLists ==
NIL &&
7185 if (!returning_old_or_new_valid)
7187 returning_old_or_new =
7189 root->parse->returningList);
7190 returning_old_or_new_valid =
true;
7192 if (!returning_old_or_new)
7194 if (!transition_tables_valid)
7199 transition_tables_valid =
true;
7201 if (!transition_tables)
7209 if (!direct_modify &&
7210 fdwroutine != NULL &&
7215 fdw_private_list =
lappend(fdw_private_list, fdw_private);
7238 case T_IncrementalSort:
7245 case T_RecursiveUnion:
7295 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)
long clamp_cardinality_to_long(Cardinality x)
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 SetOp * make_setop(SetOpCmd cmd, SetOpStrategy strategy, List *tlist, Plan *lefttree, Plan *righttree, List *groupList, long numGroups)
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 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)
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 RecursiveUnion * make_recursive_union(List *tlist, Plan *lefttree, Plan *righttree, int wtParam, List *distinctList, long numGroups)
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)
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)
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)
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)