70#define CP_EXACT_TLIST 0x0001
71#define CP_SMALL_TLIST 0x0002
72#define CP_LABEL_TLIST 0x0004
73#define CP_IGNORE_TLIST 0x0008
128 List *tlist,
List *scan_clauses,
bool indexonly);
169 List **stripped_indexquals_p,
170 List **fixed_indexquals_p);
181 double limit_tuples);
183 List *pathkeys,
double limit_tuples);
189 List *indexorderby,
List *indexorderbyorig,
190 List *indexorderbyops,
200 List *indexqualorig);
204 List *bitmapqualorig,
221 Index scanrelid,
int ctePlanId,
int cteParam);
223 Index scanrelid,
char *enrname);
225 Index scanrelid,
int wtParam);
235 List *joinclauses,
List *otherclauses,
List *nestParams,
237 JoinType jointype,
bool inner_unique);
239 List *joinclauses,
List *otherclauses,
241 List *hashoperators,
List *hashcollations,
244 JoinType jointype,
bool inner_unique);
251 List *joinclauses,
List *otherclauses,
254 Oid *mergecollations,
255 bool *mergereversals,
256 bool *mergenullsfirst,
258 JoinType jointype,
bool inner_unique,
259 bool skip_mark_restore);
262 Oid *collations,
bool *nullsFirst);
264 int numCols,
int nPresortedCols,
266 Oid *collations,
bool *nullsFirst);
270 bool adjust_tlist_in_place,
273 Oid **p_sortOperators,
275 bool **p_nullsFirst);
279 List *pathkeys,
Relids relids,
int nPresortedCols);
285 Oid *collations,
List *param_exprs,
286 bool singlerow,
bool binary_mode,
289 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
290 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
291 List *runCondition,
List *qual,
bool topWindow,
298 List *pathkeys,
int numCols);
300 int nworkers,
int rescan_param,
bool single_copy,
Plan *subplan);
303 List *groupList,
long numGroups);
308 CmdType operation,
bool canSetTag,
310 bool partColsUpdated,
311 List *resultRelations,
312 List *updateColnosLists,
313 List *withCheckOptionLists,
List *returningLists,
315 List *mergeActionLists,
List *mergeJoinConditions,
345 root->curOuterRels = NULL;
371 if (
root->curOuterParams !=
NIL)
372 elog(
ERROR,
"failed to assign all NestLoopParams to plan nodes");
400 case T_IndexOnlyScan:
401 case T_BitmapHeapScan:
406 case T_TableFuncScan:
409 case T_WorkTableScan:
410 case T_NamedTuplestoreScan:
493 case T_IncrementalSort:
522 case T_RecursiveUnion:
545 elog(
ERROR,
"unrecognized node type: %d",
546 (
int) best_path->pathtype);
563 List *gating_clauses;
582 case T_IndexOnlyScan:
596 if (best_path->param_info)
598 best_path->param_info->ppi_clauses);
615 best_path->
pathtype == T_CustomScan);
616 if (best_path->
pathtype == T_ForeignScan)
617 join_clauses = ((
ForeignPath *) best_path)->fdw_restrictinfo;
619 join_clauses = ((
CustomPath *) best_path)->custom_restrictinfo;
644 if (best_path->
pathtype == T_IndexOnlyScan)
701 case T_IndexOnlyScan:
709 case T_BitmapHeapScan:
744 case T_TableFuncScan:
765 case T_NamedTuplestoreScan:
779 case T_WorkTableScan:
801 elog(
ERROR,
"unrecognized node type: %d",
828 Index *sortgrouprefs = path->pathtarget->sortgrouprefs;
832 foreach(v, path->pathtarget->exprs)
843 if (path->param_info)
912 path->pathtarget->exprs ==
NIL)
930 foreach(lc,
root->placeholder_list)
944 if (path->
pathtype == T_IndexOnlyScan)
950 if (!indexinfo->canreturn[
i])
969 foreach(lc, path->pathtarget->exprs)
973 if (path->pathtarget->sortgrouprefs[
i])
975 if (expr &&
IsA(expr,
Var))
977 int attno = ((
Var *) expr)->varattno;
1005 if (!
root->hasPseudoConstantQuals)
1052 (
Node *) gating_quals,
1084 List *gating_clauses;
1086 switch (best_path->path.pathtype)
1101 elog(
ERROR,
"unrecognized node type: %d",
1102 (
int) best_path->path.pathtype);
1124 if (get_loc_restrictinfo(best_path) !=
NIL)
1144 case T_SubqueryScanPath:
1167 FdwRoutine *fdwroutine = path->parent->fdwroutine;
1176 Assert(fdwroutine != NULL);
1182 case T_ProjectionPath:
1203 plan->async_capable =
true;
1221 bool tlist_was_changed =
false;
1225 int nasyncplans = 0;
1227 int nodenumsortkeys = 0;
1229 Oid *nodeSortOperators = NULL;
1230 Oid *nodeCollations = NULL;
1231 bool *nodeNullsFirst = NULL;
1232 bool consider_async =
false;
1270 plan->plan.targetlist = tlist;
1272 plan->plan.lefttree = NULL;
1273 plan->plan.righttree = NULL;
1276 if (pathkeys !=
NIL)
1285 best_path->
path.parent->relids,
1293 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->plan.targetlist));
1302 foreach(subpaths, best_path->
subpaths)
1314 if (pathkeys !=
NIL)
1344 Assert(numsortkeys == nodenumsortkeys);
1345 if (memcmp(sortColIdx, nodeSortColIdx,
1347 elog(
ERROR,
"Append child's targetlist doesn't match Append");
1348 Assert(memcmp(sortOperators, nodeSortOperators,
1349 numsortkeys *
sizeof(
Oid)) == 0);
1350 Assert(memcmp(collations, nodeCollations,
1351 numsortkeys *
sizeof(
Oid)) == 0);
1352 Assert(memcmp(nullsFirst, nodeNullsFirst,
1353 numsortkeys *
sizeof(
bool)) == 0);
1359 sortColIdx, sortOperators,
1360 collations, nullsFirst);
1374 subplans =
lappend(subplans, subplan);
1378 plan->part_prune_index = -1;
1391 if (best_path->
path.param_info)
1393 List *prmquals = best_path->
path.param_info->ppi_clauses;
1402 if (prunequal !=
NIL)
1408 plan->appendplans = subplans;
1409 plan->nasyncplans = nasyncplans;
1423 plan->plan.parallel_safe);
1444 bool tlist_was_changed;
1457 plan->targetlist = tlist;
1459 plan->lefttree = NULL;
1460 plan->righttree = NULL;
1470 best_path->
path.parent->relids,
1475 &node->sortOperators,
1478 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->targetlist));
1485 foreach(subpaths, best_path->
subpaths)
1517 if (memcmp(sortColIdx, node->sortColIdx,
1519 elog(
ERROR,
"MergeAppend child's targetlist doesn't match MergeAppend");
1520 Assert(memcmp(sortOperators, node->sortOperators,
1521 numsortkeys *
sizeof(
Oid)) == 0);
1522 Assert(memcmp(collations, node->collations,
1523 numsortkeys *
sizeof(
Oid)) == 0);
1524 Assert(memcmp(nullsFirst, node->nullsFirst,
1525 numsortkeys *
sizeof(
bool)) == 0);
1531 sortColIdx, sortOperators,
1532 collations, nullsFirst);
1538 subplans =
lappend(subplans, subplan);
1558 if (prunequal !=
NIL)
1688 operators =
palloc(nkeys *
sizeof(
Oid));
1689 collations =
palloc(nkeys *
sizeof(
Oid));
1697 operators[
i] = opno;
1732 Oid *groupCollations;
1767 foreach(l, uniq_exprs)
1779 newtlist =
lappend(newtlist, tle);
1799 groupCollations = (
Oid *)
palloc(numGroupCols *
sizeof(
Oid));
1802 foreach(l, uniq_exprs)
1809 elog(
ERROR,
"failed to find unique expression in subplan tlist");
1810 groupColIdx[groupColPos] = tle->
resno;
1817 Oid *groupOperators;
1825 groupOperators = (
Oid *)
palloc(numGroupCols *
sizeof(
Oid));
1827 foreach(l, in_operators)
1833 elog(
ERROR,
"could not find compatible hash operator for operator %u",
1835 groupOperators[groupColPos++] = eq_oper;
1864 foreach(l, in_operators)
1874 elog(
ERROR,
"could not find ordering operator for equality operator %u",
1885 elog(
ERROR,
"could not find equality operator for ordering operator %u",
1889 groupColIdx[groupColPos]);
1895 sortcl->
eqop = eqop;
1899 sortcl->hashable =
false;
1900 sortList =
lappend(sortList, sortcl);
1947 root->glob->parallelModeNeeded =
true;
1983 best_path->
subpath->parent->relids,
1984 gm_plan->sortColIdx,
1987 &gm_plan->sortColIdx,
1988 &gm_plan->sortOperators,
1989 &gm_plan->collations,
1990 &gm_plan->nullsFirst);
2002 root->glob->parallelModeNeeded =
true;
2020 bool needs_result_node =
false;
2046 best_path->
path.pathtarget);
2080 if (!needs_result_node)
2084 plan->targetlist = tlist;
2090 plan->plan_width = best_path->
path.pathtarget->width;
2131 plan->parallel_safe = parallel_safe;
2160 tlist_parallel_safe);
2198 best_path->
path.parent->relids : NULL);
2223 best_path->
spath.
path.parent->relids : NULL,
2363 foreach(lc, groupClause)
2370 return new_grpColIdx;
2415 foreach(lc,
root->processed_groupClause)
2426 foreach(lc,
root->processed_groupClause)
2439 root->grouping_map = grouping_map;
2456 Plan *sort_plan = NULL;
2462 if (!rollup->
is_hashed && !is_first_sort)
2464 sort_plan = (
Plan *)
2471 is_first_sort =
false;
2503 chain =
lappend(chain, agg_plan);
2573 0, NULL, NULL, NULL);
2579 plan->plan_rows = 1;
2580 plan->plan_width = mminfo->
path->pathtarget->width;
2581 plan->parallel_aware =
false;
2625 Oid *partCollations;
2649 partCollations = (
Oid *)
palloc(
sizeof(
Oid) * numPart);
2658 partColIdx[partNumCols] = tle->
resno;
2659 partOperators[partNumCols] = sgc->
eqop;
2666 ordCollations = (
Oid *)
palloc(
sizeof(
Oid) * numOrder);
2675 ordColIdx[ordNumCols] = tle->
resno;
2676 ordOperators[ordNumCols] = sgc->
eqop;
2853 int numUniqkeys = 0;
2855 Oid *uniqOperators = NULL;
2856 Oid *uniqCollations = NULL;
2869 uniqOperators = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2870 uniqCollations = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2873 foreach(l,
parse->sortClause)
2878 uniqColIdx[numUniqkeys] = tle->
resno;
2879 uniqOperators[numUniqkeys] = sortcl->
eqop;
2889 numUniqkeys, uniqColIdx, uniqOperators, uniqCollations);
2914 Index scan_relid = best_path->parent->relid;
2927 if (best_path->param_info)
2929 scan_clauses = (
List *)
2952 Index scan_relid = best_path->parent->relid;
2970 if (best_path->param_info)
2972 scan_clauses = (
List *)
3008 Index baserelid = best_path->
path.parent->relid;
3012 List *stripped_indexquals;
3013 List *fixed_indexquals;
3014 List *fixed_indexorderbys;
3032 &stripped_indexquals,
3069 foreach(l, scan_clauses)
3073 if (rinfo->pseudoconstant)
3081 qpqual =
lappend(qpqual, rinfo);
3099 if (best_path->
path.param_info)
3101 stripped_indexquals = (
List *)
3105 indexorderbys = (
List *)
3137 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
3139 indexorderbyops =
lappend_oid(indexorderbyops, sortop);
3156 indextle->resjunk = !indexinfo->canreturn[
i];
3168 stripped_indexquals,
3169 fixed_indexorderbys,
3178 stripped_indexquals,
3179 fixed_indexorderbys,
3200 Index baserelid = best_path->
path.parent->relid;
3201 Plan *bitmapqualplan;
3202 List *bitmapqualorig;
3215 &bitmapqualorig, &indexquals,
3248 foreach(l, scan_clauses)
3253 if (rinfo->pseudoconstant)
3262 qpqual =
lappend(qpqual, rinfo);
3284 if (best_path->
path.param_info)
3288 bitmapqualorig = (
List *)
3354 &subqual, &subindexqual,
3356 subplans =
lappend(subplans, subplan);
3360 subindexECs =
list_concat(subindexECs, subindexEC);
3367 plan->plan_width = 0;
3368 plan->parallel_aware =
false;
3371 *indexqual = subindexquals;
3372 *indexECs = subindexECs;
3380 bool const_true_subqual =
false;
3381 bool const_true_subindexqual =
false;
3401 &subqual, &subindexqual,
3403 subplans =
lappend(subplans, subplan);
3405 const_true_subqual =
true;
3406 else if (!const_true_subqual)
3409 if (subindexqual ==
NIL)
3410 const_true_subindexqual =
true;
3411 else if (!const_true_subindexqual)
3412 subindexquals =
lappend(subindexquals,
3431 plan->plan_width = 0;
3432 plan->parallel_aware =
false;
3441 if (const_true_subqual)
3447 if (const_true_subindexqual)
3450 *indexqual = subindexquals;
3460 List *subindexquals;
3474 plan->startup_cost = 0.0;
3478 plan->plan_width = 0;
3479 plan->parallel_aware =
false;
3483 subindexquals =
NIL;
3490 Assert(!rinfo->pseudoconstant);
3494 if (rinfo->parent_ec)
3495 subindexECs =
lappend(subindexECs, rinfo->parent_ec);
3510 subquals =
lappend(subquals, pred);
3511 subindexquals =
lappend(subindexquals, pred);
3515 *indexqual = subindexquals;
3516 *indexECs = subindexECs;
3537 Index scan_relid = best_path->
path.parent->relid;
3568 foreach(l, scan_clauses)
3572 if (rinfo->pseudoconstant)
3578 qpqual =
lappend(qpqual, rinfo);
3580 scan_clauses = qpqual;
3606 if (best_path->
path.param_info)
3610 scan_clauses = (
List *)
3634 Index scan_relid = best_path->
path.parent->relid;
3650 foreach(l, scan_clauses)
3654 if (rinfo->pseudoconstant)
3658 qpqual =
lappend(qpqual, rinfo);
3660 scan_clauses = qpqual;
3671 if (best_path->
path.param_info)
3673 tidrangequals = (
List *)
3675 scan_clauses = (
List *)
3730 if (best_path->
path.param_info)
3734 scan_clauses = (
List *)
3758 Index scan_relid = best_path->parent->relid;
3775 if (best_path->param_info)
3777 scan_clauses = (
List *)
3801 Index scan_relid = best_path->parent->relid;
3818 if (best_path->param_info)
3820 scan_clauses = (
List *)
3844 Index scan_relid = best_path->parent->relid;
3861 if (best_path->param_info)
3863 scan_clauses = (
List *)
3866 values_lists = (
List *)
3888 Index scan_relid = best_path->parent->relid;
3901 Assert(!rte->self_reference);
3908 while (levelsup-- > 0)
3910 cteroot = cteroot->parent_root;
3939 if (ctesplan->
plan_id == plan_id)
3958 if (best_path->param_info)
3960 scan_clauses = (
List *)
3964 scan_plan =
make_ctescan(tlist, scan_clauses, scan_relid,
3965 plan_id, cte_param_id);
3983 Index scan_relid = best_path->parent->relid;
3997 if (best_path->param_info)
3999 scan_clauses = (
List *)
4022 Index scan_relid = best_path->parent->relid;
4036 if (best_path->param_info)
4038 scan_clauses = (
List *)
4059 Index scan_relid = best_path->parent->relid;
4067 Assert(rte->self_reference);
4079 while (levelsup-- > 0)
4081 cteroot = cteroot->parent_root;
4095 if (best_path->param_info)
4097 scan_clauses = (
List *)
4122 Plan *outer_plan = NULL;
4124 Assert(rel->fdwroutine != NULL);
4142 rel_oid = rte->relid;
4158 scan_plan = rel->fdwroutine->GetForeignPlan(
root, rel, rel_oid,
4160 tlist, scan_clauses,
4188 root->outer_join_rels);
4196 root->glob->dependsOnRole =
true;
4206 if (best_path->
path.param_info)
4208 scan_plan->
scan.plan.qual = (
List *)
4322 if (best_path->
path.param_info)
4382 root->curOuterRels = saveOuterRels;
4392 best_path->
jpath.path.parent->relids,
4393 &joinclauses, &otherclauses);
4403 if (best_path->
jpath.path.param_info)
4405 joinclauses = (
List *)
4407 otherclauses = (
List *)
4443 List *outerpathkeys;
4444 List *innerpathkeys;
4447 Oid *mergecollations;
4448 bool *mergereversals;
4449 bool *mergenullsfirst;
4480 best_path->
jpath.path.parent->relids,
4481 &joinclauses, &otherclauses);
4501 if (best_path->
jpath.path.param_info)
4503 joinclauses = (
List *)
4505 otherclauses = (
List *)
4522 Relids outer_relids = outer_path->parent->relids;
4524 bool use_incremental_sort =
false;
4540 if (presorted_keys > 0)
4541 use_incremental_sort =
true;
4544 if (!use_incremental_sort)
4546 sort_plan = (
Plan *)
4555 sort_plan = (
Plan *)
4567 outer_plan = sort_plan;
4580 Relids inner_relids = inner_path->parent->relids;
4608 inner_plan = matplan;
4620 mergefamilies = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4621 mergecollations = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4622 mergereversals = (
bool *)
palloc(nClauses *
sizeof(
bool));
4623 mergenullsfirst = (
bool *)
palloc(nClauses *
sizeof(
bool));
4637 bool first_inner_match =
false;
4640 if (rinfo->outer_is_left)
4642 oeclass = rinfo->left_ec;
4643 ieclass = rinfo->right_ec;
4647 oeclass = rinfo->right_ec;
4648 ieclass = rinfo->left_ec;
4668 if (oeclass != opeclass)
4672 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4674 opeclass = opathkey->pk_eclass;
4675 lop =
lnext(outerpathkeys, lop);
4676 if (oeclass != opeclass)
4677 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4698 ipeclass = ipathkey->pk_eclass;
4699 if (ieclass == ipeclass)
4702 lip =
lnext(innerpathkeys, lip);
4703 first_inner_match =
true;
4706 if (!first_inner_match)
4711 foreach(l2, innerpathkeys)
4716 ipeclass = ipathkey->pk_eclass;
4717 if (ieclass == ipeclass)
4720 if (ieclass != ipeclass)
4721 elog(
ERROR,
"inner pathkeys do not match mergeclauses");
4739 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation)
4740 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4741 if (first_inner_match &&
4744 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4748 mergecollations[
i] = opathkey->pk_eclass->ec_collation;
4801 bool skewInherit =
false;
4826 best_path->
jpath.path.parent->relids,
4827 &joinclauses, &otherclauses);
4847 if (best_path->
jpath.path.param_info)
4849 joinclauses = (
List *)
4851 otherclauses = (
List *)
4884 rte =
root->simple_rte_array[var->
varno];
4887 skewTable = rte->relid;
4889 skewInherit = rte->
inh;
4902 foreach(lc, hashclauses)
4907 hashcollations =
lappend_oid(hashcollations, hclause->inputcollid);
4933 if (best_path->
jpath.path.parallel_aware)
5006 root->curOuterRels))
5026 newphv->phexpr = (
Expr *)
5029 return (
Node *) newphv;
5059 List **stripped_indexquals_p,
List **fixed_indexquals_p)
5062 List *stripped_indexquals;
5063 List *fixed_indexquals;
5066 stripped_indexquals = fixed_indexquals =
NIL;
5079 stripped_indexquals =
lappend(stripped_indexquals, clause);
5082 fixed_indexquals =
lappend(fixed_indexquals, clause);
5086 *stripped_indexquals_p = stripped_indexquals;
5087 *fixed_indexquals_p = fixed_indexquals;
5102 List *fixed_indexorderbys;
5106 fixed_indexorderbys =
NIL;
5114 fixed_indexorderbys =
lappend(fixed_indexorderbys, clause);
5117 return fixed_indexorderbys;
5182 elog(
ERROR,
"unsupported indexqual type: %d",
5211 Assert(indexcol >= 0 && indexcol < index->ncolumns);
5213 if (
index->indexkeys[indexcol] != 0)
5217 ((
Var *) node)->varno ==
index->rel->relid &&
5218 ((
Var *) node)->varattno ==
index->indexkeys[indexcol])
5223 return (
Node *) result;
5226 elog(
ERROR,
"index key does not match expected index column");
5231 for (pos = 0; pos <
index->ncolumns; pos++)
5233 if (
index->indexkeys[pos] == 0)
5235 if (indexpr_item == NULL)
5236 elog(
ERROR,
"too few entries in indexprs list");
5237 if (pos == indexcol)
5244 if (
equal(node, indexkey))
5250 return (
Node *) result;
5253 elog(
ERROR,
"index key does not match expected index column");
5255 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5260 elog(
ERROR,
"index key does not match expected index column");
5296 temp->opresulttype = clause->opresulttype;
5297 temp->opretset = clause->opretset;
5298 temp->opcollid = clause->opcollid;
5299 temp->inputcollid = clause->inputcollid;
5304 t_list =
lappend(t_list, temp);
5305 restrictinfo->outer_is_left =
false;
5310 t_list =
lappend(t_list, clause);
5311 restrictinfo->outer_is_left =
true;
5357 Index security_level;
5375 foreach(lc, clauses)
5381 items[
i].clause = clause;
5398 items[
i].security_level = 0;
5403 items[
i].security_level = 0;
5414 QualItem newitem =
items[
i];
5418 for (
j =
i;
j > 0;
j--)
5420 QualItem *olditem = &
items[
j - 1];
5422 if (newitem.security_level > olditem->security_level ||
5423 (newitem.security_level == olditem->security_level &&
5424 newitem.cost >= olditem->cost))
5451 dest->plan_width = src->pathtarget->width;
5469 dest->parallel_aware =
false;
5486 Plan *lefttree =
plan->plan.lefttree;
5492 plan->plan.disabled_nodes,
5503 plan->plan.parallel_aware =
false;
5513 List *pathkeys,
double limit_tuples)
5515 Plan *lefttree =
plan->sort.plan.lefttree;
5521 plan->nPresortedCols,
5522 plan->sort.plan.disabled_nodes,
5534 plan->sort.plan.parallel_aware =
false;
5581 plan->targetlist = qptlist;
5582 plan->qual = qpqual;
5583 plan->lefttree = NULL;
5584 plan->righttree = NULL;
5599 plan->targetlist = qptlist;
5600 plan->qual = qpqual;
5601 plan->lefttree = NULL;
5602 plan->righttree = NULL;
5615 List *indexqualorig,
5617 List *indexorderbyorig,
5618 List *indexorderbyops,
5624 plan->targetlist = qptlist;
5625 plan->qual = qpqual;
5626 plan->lefttree = NULL;
5627 plan->righttree = NULL;
5654 plan->targetlist = qptlist;
5655 plan->qual = qpqual;
5656 plan->lefttree = NULL;
5657 plan->righttree = NULL;
5673 List *indexqualorig)
5680 plan->lefttree = NULL;
5681 plan->righttree = NULL;
5694 List *bitmapqualorig,
5700 plan->targetlist = qptlist;
5701 plan->qual = qpqual;
5702 plan->lefttree = lefttree;
5703 plan->righttree = NULL;
5719 plan->targetlist = qptlist;
5720 plan->qual = qpqual;
5721 plan->lefttree = NULL;
5722 plan->righttree = NULL;
5733 List *tidrangequals)
5738 plan->targetlist = qptlist;
5739 plan->qual = qpqual;
5740 plan->lefttree = NULL;
5741 plan->righttree = NULL;
5757 plan->targetlist = qptlist;
5758 plan->qual = qpqual;
5759 plan->lefttree = NULL;
5760 plan->righttree = NULL;
5773 bool funcordinality)
5778 plan->targetlist = qptlist;
5779 plan->qual = qpqual;
5780 plan->lefttree = NULL;
5781 plan->righttree = NULL;
5798 plan->targetlist = qptlist;
5799 plan->qual = qpqual;
5800 plan->lefttree = NULL;
5801 plan->righttree = NULL;
5817 plan->targetlist = qptlist;
5818 plan->qual = qpqual;
5819 plan->lefttree = NULL;
5820 plan->righttree = NULL;
5837 plan->targetlist = qptlist;
5838 plan->qual = qpqual;
5839 plan->lefttree = NULL;
5840 plan->righttree = NULL;
5858 plan->targetlist = qptlist;
5859 plan->qual = qpqual;
5860 plan->lefttree = NULL;
5861 plan->righttree = NULL;
5877 plan->targetlist = qptlist;
5878 plan->qual = qpqual;
5879 plan->lefttree = NULL;
5880 plan->righttree = NULL;
5893 List *fdw_scan_tlist,
5894 List *fdw_recheck_quals,
5901 plan->targetlist = qptlist;
5902 plan->qual = qpqual;
5903 plan->lefttree = outer_plan;
5904 plan->righttree = NULL;
5939 plan->targetlist = tlist;
5941 plan->lefttree = lefttree;
5942 plan->righttree = righttree;
5962 foreach(slitem, distinctList)
5968 dupColIdx[keyno] = tle->
resno;
5969 dupOperators[keyno] = sortcl->
eqop;
5974 node->dupColIdx = dupColIdx;
5975 node->dupOperators = dupOperators;
5976 node->dupCollations = dupCollations;
5991 plan->lefttree = NULL;
5992 plan->righttree = NULL;
6006 plan->lefttree = NULL;
6007 plan->righttree = NULL;
6026 plan->targetlist = tlist;
6027 plan->qual = otherclauses;
6028 plan->lefttree = lefttree;
6029 plan->righttree = righttree;
6043 List *hashoperators,
6044 List *hashcollations,
6054 plan->targetlist = tlist;
6055 plan->qual = otherclauses;
6056 plan->lefttree = lefttree;
6057 plan->righttree = righttree;
6081 plan->lefttree = lefttree;
6082 plan->righttree = NULL;
6098 Oid *mergecollations,
6099 bool *mergereversals,
6100 bool *mergenullsfirst,
6105 bool skip_mark_restore)
6110 plan->targetlist = tlist;
6111 plan->qual = otherclauses;
6112 plan->lefttree = lefttree;
6113 plan->righttree = righttree;
6116 node->mergeFamilies = mergefamilies;
6117 node->mergeCollations = mergecollations;
6118 node->mergeReversals = mergereversals;
6119 node->mergeNullsFirst = mergenullsfirst;
6136 Oid *collations,
bool *nullsFirst)
6147 plan->lefttree = lefttree;
6148 plan->righttree = NULL;
6150 node->sortColIdx = sortColIdx;
6151 node->sortOperators = sortOperators;
6152 node->collations = collations;
6153 node->nullsFirst = nullsFirst;
6167 Oid *collations,
bool *nullsFirst)
6177 plan->lefttree = lefttree;
6178 plan->righttree = NULL;
6181 node->
sort.sortColIdx = sortColIdx;
6182 node->
sort.sortOperators = sortOperators;
6183 node->
sort.collations = collations;
6184 node->
sort.nullsFirst = nullsFirst;
6234 bool adjust_tlist_in_place,
6237 Oid **p_sortOperators,
6239 bool **p_nullsFirst)
6254 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6255 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6256 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6260 foreach(
i, pathkeys)
6278 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6284 else if (reqColIdx != NULL)
6344 elog(
ERROR,
"could not find pathkey item to sort");
6350 if (!adjust_tlist_in_place &&
6360 adjust_tlist_in_place =
true;
6382 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6383 pathkey->
pk_cmptype, pk_datatype, pk_datatype,
6387 sortColIdx[numsortkeys] = tle->
resno;
6388 sortOperators[numsortkeys] = sortop;
6395 *p_numsortkeys = numsortkeys;
6396 *p_sortColIdx = sortColIdx;
6397 *p_sortOperators = sortOperators;
6398 *p_collations = collations;
6399 *p_nullsFirst = nullsFirst;
6434 sortColIdx, sortOperators,
6435 collations, nullsFirst);
6449 Relids relids,
int nPresortedCols)
6470 sortColIdx, sortOperators,
6471 collations, nullsFirst);
6495 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6496 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6497 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6505 sortColIdx[numsortkeys] = tle->
resno;
6506 sortOperators[numsortkeys] = sortcl->
sortop;
6513 sortColIdx, sortOperators,
6514 collations, nullsFirst);
6546 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6547 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6548 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6551 foreach(l, groupcls)
6557 elog(
ERROR,
"could not retrieve tle for sort-from-groupcols");
6559 sortColIdx[numsortkeys] = tle->
resno;
6560 sortOperators[numsortkeys] = grpcl->
sortop;
6567 sortColIdx, sortOperators,
6568 collations, nullsFirst);
6579 plan->lefttree = lefttree;
6580 plan->righttree = NULL;
6599 bool unsafe_initplans;
6614 &initplan_cost, &unsafe_initplans);
6638 List *param_exprs,
bool singlerow,
bool binary_mode,
6646 plan->lefttree = lefttree;
6647 plan->righttree = NULL;
6650 node->hashOperators = hashoperators;
6651 node->collations = collations;
6664 int numGroupCols,
AttrNumber *grpColIdx,
Oid *grpOperators,
Oid *grpCollations,
6665 List *groupingSets,
List *chain,
double dNumGroups,
6666 Size transitionSpace,
Plan *lefttree)
6678 node->grpColIdx = grpColIdx;
6679 node->grpOperators = grpOperators;
6680 node->grpCollations = grpCollations;
6685 node->
chain = chain;
6688 plan->targetlist = tlist;
6689 plan->lefttree = lefttree;
6690 plan->righttree = NULL;
6697 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
6698 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
6699 List *runCondition,
List *qual,
bool topWindow,
Plan *lefttree)
6707 node->partColIdx = partColIdx;
6708 node->partOperators = partOperators;
6709 node->partCollations = partCollations;
6711 node->ordColIdx = ordColIdx;
6712 node->ordOperators = ordOperators;
6713 node->ordCollations = ordCollations;
6727 plan->targetlist = tlist;
6728 plan->lefttree = lefttree;
6729 plan->righttree = NULL;
6748 node->grpColIdx = grpColIdx;
6749 node->grpOperators = grpOperators;
6750 node->grpCollations = grpCollations;
6753 plan->targetlist = tlist;
6754 plan->lefttree = lefttree;
6755 plan->righttree = NULL;
6774 Oid *uniqCollations;
6779 plan->lefttree = lefttree;
6780 plan->righttree = NULL;
6789 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6791 foreach(slitem, distinctList)
6796 uniqColIdx[keyno] = tle->
resno;
6797 uniqOperators[keyno] = sortcl->
eqop;
6804 node->uniqColIdx = uniqColIdx;
6805 node->uniqOperators = uniqOperators;
6806 node->uniqCollations = uniqCollations;
6822 Oid *uniqCollations;
6827 plan->lefttree = lefttree;
6828 plan->righttree = NULL;
6838 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6840 foreach(lc, pathkeys)
6851 if (keyno >= numCols)
6862 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6875 foreach(
j,
plan->targetlist)
6890 elog(
ERROR,
"could not find pathkey item to sort");
6901 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6905 uniqColIdx[keyno] = tle->
resno;
6906 uniqOperators[keyno] = eqop;
6913 node->uniqColIdx = uniqColIdx;
6914 node->uniqOperators = uniqOperators;
6915 node->uniqCollations = uniqCollations;
6931 plan->targetlist = qptlist;
6932 plan->qual = qpqual;
6933 plan->lefttree = subplan;
6934 plan->righttree = NULL;
6952 List *groupList,
long numGroups)
6961 bool *cmpNullsFirst;
6964 plan->targetlist = tlist;
6966 plan->lefttree = lefttree;
6967 plan->righttree = righttree;
6976 cmpNullsFirst = (
bool *)
palloc(
sizeof(
bool) * numCols);
6978 foreach(slitem, groupList)
6983 cmpColIdx[keyno] = tle->
resno;
6985 cmpOperators[keyno] = sortcl->
eqop;
6987 cmpOperators[keyno] = sortcl->
sortop;
6997 node->cmpColIdx = cmpColIdx;
6998 node->cmpOperators = cmpOperators;
6999 node->cmpCollations = cmpCollations;
7000 node->cmpNullsFirst = cmpNullsFirst;
7018 plan->lefttree = lefttree;
7019 plan->righttree = NULL;
7034 Oid *uniqOperators,
Oid *uniqCollations)
7041 plan->lefttree = lefttree;
7042 plan->righttree = NULL;
7048 node->uniqColIdx = uniqColIdx;
7049 node->uniqOperators = uniqOperators;
7050 node->uniqCollations = uniqCollations;
7061 Node *resconstantqual,
7067 plan->targetlist = tlist;
7069 plan->lefttree = subplan;
7070 plan->righttree = NULL;
7087 plan->targetlist = tlist;
7089 plan->lefttree = subplan;
7090 plan->righttree = NULL;
7101 CmdType operation,
bool canSetTag,
7103 bool partColsUpdated,
7104 List *resultRelations,
7105 List *updateColnosLists,
7106 List *withCheckOptionLists,
List *returningLists,
7108 List *mergeActionLists,
List *mergeJoinConditions,
7112 bool returning_old_or_new =
false;
7113 bool returning_old_or_new_valid =
false;
7114 List *fdw_private_list;
7122 updateColnosLists ==
NIL));
7190 fdw_private_list =
NIL;
7191 direct_modify_plans = NULL;
7193 foreach(lc, resultRelations)
7207 if (rti < root->simple_rel_array_size &&
7208 root->simple_rel_array[rti] != NULL)
7212 fdwroutine = resultRel->fdwroutine;
7219 rte->relkind == RELKIND_FOREIGN_TABLE)
7227 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
7228 errmsg(
"access to non-system foreign table is restricted")));
7244 if (operation ==
CMD_MERGE && fdwroutine != NULL)
7249 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7250 errmsg(
"cannot execute MERGE on relation \"%s\"",
7263 direct_modify =
false;
7264 if (fdwroutine != NULL &&
7269 withCheckOptionLists ==
NIL &&
7274 if (!returning_old_or_new_valid)
7276 returning_old_or_new =
7278 root->parse->returningList);
7279 returning_old_or_new_valid =
true;
7281 if (!returning_old_or_new)
7287 if (!direct_modify &&
7288 fdwroutine != NULL &&
7293 fdw_private_list =
lappend(fdw_private_list, fdw_private);
7316 case T_IncrementalSort:
7323 case T_RecursiveUnion:
7373 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)
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 Unique * make_unique_from_sortclauses(Plan *lefttree, List *distinctList)
static Plan * create_join_plan(PlannerInfo *root, JoinPath *best_path)
static bool use_physical_tlist(PlannerInfo *root, Path *path, int flags)
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)
static Memoize * make_memoize(Plan *lefttree, Oid *hashoperators, Oid *collations, List *param_exprs, bool singlerow, bool binary_mode, uint32 est_entries, Bitmapset *keyparamids)
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 Result * make_result(List *tlist, Node *resconstantqual, Plan *subplan)
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 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 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 Unique * make_unique_from_pathkeys(Plan *lefttree, List *pathkeys, int numCols)
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 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 Unique * create_upper_unique_plan(PlannerInfo *root, UpperUniquePath *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 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 ModifyTable * make_modifytable(PlannerInfo *root, Plan *subplan, CmdType operation, bool canSetTag, Index nominalRelation, Index rootRelation, bool partColsUpdated, List *resultRelations, List *updateColnosLists, List *withCheckOptionLists, List *returningLists, List *rowMarks, OnConflictExpr *onconflict, List *mergeActionLists, List *mergeJoinConditions, int epqParam)
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 Plan * create_unique_plan(PlannerInfo *root, UniquePath *best_path, int flags)
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)
bool get_compatible_hash_operators(Oid opno, Oid *lhs_opno, Oid *rhs_opno)
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
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)
List * identify_current_nestloop_params(PlannerInfo *root, Relids leftrelids)
void process_subquery_nestloop_params(PlannerInfo *root, List *subplan_params)
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)
Index assignSortGroupRef(TargetEntry *tle, List *tlist)
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 planner_rt_fetch(rti, root)
#define IS_OTHER_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)
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
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)