69 #define CP_EXACT_TLIST 0x0001
70 #define CP_SMALL_TLIST 0x0002
71 #define CP_LABEL_TLIST 0x0004
72 #define CP_IGNORE_TLIST 0x0008
127 List *tlist,
List *scan_clauses,
bool indexonly);
168 List **stripped_indexquals_p,
169 List **fixed_indexquals_p);
180 double limit_tuples);
186 List *indexorderby,
List *indexorderbyorig,
187 List *indexorderbyops,
197 List *indexqualorig);
201 List *bitmapqualorig,
218 Index scanrelid,
int ctePlanId,
int cteParam);
220 Index scanrelid,
char *enrname);
222 Index scanrelid,
int wtParam);
232 List *joinclauses,
List *otherclauses,
List *nestParams,
234 JoinType jointype,
bool inner_unique);
236 List *joinclauses,
List *otherclauses,
238 List *hashoperators,
List *hashcollations,
241 JoinType jointype,
bool inner_unique);
248 List *joinclauses,
List *otherclauses,
251 Oid *mergecollations,
252 int *mergestrategies,
253 bool *mergenullsfirst,
255 JoinType jointype,
bool inner_unique,
256 bool skip_mark_restore);
259 Oid *collations,
bool *nullsFirst);
261 int numCols,
int nPresortedCols,
263 Oid *collations,
bool *nullsFirst);
267 bool adjust_tlist_in_place,
270 Oid **p_sortOperators,
272 bool **p_nullsFirst);
276 List *pathkeys,
Relids relids,
int nPresortedCols);
282 Oid *collations,
List *param_exprs,
283 bool singlerow,
bool binary_mode,
286 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
287 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
288 int frameOptions,
Node *startOffset,
Node *endOffset,
289 Oid startInRangeFunc,
Oid endInRangeFunc,
290 Oid inRangeColl,
bool inRangeAsc,
bool inRangeNullsFirst,
291 List *runCondition,
List *qual,
bool topWindow,
298 List *pathkeys,
int numCols);
300 int nworkers,
int rescan_param,
bool single_copy,
Plan *subplan);
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;
1228 int nodenumsortkeys = 0;
1230 Oid *nodeSortOperators = NULL;
1231 Oid *nodeCollations = NULL;
1232 bool *nodeNullsFirst = NULL;
1233 bool consider_async =
false;
1271 plan->plan.targetlist = tlist;
1273 plan->plan.lefttree = NULL;
1274 plan->plan.righttree = NULL;
1277 if (pathkeys !=
NIL)
1286 best_path->
path.parent->relids,
1294 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->plan.targetlist));
1303 foreach(subpaths, best_path->
subpaths)
1315 if (pathkeys !=
NIL)
1345 Assert(numsortkeys == nodenumsortkeys);
1346 if (memcmp(sortColIdx, nodeSortColIdx,
1348 elog(
ERROR,
"Append child's targetlist doesn't match Append");
1349 Assert(memcmp(sortOperators, nodeSortOperators,
1350 numsortkeys *
sizeof(
Oid)) == 0);
1351 Assert(memcmp(collations, nodeCollations,
1352 numsortkeys *
sizeof(
Oid)) == 0);
1353 Assert(memcmp(nullsFirst, nodeNullsFirst,
1354 numsortkeys *
sizeof(
bool)) == 0);
1360 sortColIdx, sortOperators,
1361 collations, nullsFirst);
1375 subplans =
lappend(subplans, subplan);
1389 if (best_path->
path.param_info)
1391 List *prmquals = best_path->
path.param_info->ppi_clauses;
1400 if (prunequal !=
NIL)
1407 plan->appendplans = subplans;
1408 plan->nasyncplans = nasyncplans;
1410 plan->part_prune_info = partpruneinfo;
1423 plan->plan.parallel_safe);
1444 bool tlist_was_changed;
1458 plan->targetlist = tlist;
1460 plan->lefttree = NULL;
1461 plan->righttree = NULL;
1471 best_path->
path.parent->relids,
1476 &node->sortOperators,
1479 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->targetlist));
1486 foreach(subpaths, best_path->
subpaths)
1518 if (memcmp(sortColIdx, node->sortColIdx,
1520 elog(
ERROR,
"MergeAppend child's targetlist doesn't match MergeAppend");
1521 Assert(memcmp(sortOperators, node->sortOperators,
1522 numsortkeys *
sizeof(
Oid)) == 0);
1523 Assert(memcmp(collations, node->collations,
1524 numsortkeys *
sizeof(
Oid)) == 0);
1525 Assert(memcmp(nullsFirst, node->nullsFirst,
1526 numsortkeys *
sizeof(
bool)) == 0);
1532 sortColIdx, sortOperators,
1533 collations, nullsFirst);
1539 subplans =
lappend(subplans, subplan);
1556 if (prunequal !=
NIL)
1687 operators =
palloc(nkeys *
sizeof(
Oid));
1688 collations =
palloc(nkeys *
sizeof(
Oid));
1696 operators[
i] = opno;
1731 Oid *groupCollations;
1766 foreach(l, uniq_exprs)
1778 newtlist =
lappend(newtlist, tle);
1798 groupCollations = (
Oid *)
palloc(numGroupCols *
sizeof(
Oid));
1801 foreach(l, uniq_exprs)
1808 elog(
ERROR,
"failed to find unique expression in subplan tlist");
1809 groupColIdx[groupColPos] = tle->
resno;
1816 Oid *groupOperators;
1824 groupOperators = (
Oid *)
palloc(numGroupCols *
sizeof(
Oid));
1826 foreach(l, in_operators)
1832 elog(
ERROR,
"could not find compatible hash operator for operator %u",
1834 groupOperators[groupColPos++] = eq_oper;
1863 foreach(l, in_operators)
1873 elog(
ERROR,
"could not find ordering operator for equality operator %u",
1884 elog(
ERROR,
"could not find equality operator for ordering operator %u",
1888 groupColIdx[groupColPos]);
1894 sortcl->
eqop = eqop;
1897 sortcl->hashable =
false;
1898 sortList =
lappend(sortList, sortcl);
1945 root->glob->parallelModeNeeded =
true;
1981 best_path->
subpath->parent->relids,
1982 gm_plan->sortColIdx,
1985 &gm_plan->sortColIdx,
1986 &gm_plan->sortOperators,
1987 &gm_plan->collations,
1988 &gm_plan->nullsFirst);
1999 elog(
ERROR,
"gather merge input not sufficiently sorted");
2005 root->glob->parallelModeNeeded =
true;
2023 bool needs_result_node =
false;
2049 best_path->
path.pathtarget);
2083 if (!needs_result_node)
2087 plan->targetlist = tlist;
2093 plan->plan_width = best_path->
path.pathtarget->width;
2134 plan->parallel_safe = parallel_safe;
2163 tlist_parallel_safe);
2201 best_path->
path.parent->relids : NULL);
2226 best_path->
spath.
path.parent->relids : NULL,
2366 foreach(lc, groupClause)
2373 return new_grpColIdx;
2418 foreach(lc,
root->processed_groupClause)
2429 foreach(lc,
root->processed_groupClause)
2442 root->grouping_map = grouping_map;
2459 Plan *sort_plan = NULL;
2465 if (!rollup->
is_hashed && !is_first_sort)
2467 sort_plan = (
Plan *)
2474 is_first_sort =
false;
2506 chain =
lappend(chain, agg_plan);
2576 0, NULL, NULL, NULL);
2581 plan->plan_rows = 1;
2582 plan->plan_width = mminfo->
path->pathtarget->width;
2583 plan->parallel_aware =
false;
2627 Oid *partCollations;
2651 partCollations = (
Oid *)
palloc(
sizeof(
Oid) * numPart);
2660 partColIdx[partNumCols] = tle->
resno;
2661 partOperators[partNumCols] = sgc->
eqop;
2668 ordCollations = (
Oid *)
palloc(
sizeof(
Oid) * numOrder);
2677 ordColIdx[ordNumCols] = tle->
resno;
2678 ordOperators[ordNumCols] = sgc->
eqop;
2697 wc->startInRangeFunc,
2701 wc->inRangeNullsFirst,
2859 int numUniqkeys = 0;
2861 Oid *uniqOperators = NULL;
2862 Oid *uniqCollations = NULL;
2875 uniqOperators = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2876 uniqCollations = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2879 foreach(l,
parse->sortClause)
2884 uniqColIdx[numUniqkeys] = tle->
resno;
2885 uniqOperators[numUniqkeys] = sortcl->
eqop;
2895 numUniqkeys, uniqColIdx, uniqOperators, uniqCollations);
2920 Index scan_relid = best_path->parent->relid;
2933 if (best_path->param_info)
2935 scan_clauses = (
List *)
2958 Index scan_relid = best_path->parent->relid;
2976 if (best_path->param_info)
2978 scan_clauses = (
List *)
3014 Index baserelid = best_path->
path.parent->relid;
3018 List *stripped_indexquals;
3019 List *fixed_indexquals;
3020 List *fixed_indexorderbys;
3038 &stripped_indexquals,
3075 foreach(l, scan_clauses)
3079 if (rinfo->pseudoconstant)
3087 qpqual =
lappend(qpqual, rinfo);
3105 if (best_path->
path.param_info)
3107 stripped_indexquals = (
List *)
3111 indexorderbys = (
List *)
3143 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
3145 indexorderbyops =
lappend_oid(indexorderbyops, sortop);
3162 indextle->resjunk = !indexinfo->canreturn[
i];
3174 stripped_indexquals,
3175 fixed_indexorderbys,
3184 stripped_indexquals,
3185 fixed_indexorderbys,
3206 Index baserelid = best_path->
path.parent->relid;
3207 Plan *bitmapqualplan;
3208 List *bitmapqualorig;
3221 &bitmapqualorig, &indexquals,
3254 foreach(l, scan_clauses)
3259 if (rinfo->pseudoconstant)
3268 qpqual =
lappend(qpqual, rinfo);
3290 if (best_path->
path.param_info)
3294 bitmapqualorig = (
List *)
3360 &subqual, &subindexqual,
3362 subplans =
lappend(subplans, subplan);
3366 subindexECs =
list_concat(subindexECs, subindexEC);
3373 plan->plan_width = 0;
3374 plan->parallel_aware =
false;
3377 *indexqual = subindexquals;
3378 *indexECs = subindexECs;
3386 bool const_true_subqual =
false;
3387 bool const_true_subindexqual =
false;
3407 &subqual, &subindexqual,
3409 subplans =
lappend(subplans, subplan);
3411 const_true_subqual =
true;
3412 else if (!const_true_subqual)
3415 if (subindexqual ==
NIL)
3416 const_true_subindexqual =
true;
3417 else if (!const_true_subindexqual)
3418 subindexquals =
lappend(subindexquals,
3437 plan->plan_width = 0;
3438 plan->parallel_aware =
false;
3447 if (const_true_subqual)
3453 if (const_true_subindexqual)
3456 *indexqual = subindexquals;
3466 List *subindexquals;
3480 plan->startup_cost = 0.0;
3484 plan->plan_width = 0;
3485 plan->parallel_aware =
false;
3489 subindexquals =
NIL;
3496 Assert(!rinfo->pseudoconstant);
3500 if (rinfo->parent_ec)
3501 subindexECs =
lappend(subindexECs, rinfo->parent_ec);
3516 subquals =
lappend(subquals, pred);
3517 subindexquals =
lappend(subindexquals, pred);
3521 *indexqual = subindexquals;
3522 *indexECs = subindexECs;
3543 Index scan_relid = best_path->
path.parent->relid;
3574 foreach(l, scan_clauses)
3578 if (rinfo->pseudoconstant)
3584 qpqual =
lappend(qpqual, rinfo);
3586 scan_clauses = qpqual;
3612 if (best_path->
path.param_info)
3616 scan_clauses = (
List *)
3640 Index scan_relid = best_path->
path.parent->relid;
3656 foreach(l, scan_clauses)
3660 if (rinfo->pseudoconstant)
3664 qpqual =
lappend(qpqual, rinfo);
3666 scan_clauses = qpqual;
3677 if (best_path->
path.param_info)
3679 tidrangequals = (
List *)
3681 scan_clauses = (
List *)
3736 if (best_path->
path.param_info)
3740 scan_clauses = (
List *)
3764 Index scan_relid = best_path->parent->relid;
3781 if (best_path->param_info)
3783 scan_clauses = (
List *)
3807 Index scan_relid = best_path->parent->relid;
3824 if (best_path->param_info)
3826 scan_clauses = (
List *)
3850 Index scan_relid = best_path->parent->relid;
3867 if (best_path->param_info)
3869 scan_clauses = (
List *)
3872 values_lists = (
List *)
3894 Index scan_relid = best_path->parent->relid;
3907 Assert(!rte->self_reference);
3914 while (levelsup-- > 0)
3916 cteroot = cteroot->parent_root;
3945 if (ctesplan->
plan_id == plan_id)
3964 if (best_path->param_info)
3966 scan_clauses = (
List *)
3970 scan_plan =
make_ctescan(tlist, scan_clauses, scan_relid,
3971 plan_id, cte_param_id);
3989 Index scan_relid = best_path->parent->relid;
4003 if (best_path->param_info)
4005 scan_clauses = (
List *)
4028 Index scan_relid = best_path->parent->relid;
4042 if (best_path->param_info)
4044 scan_clauses = (
List *)
4065 Index scan_relid = best_path->parent->relid;
4073 Assert(rte->self_reference);
4085 while (levelsup-- > 0)
4087 cteroot = cteroot->parent_root;
4101 if (best_path->param_info)
4103 scan_clauses = (
List *)
4128 Plan *outer_plan = NULL;
4130 Assert(rel->fdwroutine != NULL);
4148 rel_oid = rte->
relid;
4164 scan_plan = rel->fdwroutine->GetForeignPlan(
root, rel, rel_oid,
4166 tlist, scan_clauses,
4194 root->outer_join_rels);
4202 root->glob->dependsOnRole =
true;
4212 if (best_path->
path.param_info)
4214 scan_plan->
scan.plan.qual = (
List *)
4328 if (best_path->
path.param_info)
4388 root->curOuterRels = saveOuterRels;
4398 best_path->
jpath.path.parent->relids,
4399 &joinclauses, &otherclauses);
4409 if (best_path->
jpath.path.param_info)
4411 joinclauses = (
List *)
4413 otherclauses = (
List *)
4449 List *outerpathkeys;
4450 List *innerpathkeys;
4453 Oid *mergecollations;
4454 int *mergestrategies;
4455 bool *mergenullsfirst;
4486 best_path->
jpath.path.parent->relids,
4487 &joinclauses, &otherclauses);
4507 if (best_path->
jpath.path.param_info)
4509 joinclauses = (
List *)
4511 otherclauses = (
List *)
4528 Relids outer_relids = outer_path->parent->relids;
4542 Relids inner_relids = inner_path->parent->relids;
4570 inner_plan = matplan;
4582 mergefamilies = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4583 mergecollations = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4584 mergestrategies = (
int *)
palloc(nClauses *
sizeof(
int));
4585 mergenullsfirst = (
bool *)
palloc(nClauses *
sizeof(
bool));
4599 bool first_inner_match =
false;
4602 if (rinfo->outer_is_left)
4604 oeclass = rinfo->left_ec;
4605 ieclass = rinfo->right_ec;
4609 oeclass = rinfo->right_ec;
4610 ieclass = rinfo->left_ec;
4630 if (oeclass != opeclass)
4634 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4636 opeclass = opathkey->pk_eclass;
4637 lop =
lnext(outerpathkeys, lop);
4638 if (oeclass != opeclass)
4639 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4660 ipeclass = ipathkey->pk_eclass;
4661 if (ieclass == ipeclass)
4664 lip =
lnext(innerpathkeys, lip);
4665 first_inner_match =
true;
4668 if (!first_inner_match)
4673 foreach(l2, innerpathkeys)
4678 ipeclass = ipathkey->pk_eclass;
4679 if (ieclass == ipeclass)
4682 if (ieclass != ipeclass)
4683 elog(
ERROR,
"inner pathkeys do not match mergeclauses");
4701 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation)
4702 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4703 if (first_inner_match &&
4706 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4710 mergecollations[
i] = opathkey->pk_eclass->ec_collation;
4763 bool skewInherit =
false;
4788 best_path->
jpath.path.parent->relids,
4789 &joinclauses, &otherclauses);
4809 if (best_path->
jpath.path.param_info)
4811 joinclauses = (
List *)
4813 otherclauses = (
List *)
4846 rte =
root->simple_rte_array[var->
varno];
4849 skewTable = rte->
relid;
4851 skewInherit = rte->
inh;
4864 foreach(lc, hashclauses)
4869 hashcollations =
lappend_oid(hashcollations, hclause->inputcollid);
4895 if (best_path->
jpath.path.parallel_aware)
4968 root->curOuterRels))
4988 newphv->phexpr = (
Expr *)
4991 return (
Node *) newphv;
5023 List **stripped_indexquals_p,
List **fixed_indexquals_p)
5026 List *stripped_indexquals;
5027 List *fixed_indexquals;
5030 stripped_indexquals = fixed_indexquals =
NIL;
5043 stripped_indexquals =
lappend(stripped_indexquals, clause);
5046 fixed_indexquals =
lappend(fixed_indexquals, clause);
5050 *stripped_indexquals_p = stripped_indexquals;
5051 *fixed_indexquals_p = fixed_indexquals;
5066 List *fixed_indexorderbys;
5070 fixed_indexorderbys =
NIL;
5078 fixed_indexorderbys =
lappend(fixed_indexorderbys, clause);
5081 return fixed_indexorderbys;
5146 elog(
ERROR,
"unsupported indexqual type: %d",
5175 Assert(indexcol >= 0 && indexcol < index->ncolumns);
5177 if (
index->indexkeys[indexcol] != 0)
5181 ((
Var *) node)->varno ==
index->rel->relid &&
5182 ((
Var *) node)->varattno ==
index->indexkeys[indexcol])
5187 return (
Node *) result;
5190 elog(
ERROR,
"index key does not match expected index column");
5195 for (pos = 0; pos <
index->ncolumns; pos++)
5197 if (
index->indexkeys[pos] == 0)
5199 if (indexpr_item == NULL)
5200 elog(
ERROR,
"too few entries in indexprs list");
5201 if (pos == indexcol)
5208 if (
equal(node, indexkey))
5214 return (
Node *) result;
5217 elog(
ERROR,
"index key does not match expected index column");
5219 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5224 elog(
ERROR,
"index key does not match expected index column");
5260 temp->opresulttype = clause->opresulttype;
5261 temp->opretset = clause->opretset;
5262 temp->opcollid = clause->opcollid;
5263 temp->inputcollid = clause->inputcollid;
5268 t_list =
lappend(t_list, temp);
5269 restrictinfo->outer_is_left =
false;
5274 t_list =
lappend(t_list, clause);
5275 restrictinfo->outer_is_left =
true;
5321 Index security_level;
5339 foreach(lc, clauses)
5345 items[
i].clause = clause;
5362 items[
i].security_level = 0;
5367 items[
i].security_level = 0;
5378 QualItem newitem =
items[
i];
5382 for (
j =
i;
j > 0;
j--)
5384 QualItem *olditem = &
items[
j - 1];
5386 if (newitem.security_level > olditem->security_level ||
5387 (newitem.security_level == olditem->security_level &&
5388 newitem.cost >= olditem->cost))
5414 dest->plan_width = src->pathtarget->width;
5431 dest->parallel_aware =
false;
5448 Plan *lefttree =
plan->plan.lefttree;
5468 plan->plan.parallel_aware =
false;
5515 plan->targetlist = qptlist;
5516 plan->qual = qpqual;
5517 plan->lefttree = NULL;
5518 plan->righttree = NULL;
5533 plan->targetlist = qptlist;
5534 plan->qual = qpqual;
5535 plan->lefttree = NULL;
5536 plan->righttree = NULL;
5549 List *indexqualorig,
5551 List *indexorderbyorig,
5552 List *indexorderbyops,
5558 plan->targetlist = qptlist;
5559 plan->qual = qpqual;
5560 plan->lefttree = NULL;
5561 plan->righttree = NULL;
5588 plan->targetlist = qptlist;
5589 plan->qual = qpqual;
5590 plan->lefttree = NULL;
5591 plan->righttree = NULL;
5607 List *indexqualorig)
5614 plan->lefttree = NULL;
5615 plan->righttree = NULL;
5628 List *bitmapqualorig,
5634 plan->targetlist = qptlist;
5635 plan->qual = qpqual;
5636 plan->lefttree = lefttree;
5637 plan->righttree = NULL;
5653 plan->targetlist = qptlist;
5654 plan->qual = qpqual;
5655 plan->lefttree = NULL;
5656 plan->righttree = NULL;
5667 List *tidrangequals)
5672 plan->targetlist = qptlist;
5673 plan->qual = qpqual;
5674 plan->lefttree = NULL;
5675 plan->righttree = NULL;
5691 plan->targetlist = qptlist;
5692 plan->qual = qpqual;
5693 plan->lefttree = NULL;
5694 plan->righttree = NULL;
5707 bool funcordinality)
5712 plan->targetlist = qptlist;
5713 plan->qual = qpqual;
5714 plan->lefttree = NULL;
5715 plan->righttree = NULL;
5732 plan->targetlist = qptlist;
5733 plan->qual = qpqual;
5734 plan->lefttree = NULL;
5735 plan->righttree = NULL;
5751 plan->targetlist = qptlist;
5752 plan->qual = qpqual;
5753 plan->lefttree = NULL;
5754 plan->righttree = NULL;
5771 plan->targetlist = qptlist;
5772 plan->qual = qpqual;
5773 plan->lefttree = NULL;
5774 plan->righttree = NULL;
5792 plan->targetlist = qptlist;
5793 plan->qual = qpqual;
5794 plan->lefttree = NULL;
5795 plan->righttree = NULL;
5811 plan->targetlist = qptlist;
5812 plan->qual = qpqual;
5813 plan->lefttree = NULL;
5814 plan->righttree = NULL;
5827 List *fdw_scan_tlist,
5828 List *fdw_recheck_quals,
5835 plan->targetlist = qptlist;
5836 plan->qual = qpqual;
5837 plan->lefttree = outer_plan;
5838 plan->righttree = NULL;
5873 plan->targetlist = tlist;
5875 plan->lefttree = lefttree;
5876 plan->righttree = righttree;
5896 foreach(slitem, distinctList)
5902 dupColIdx[keyno] = tle->
resno;
5903 dupOperators[keyno] = sortcl->
eqop;
5908 node->dupColIdx = dupColIdx;
5909 node->dupOperators = dupOperators;
5910 node->dupCollations = dupCollations;
5925 plan->lefttree = NULL;
5926 plan->righttree = NULL;
5940 plan->lefttree = NULL;
5941 plan->righttree = NULL;
5960 plan->targetlist = tlist;
5961 plan->qual = otherclauses;
5962 plan->lefttree = lefttree;
5963 plan->righttree = righttree;
5977 List *hashoperators,
5978 List *hashcollations,
5988 plan->targetlist = tlist;
5989 plan->qual = otherclauses;
5990 plan->lefttree = lefttree;
5991 plan->righttree = righttree;
6015 plan->lefttree = lefttree;
6016 plan->righttree = NULL;
6032 Oid *mergecollations,
6033 int *mergestrategies,
6034 bool *mergenullsfirst,
6039 bool skip_mark_restore)
6044 plan->targetlist = tlist;
6045 plan->qual = otherclauses;
6046 plan->lefttree = lefttree;
6047 plan->righttree = righttree;
6050 node->mergeFamilies = mergefamilies;
6051 node->mergeCollations = mergecollations;
6052 node->mergeStrategies = mergestrategies;
6053 node->mergeNullsFirst = mergenullsfirst;
6070 Oid *collations,
bool *nullsFirst)
6080 plan->lefttree = lefttree;
6081 plan->righttree = NULL;
6083 node->sortColIdx = sortColIdx;
6084 node->sortOperators = sortOperators;
6085 node->collations = collations;
6086 node->nullsFirst = nullsFirst;
6100 Oid *collations,
bool *nullsFirst)
6110 plan->lefttree = lefttree;
6111 plan->righttree = NULL;
6114 node->
sort.sortColIdx = sortColIdx;
6115 node->
sort.sortOperators = sortOperators;
6116 node->
sort.collations = collations;
6117 node->
sort.nullsFirst = nullsFirst;
6167 bool adjust_tlist_in_place,
6170 Oid **p_sortOperators,
6172 bool **p_nullsFirst)
6187 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6188 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6189 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6193 foreach(
i, pathkeys)
6211 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6217 else if (reqColIdx != NULL)
6277 elog(
ERROR,
"could not find pathkey item to sort");
6283 if (!adjust_tlist_in_place &&
6293 adjust_tlist_in_place =
true;
6315 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6320 sortColIdx[numsortkeys] = tle->
resno;
6321 sortOperators[numsortkeys] = sortop;
6328 *p_numsortkeys = numsortkeys;
6329 *p_sortColIdx = sortColIdx;
6330 *p_sortOperators = sortOperators;
6331 *p_collations = collations;
6332 *p_nullsFirst = nullsFirst;
6367 sortColIdx, sortOperators,
6368 collations, nullsFirst);
6382 Relids relids,
int nPresortedCols)
6403 sortColIdx, sortOperators,
6404 collations, nullsFirst);
6428 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6429 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6430 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6438 sortColIdx[numsortkeys] = tle->
resno;
6439 sortOperators[numsortkeys] = sortcl->
sortop;
6446 sortColIdx, sortOperators,
6447 collations, nullsFirst);
6479 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6480 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6481 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6484 foreach(l, groupcls)
6490 elog(
ERROR,
"could not retrieve tle for sort-from-groupcols");
6492 sortColIdx[numsortkeys] = tle->
resno;
6493 sortOperators[numsortkeys] = grpcl->
sortop;
6500 sortColIdx, sortOperators,
6501 collations, nullsFirst);
6512 plan->lefttree = lefttree;
6513 plan->righttree = NULL;
6532 bool unsafe_initplans;
6547 &initplan_cost, &unsafe_initplans);
6569 List *param_exprs,
bool singlerow,
bool binary_mode,
6577 plan->lefttree = lefttree;
6578 plan->righttree = NULL;
6581 node->hashOperators = hashoperators;
6582 node->collations = collations;
6595 int numGroupCols,
AttrNumber *grpColIdx,
Oid *grpOperators,
Oid *grpCollations,
6596 List *groupingSets,
List *chain,
double dNumGroups,
6597 Size transitionSpace,
Plan *lefttree)
6609 node->grpColIdx = grpColIdx;
6610 node->grpOperators = grpOperators;
6611 node->grpCollations = grpCollations;
6616 node->
chain = chain;
6619 plan->targetlist = tlist;
6620 plan->lefttree = lefttree;
6621 plan->righttree = NULL;
6628 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
6629 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
6630 int frameOptions,
Node *startOffset,
Node *endOffset,
6631 Oid startInRangeFunc,
Oid endInRangeFunc,
6632 Oid inRangeColl,
bool inRangeAsc,
bool inRangeNullsFirst,
6633 List *runCondition,
List *qual,
bool topWindow,
Plan *lefttree)
6640 node->partColIdx = partColIdx;
6641 node->partOperators = partOperators;
6642 node->partCollations = partCollations;
6644 node->ordColIdx = ordColIdx;
6645 node->ordOperators = ordOperators;
6646 node->ordCollations = ordCollations;
6660 plan->targetlist = tlist;
6661 plan->lefttree = lefttree;
6662 plan->righttree = NULL;
6681 node->grpColIdx = grpColIdx;
6682 node->grpOperators = grpOperators;
6683 node->grpCollations = grpCollations;
6686 plan->targetlist = tlist;
6687 plan->lefttree = lefttree;
6688 plan->righttree = NULL;
6707 Oid *uniqCollations;
6712 plan->lefttree = lefttree;
6713 plan->righttree = NULL;
6722 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6724 foreach(slitem, distinctList)
6729 uniqColIdx[keyno] = tle->
resno;
6730 uniqOperators[keyno] = sortcl->
eqop;
6737 node->uniqColIdx = uniqColIdx;
6738 node->uniqOperators = uniqOperators;
6739 node->uniqCollations = uniqCollations;
6755 Oid *uniqCollations;
6760 plan->lefttree = lefttree;
6761 plan->righttree = NULL;
6771 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6773 foreach(lc, pathkeys)
6784 if (keyno >= numCols)
6795 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6808 foreach(
j,
plan->targetlist)
6823 elog(
ERROR,
"could not find pathkey item to sort");
6834 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6838 uniqColIdx[keyno] = tle->
resno;
6839 uniqOperators[keyno] = eqop;
6846 node->uniqColIdx = uniqColIdx;
6847 node->uniqOperators = uniqOperators;
6848 node->uniqCollations = uniqCollations;
6864 plan->targetlist = qptlist;
6865 plan->qual = qpqual;
6866 plan->lefttree = subplan;
6867 plan->righttree = NULL;
6898 plan->lefttree = lefttree;
6899 plan->righttree = NULL;
6909 foreach(slitem, distinctList)
6914 dupColIdx[keyno] = tle->
resno;
6915 dupOperators[keyno] = sortcl->
eqop;
6924 node->dupColIdx = dupColIdx;
6925 node->dupOperators = dupOperators;
6926 node->dupCollations = dupCollations;
6946 plan->lefttree = lefttree;
6947 plan->righttree = NULL;
6962 Oid *uniqOperators,
Oid *uniqCollations)
6969 plan->lefttree = lefttree;
6970 plan->righttree = NULL;
6976 node->uniqColIdx = uniqColIdx;
6977 node->uniqOperators = uniqOperators;
6978 node->uniqCollations = uniqCollations;
6989 Node *resconstantqual,
6995 plan->targetlist = tlist;
6997 plan->lefttree = subplan;
6998 plan->righttree = NULL;
7015 plan->targetlist = tlist;
7017 plan->lefttree = subplan;
7018 plan->righttree = NULL;
7029 CmdType operation,
bool canSetTag,
7031 bool partColsUpdated,
7032 List *resultRelations,
7033 List *updateColnosLists,
7034 List *withCheckOptionLists,
List *returningLists,
7036 List *mergeActionLists,
List *mergeJoinConditions,
7040 List *fdw_private_list;
7048 updateColnosLists ==
NIL));
7114 fdw_private_list =
NIL;
7115 direct_modify_plans = NULL;
7117 foreach(lc, resultRelations)
7131 if (rti < root->simple_rel_array_size &&
7132 root->simple_rel_array[rti] != NULL)
7136 fdwroutine = resultRel->fdwroutine;
7143 rte->relkind == RELKIND_FOREIGN_TABLE)
7156 if (operation ==
CMD_MERGE && fdwroutine != NULL)
7161 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7162 errmsg(
"cannot execute MERGE on relation \"%s\"",
7174 direct_modify =
false;
7175 if (fdwroutine != NULL &&
7180 withCheckOptionLists ==
NIL &&
7187 if (!direct_modify &&
7188 fdwroutine != NULL &&
7193 fdw_private_list =
lappend(fdw_private_list, fdw_private);
7216 case T_IncrementalSort:
7223 case T_RecursiveUnion:
7273 case T_RecursiveUnion:
Datum sort(PG_FUNCTION_ARGS)
#define InvalidAttrNumber
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)
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define OidIsValid(objectId)
bool contain_mutable_functions(Node *clause)
Bitmapset * pull_paramids(Expr *expr)
void CommuteOpExpr(OpExpr *clause)
void cost_material(Path *path, Cost input_startup_cost, Cost input_total_cost, double tuples, int width)
void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root)
double clamp_row_est(double nrows)
long clamp_cardinality_to_long(Cardinality x)
bool enable_partition_pruning
void cost_sort(Path *path, PlannerInfo *root, List *pathkeys, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
static Unique * make_unique_from_sortclauses(Plan *lefttree, List *distinctList)
static Plan * create_join_plan(PlannerInfo *root, JoinPath *best_path)
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
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 GatherMerge * create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path)
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 ValuesScan * create_valuesscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static void copy_generic_path_info(Plan *dest, Path *src)
static Memoize * make_memoize(Plan *lefttree, Oid *hashoperators, Oid *collations, List *param_exprs, bool singlerow, bool binary_mode, uint32 est_entries, Bitmapset *keyparamids)
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 Plan * create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
static void bitmap_subplan_mark_shared(Plan *plan)
static SetOp * make_setop(SetOpCmd cmd, SetOpStrategy strategy, Plan *lefttree, List *distinctList, AttrNumber flagColIdx, int firstFlag, long numGroups)
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)
Plan * create_plan(PlannerInfo *root, Path *best_path)
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 MergeJoin * make_mergejoin(List *tlist, List *joinclauses, List *otherclauses, List *mergeclauses, Oid *mergefamilies, Oid *mergecollations, int *mergestrategies, bool *mergenullsfirst, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique, bool skip_mark_restore)
static Sort * make_sort(Plan *lefttree, int numCols, AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst)
static ProjectSet * create_project_set_plan(PlannerInfo *root, ProjectSetPath *best_path)
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 AttrNumber * remap_groupColIdx(PlannerInfo *root, List *groupClause)
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)
Plan * materialize_finished_plan(Plan *subplan)
static List * build_path_tlist(PlannerInfo *root, Path *path)
static IndexScan * make_indexscan(List *qptlist, List *qpqual, Index scanrelid, Oid indexid, List *indexqual, List *indexqualorig, List *indexorderby, List *indexorderbyorig, List *indexorderbyops, ScanDirection indexscandir)
static FunctionScan * make_functionscan(List *qptlist, List *qpqual, Index scanrelid, List *functions, bool funcordinality)
static TableFuncScan * make_tablefuncscan(List *qptlist, List *qpqual, Index scanrelid, TableFunc *tablefunc)
static SubqueryScan * create_subqueryscan_plan(PlannerInfo *root, SubqueryScanPath *best_path, List *tlist, List *scan_clauses)
static Plan * inject_projection_plan(Plan *subplan, List *tlist, bool parallel_safe)
static TidRangeScan * create_tidrangescan_plan(PlannerInfo *root, TidRangePath *best_path, List *tlist, List *scan_clauses)
static List * get_switched_clauses(List *clauses, Relids outerrelids)
static void copy_plan_costsize(Plan *dest, Plan *src)
static ValuesScan * make_valuesscan(List *qptlist, List *qpqual, Index scanrelid, List *values_lists)
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)
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)
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
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)
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
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)
static WindowAgg * make_windowagg(List *tlist, Index winref, int partNumCols, AttrNumber *partColIdx, Oid *partOperators, Oid *partCollations, int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators, Oid *ordCollations, int frameOptions, Node *startOffset, Node *endOffset, Oid startInRangeFunc, Oid endInRangeFunc, Oid inRangeColl, bool inRangeAsc, bool inRangeNullsFirst, List *runCondition, List *qual, bool topWindow, Plan *lefttree)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
EquivalenceMember * find_ec_member_matching_expr(EquivalenceClass *ec, Expr *expr, Relids relids)
bool is_redundant_with_indexclauses(RestrictInfo *rinfo, List *indexclauses)
bool is_redundant_derived_clause(RestrictInfo *rinfo, List *clauselist)
EquivalenceMember * find_computable_ec_member(PlannerInfo *root, EquivalenceClass *ec, List *exprs, Relids relids, bool require_parallel_safe)
#define CUSTOMPATH_SUPPORT_PROJECTION
FdwRoutine * GetFdwRoutineByRelId(Oid relid)
if(TABLE==NULL||TABLE_index==NULL)
List * list_concat_unique(List *list1, const List *list2)
List * list_difference_ptr(const List *list1, const List *list2)
List * lappend(List *list, void *datum)
List * list_copy_head(const List *oldlist, int len)
List * lappend_oid(List *list, Oid datum)
List * list_copy(const List *oldlist)
bool list_member_ptr(const List *list, const void *datum)
List * list_concat(List *list1, const List *list2)
bool list_member(const List *list, const void *datum)
List * list_difference(const List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
bool get_compatible_hash_operators(Oid opno, Oid *lhs_opno, Oid *rhs_opno)
Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)
char * get_rel_name(Oid relid)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type)
Datum lca(PG_FUNCTION_ARGS)
Datum subpath(PG_FUNCTION_ARGS)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Expr * make_ands_explicit(List *andclauses)
Node * makeBoolConst(bool value, bool isnull)
Expr * make_orclause(List *orclauses)
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)
Param * replace_nestloop_param_var(PlannerInfo *root, Var *var)
List * identify_current_nestloop_params(PlannerInfo *root, Relids leftrelids)
Param * replace_nestloop_param_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
int assign_special_exec_param(PlannerInfo *root)
Index assignSortGroupRef(TargetEntry *tle, List *tlist)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
PartitionPruneInfo * make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, List *subpaths, List *prunequal)
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)
static ListCell * list_head(const List *l)
#define for_each_from(cell, lst, N)
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)
void check_stack_depth(void)
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 * get_actual_clauses(List *restrictinfo_list)
void extract_actual_join_clauses(List *restrictinfo_list, Relids joinrelids, List **joinquals, List **otherquals)
List * extract_actual_clauses(List *restrictinfo_list, bool pseudoconstant)
bool trivial_subqueryscan(SubqueryScan *plan)
#define BTEqualStrategyNumber
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
struct PartitionPruneInfo * part_prune_info
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
bool tlist_same_exprs(List *tlist1, List *tlist2)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
void apply_tlist_labeling(List *dest_tlist, List *src_tlist)
Oid * extract_grouping_collations(List *groupClause, List *tlist)
void apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target)
Oid * extract_grouping_ops(List *groupClause)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
AttrNumber * extract_grouping_cols(List *groupClause, List *tlist)
TargetEntry * tlist_member(Expr *node, List *targetlist)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)