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);
2000 root->glob->parallelModeNeeded =
true;
2018 bool needs_result_node =
false;
2044 best_path->
path.pathtarget);
2078 if (!needs_result_node)
2082 plan->targetlist = tlist;
2088 plan->plan_width = best_path->
path.pathtarget->width;
2129 plan->parallel_safe = parallel_safe;
2158 tlist_parallel_safe);
2196 best_path->
path.parent->relids : NULL);
2221 best_path->
spath.
path.parent->relids : NULL,
2361 foreach(lc, groupClause)
2368 return new_grpColIdx;
2413 foreach(lc,
root->processed_groupClause)
2424 foreach(lc,
root->processed_groupClause)
2437 root->grouping_map = grouping_map;
2454 Plan *sort_plan = NULL;
2460 if (!rollup->
is_hashed && !is_first_sort)
2462 sort_plan = (
Plan *)
2469 is_first_sort =
false;
2501 chain =
lappend(chain, agg_plan);
2571 0, NULL, NULL, NULL);
2576 plan->plan_rows = 1;
2577 plan->plan_width = mminfo->
path->pathtarget->width;
2578 plan->parallel_aware =
false;
2622 Oid *partCollations;
2646 partCollations = (
Oid *)
palloc(
sizeof(
Oid) * numPart);
2655 partColIdx[partNumCols] = tle->
resno;
2656 partOperators[partNumCols] = sgc->
eqop;
2663 ordCollations = (
Oid *)
palloc(
sizeof(
Oid) * numOrder);
2672 ordColIdx[ordNumCols] = tle->
resno;
2673 ordOperators[ordNumCols] = sgc->
eqop;
2692 wc->startInRangeFunc,
2696 wc->inRangeNullsFirst,
2854 int numUniqkeys = 0;
2856 Oid *uniqOperators = NULL;
2857 Oid *uniqCollations = NULL;
2870 uniqOperators = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2871 uniqCollations = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2874 foreach(l,
parse->sortClause)
2879 uniqColIdx[numUniqkeys] = tle->
resno;
2880 uniqOperators[numUniqkeys] = sortcl->
eqop;
2890 numUniqkeys, uniqColIdx, uniqOperators, uniqCollations);
2915 Index scan_relid = best_path->parent->relid;
2928 if (best_path->param_info)
2930 scan_clauses = (
List *)
2953 Index scan_relid = best_path->parent->relid;
2971 if (best_path->param_info)
2973 scan_clauses = (
List *)
3009 Index baserelid = best_path->
path.parent->relid;
3013 List *stripped_indexquals;
3014 List *fixed_indexquals;
3015 List *fixed_indexorderbys;
3033 &stripped_indexquals,
3070 foreach(l, scan_clauses)
3074 if (rinfo->pseudoconstant)
3082 qpqual =
lappend(qpqual, rinfo);
3100 if (best_path->
path.param_info)
3102 stripped_indexquals = (
List *)
3106 indexorderbys = (
List *)
3138 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
3140 indexorderbyops =
lappend_oid(indexorderbyops, sortop);
3157 indextle->resjunk = !indexinfo->canreturn[
i];
3169 stripped_indexquals,
3170 fixed_indexorderbys,
3179 stripped_indexquals,
3180 fixed_indexorderbys,
3201 Index baserelid = best_path->
path.parent->relid;
3202 Plan *bitmapqualplan;
3203 List *bitmapqualorig;
3216 &bitmapqualorig, &indexquals,
3249 foreach(l, scan_clauses)
3254 if (rinfo->pseudoconstant)
3263 qpqual =
lappend(qpqual, rinfo);
3285 if (best_path->
path.param_info)
3289 bitmapqualorig = (
List *)
3355 &subqual, &subindexqual,
3357 subplans =
lappend(subplans, subplan);
3361 subindexECs =
list_concat(subindexECs, subindexEC);
3368 plan->plan_width = 0;
3369 plan->parallel_aware =
false;
3372 *indexqual = subindexquals;
3373 *indexECs = subindexECs;
3381 bool const_true_subqual =
false;
3382 bool const_true_subindexqual =
false;
3402 &subqual, &subindexqual,
3404 subplans =
lappend(subplans, subplan);
3406 const_true_subqual =
true;
3407 else if (!const_true_subqual)
3410 if (subindexqual ==
NIL)
3411 const_true_subindexqual =
true;
3412 else if (!const_true_subindexqual)
3413 subindexquals =
lappend(subindexquals,
3432 plan->plan_width = 0;
3433 plan->parallel_aware =
false;
3442 if (const_true_subqual)
3448 if (const_true_subindexqual)
3451 *indexqual = subindexquals;
3461 List *subindexquals;
3475 plan->startup_cost = 0.0;
3479 plan->plan_width = 0;
3480 plan->parallel_aware =
false;
3484 subindexquals =
NIL;
3491 Assert(!rinfo->pseudoconstant);
3495 if (rinfo->parent_ec)
3496 subindexECs =
lappend(subindexECs, rinfo->parent_ec);
3511 subquals =
lappend(subquals, pred);
3512 subindexquals =
lappend(subindexquals, pred);
3516 *indexqual = subindexquals;
3517 *indexECs = subindexECs;
3538 Index scan_relid = best_path->
path.parent->relid;
3569 foreach(l, scan_clauses)
3573 if (rinfo->pseudoconstant)
3579 qpqual =
lappend(qpqual, rinfo);
3581 scan_clauses = qpqual;
3607 if (best_path->
path.param_info)
3611 scan_clauses = (
List *)
3635 Index scan_relid = best_path->
path.parent->relid;
3651 foreach(l, scan_clauses)
3655 if (rinfo->pseudoconstant)
3659 qpqual =
lappend(qpqual, rinfo);
3661 scan_clauses = qpqual;
3672 if (best_path->
path.param_info)
3674 tidrangequals = (
List *)
3676 scan_clauses = (
List *)
3731 if (best_path->
path.param_info)
3735 scan_clauses = (
List *)
3759 Index scan_relid = best_path->parent->relid;
3776 if (best_path->param_info)
3778 scan_clauses = (
List *)
3802 Index scan_relid = best_path->parent->relid;
3819 if (best_path->param_info)
3821 scan_clauses = (
List *)
3845 Index scan_relid = best_path->parent->relid;
3862 if (best_path->param_info)
3864 scan_clauses = (
List *)
3867 values_lists = (
List *)
3889 Index scan_relid = best_path->parent->relid;
3902 Assert(!rte->self_reference);
3909 while (levelsup-- > 0)
3911 cteroot = cteroot->parent_root;
3940 if (ctesplan->
plan_id == plan_id)
3959 if (best_path->param_info)
3961 scan_clauses = (
List *)
3965 scan_plan =
make_ctescan(tlist, scan_clauses, scan_relid,
3966 plan_id, cte_param_id);
3984 Index scan_relid = best_path->parent->relid;
3998 if (best_path->param_info)
4000 scan_clauses = (
List *)
4023 Index scan_relid = best_path->parent->relid;
4037 if (best_path->param_info)
4039 scan_clauses = (
List *)
4060 Index scan_relid = best_path->parent->relid;
4068 Assert(rte->self_reference);
4080 while (levelsup-- > 0)
4082 cteroot = cteroot->parent_root;
4096 if (best_path->param_info)
4098 scan_clauses = (
List *)
4123 Plan *outer_plan = NULL;
4125 Assert(rel->fdwroutine != NULL);
4143 rel_oid = rte->
relid;
4159 scan_plan = rel->fdwroutine->GetForeignPlan(
root, rel, rel_oid,
4161 tlist, scan_clauses,
4189 root->outer_join_rels);
4197 root->glob->dependsOnRole =
true;
4207 if (best_path->
path.param_info)
4209 scan_plan->
scan.plan.qual = (
List *)
4323 if (best_path->
path.param_info)
4383 root->curOuterRels = saveOuterRels;
4393 best_path->
jpath.path.parent->relids,
4394 &joinclauses, &otherclauses);
4404 if (best_path->
jpath.path.param_info)
4406 joinclauses = (
List *)
4408 otherclauses = (
List *)
4444 List *outerpathkeys;
4445 List *innerpathkeys;
4448 Oid *mergecollations;
4449 int *mergestrategies;
4450 bool *mergenullsfirst;
4481 best_path->
jpath.path.parent->relids,
4482 &joinclauses, &otherclauses);
4502 if (best_path->
jpath.path.param_info)
4504 joinclauses = (
List *)
4506 otherclauses = (
List *)
4523 Relids outer_relids = outer_path->parent->relids;
4537 Relids inner_relids = inner_path->parent->relids;
4565 inner_plan = matplan;
4577 mergefamilies = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4578 mergecollations = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4579 mergestrategies = (
int *)
palloc(nClauses *
sizeof(
int));
4580 mergenullsfirst = (
bool *)
palloc(nClauses *
sizeof(
bool));
4594 bool first_inner_match =
false;
4597 if (rinfo->outer_is_left)
4599 oeclass = rinfo->left_ec;
4600 ieclass = rinfo->right_ec;
4604 oeclass = rinfo->right_ec;
4605 ieclass = rinfo->left_ec;
4625 if (oeclass != opeclass)
4629 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4631 opeclass = opathkey->pk_eclass;
4632 lop =
lnext(outerpathkeys, lop);
4633 if (oeclass != opeclass)
4634 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4655 ipeclass = ipathkey->pk_eclass;
4656 if (ieclass == ipeclass)
4659 lip =
lnext(innerpathkeys, lip);
4660 first_inner_match =
true;
4663 if (!first_inner_match)
4668 foreach(l2, innerpathkeys)
4673 ipeclass = ipathkey->pk_eclass;
4674 if (ieclass == ipeclass)
4677 if (ieclass != ipeclass)
4678 elog(
ERROR,
"inner pathkeys do not match mergeclauses");
4696 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation)
4697 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4698 if (first_inner_match &&
4701 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4705 mergecollations[
i] = opathkey->pk_eclass->ec_collation;
4758 bool skewInherit =
false;
4783 best_path->
jpath.path.parent->relids,
4784 &joinclauses, &otherclauses);
4804 if (best_path->
jpath.path.param_info)
4806 joinclauses = (
List *)
4808 otherclauses = (
List *)
4841 rte =
root->simple_rte_array[var->
varno];
4844 skewTable = rte->
relid;
4846 skewInherit = rte->
inh;
4859 foreach(lc, hashclauses)
4864 hashcollations =
lappend_oid(hashcollations, hclause->inputcollid);
4890 if (best_path->
jpath.path.parallel_aware)
4963 root->curOuterRels))
4983 newphv->phexpr = (
Expr *)
4986 return (
Node *) newphv;
5018 List **stripped_indexquals_p,
List **fixed_indexquals_p)
5021 List *stripped_indexquals;
5022 List *fixed_indexquals;
5025 stripped_indexquals = fixed_indexquals =
NIL;
5038 stripped_indexquals =
lappend(stripped_indexquals, clause);
5041 fixed_indexquals =
lappend(fixed_indexquals, clause);
5045 *stripped_indexquals_p = stripped_indexquals;
5046 *fixed_indexquals_p = fixed_indexquals;
5061 List *fixed_indexorderbys;
5065 fixed_indexorderbys =
NIL;
5073 fixed_indexorderbys =
lappend(fixed_indexorderbys, clause);
5076 return fixed_indexorderbys;
5141 elog(
ERROR,
"unsupported indexqual type: %d",
5170 Assert(indexcol >= 0 && indexcol < index->ncolumns);
5172 if (
index->indexkeys[indexcol] != 0)
5176 ((
Var *) node)->varno ==
index->rel->relid &&
5177 ((
Var *) node)->varattno ==
index->indexkeys[indexcol])
5182 return (
Node *) result;
5185 elog(
ERROR,
"index key does not match expected index column");
5190 for (pos = 0; pos <
index->ncolumns; pos++)
5192 if (
index->indexkeys[pos] == 0)
5194 if (indexpr_item == NULL)
5195 elog(
ERROR,
"too few entries in indexprs list");
5196 if (pos == indexcol)
5203 if (
equal(node, indexkey))
5209 return (
Node *) result;
5212 elog(
ERROR,
"index key does not match expected index column");
5214 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5219 elog(
ERROR,
"index key does not match expected index column");
5255 temp->opresulttype = clause->opresulttype;
5256 temp->opretset = clause->opretset;
5257 temp->opcollid = clause->opcollid;
5258 temp->inputcollid = clause->inputcollid;
5263 t_list =
lappend(t_list, temp);
5264 restrictinfo->outer_is_left =
false;
5269 t_list =
lappend(t_list, clause);
5270 restrictinfo->outer_is_left =
true;
5316 Index security_level;
5334 foreach(lc, clauses)
5340 items[
i].clause = clause;
5357 items[
i].security_level = 0;
5362 items[
i].security_level = 0;
5373 QualItem newitem =
items[
i];
5377 for (
j =
i;
j > 0;
j--)
5379 QualItem *olditem = &
items[
j - 1];
5381 if (newitem.security_level > olditem->security_level ||
5382 (newitem.security_level == olditem->security_level &&
5383 newitem.cost >= olditem->cost))
5409 dest->plan_width = src->pathtarget->width;
5426 dest->parallel_aware =
false;
5443 Plan *lefttree =
plan->plan.lefttree;
5463 plan->plan.parallel_aware =
false;
5510 plan->targetlist = qptlist;
5511 plan->qual = qpqual;
5512 plan->lefttree = NULL;
5513 plan->righttree = NULL;
5528 plan->targetlist = qptlist;
5529 plan->qual = qpqual;
5530 plan->lefttree = NULL;
5531 plan->righttree = NULL;
5544 List *indexqualorig,
5546 List *indexorderbyorig,
5547 List *indexorderbyops,
5553 plan->targetlist = qptlist;
5554 plan->qual = qpqual;
5555 plan->lefttree = NULL;
5556 plan->righttree = NULL;
5583 plan->targetlist = qptlist;
5584 plan->qual = qpqual;
5585 plan->lefttree = NULL;
5586 plan->righttree = NULL;
5602 List *indexqualorig)
5609 plan->lefttree = NULL;
5610 plan->righttree = NULL;
5623 List *bitmapqualorig,
5629 plan->targetlist = qptlist;
5630 plan->qual = qpqual;
5631 plan->lefttree = lefttree;
5632 plan->righttree = NULL;
5648 plan->targetlist = qptlist;
5649 plan->qual = qpqual;
5650 plan->lefttree = NULL;
5651 plan->righttree = NULL;
5662 List *tidrangequals)
5667 plan->targetlist = qptlist;
5668 plan->qual = qpqual;
5669 plan->lefttree = NULL;
5670 plan->righttree = NULL;
5686 plan->targetlist = qptlist;
5687 plan->qual = qpqual;
5688 plan->lefttree = NULL;
5689 plan->righttree = NULL;
5702 bool funcordinality)
5707 plan->targetlist = qptlist;
5708 plan->qual = qpqual;
5709 plan->lefttree = NULL;
5710 plan->righttree = NULL;
5727 plan->targetlist = qptlist;
5728 plan->qual = qpqual;
5729 plan->lefttree = NULL;
5730 plan->righttree = NULL;
5746 plan->targetlist = qptlist;
5747 plan->qual = qpqual;
5748 plan->lefttree = NULL;
5749 plan->righttree = NULL;
5766 plan->targetlist = qptlist;
5767 plan->qual = qpqual;
5768 plan->lefttree = NULL;
5769 plan->righttree = NULL;
5787 plan->targetlist = qptlist;
5788 plan->qual = qpqual;
5789 plan->lefttree = NULL;
5790 plan->righttree = NULL;
5806 plan->targetlist = qptlist;
5807 plan->qual = qpqual;
5808 plan->lefttree = NULL;
5809 plan->righttree = NULL;
5822 List *fdw_scan_tlist,
5823 List *fdw_recheck_quals,
5830 plan->targetlist = qptlist;
5831 plan->qual = qpqual;
5832 plan->lefttree = outer_plan;
5833 plan->righttree = NULL;
5868 plan->targetlist = tlist;
5870 plan->lefttree = lefttree;
5871 plan->righttree = righttree;
5891 foreach(slitem, distinctList)
5897 dupColIdx[keyno] = tle->
resno;
5898 dupOperators[keyno] = sortcl->
eqop;
5903 node->dupColIdx = dupColIdx;
5904 node->dupOperators = dupOperators;
5905 node->dupCollations = dupCollations;
5920 plan->lefttree = NULL;
5921 plan->righttree = NULL;
5935 plan->lefttree = NULL;
5936 plan->righttree = NULL;
5955 plan->targetlist = tlist;
5956 plan->qual = otherclauses;
5957 plan->lefttree = lefttree;
5958 plan->righttree = righttree;
5972 List *hashoperators,
5973 List *hashcollations,
5983 plan->targetlist = tlist;
5984 plan->qual = otherclauses;
5985 plan->lefttree = lefttree;
5986 plan->righttree = righttree;
6010 plan->lefttree = lefttree;
6011 plan->righttree = NULL;
6027 Oid *mergecollations,
6028 int *mergestrategies,
6029 bool *mergenullsfirst,
6034 bool skip_mark_restore)
6039 plan->targetlist = tlist;
6040 plan->qual = otherclauses;
6041 plan->lefttree = lefttree;
6042 plan->righttree = righttree;
6045 node->mergeFamilies = mergefamilies;
6046 node->mergeCollations = mergecollations;
6047 node->mergeStrategies = mergestrategies;
6048 node->mergeNullsFirst = mergenullsfirst;
6065 Oid *collations,
bool *nullsFirst)
6075 plan->lefttree = lefttree;
6076 plan->righttree = NULL;
6078 node->sortColIdx = sortColIdx;
6079 node->sortOperators = sortOperators;
6080 node->collations = collations;
6081 node->nullsFirst = nullsFirst;
6095 Oid *collations,
bool *nullsFirst)
6105 plan->lefttree = lefttree;
6106 plan->righttree = NULL;
6109 node->
sort.sortColIdx = sortColIdx;
6110 node->
sort.sortOperators = sortOperators;
6111 node->
sort.collations = collations;
6112 node->
sort.nullsFirst = nullsFirst;
6162 bool adjust_tlist_in_place,
6165 Oid **p_sortOperators,
6167 bool **p_nullsFirst)
6182 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6183 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6184 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6188 foreach(
i, pathkeys)
6206 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6212 else if (reqColIdx != NULL)
6272 elog(
ERROR,
"could not find pathkey item to sort");
6278 if (!adjust_tlist_in_place &&
6288 adjust_tlist_in_place =
true;
6310 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6315 sortColIdx[numsortkeys] = tle->
resno;
6316 sortOperators[numsortkeys] = sortop;
6323 *p_numsortkeys = numsortkeys;
6324 *p_sortColIdx = sortColIdx;
6325 *p_sortOperators = sortOperators;
6326 *p_collations = collations;
6327 *p_nullsFirst = nullsFirst;
6362 sortColIdx, sortOperators,
6363 collations, nullsFirst);
6377 Relids relids,
int nPresortedCols)
6398 sortColIdx, sortOperators,
6399 collations, nullsFirst);
6423 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6424 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6425 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6433 sortColIdx[numsortkeys] = tle->
resno;
6434 sortOperators[numsortkeys] = sortcl->
sortop;
6441 sortColIdx, sortOperators,
6442 collations, nullsFirst);
6474 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6475 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6476 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6479 foreach(l, groupcls)
6485 elog(
ERROR,
"could not retrieve tle for sort-from-groupcols");
6487 sortColIdx[numsortkeys] = tle->
resno;
6488 sortOperators[numsortkeys] = grpcl->
sortop;
6495 sortColIdx, sortOperators,
6496 collations, nullsFirst);
6507 plan->lefttree = lefttree;
6508 plan->righttree = NULL;
6527 bool unsafe_initplans;
6542 &initplan_cost, &unsafe_initplans);
6564 List *param_exprs,
bool singlerow,
bool binary_mode,
6572 plan->lefttree = lefttree;
6573 plan->righttree = NULL;
6576 node->hashOperators = hashoperators;
6577 node->collations = collations;
6590 int numGroupCols,
AttrNumber *grpColIdx,
Oid *grpOperators,
Oid *grpCollations,
6591 List *groupingSets,
List *chain,
double dNumGroups,
6592 Size transitionSpace,
Plan *lefttree)
6604 node->grpColIdx = grpColIdx;
6605 node->grpOperators = grpOperators;
6606 node->grpCollations = grpCollations;
6611 node->
chain = chain;
6614 plan->targetlist = tlist;
6615 plan->lefttree = lefttree;
6616 plan->righttree = NULL;
6623 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
6624 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
6625 int frameOptions,
Node *startOffset,
Node *endOffset,
6626 Oid startInRangeFunc,
Oid endInRangeFunc,
6627 Oid inRangeColl,
bool inRangeAsc,
bool inRangeNullsFirst,
6628 List *runCondition,
List *qual,
bool topWindow,
Plan *lefttree)
6635 node->partColIdx = partColIdx;
6636 node->partOperators = partOperators;
6637 node->partCollations = partCollations;
6639 node->ordColIdx = ordColIdx;
6640 node->ordOperators = ordOperators;
6641 node->ordCollations = ordCollations;
6655 plan->targetlist = tlist;
6656 plan->lefttree = lefttree;
6657 plan->righttree = NULL;
6676 node->grpColIdx = grpColIdx;
6677 node->grpOperators = grpOperators;
6678 node->grpCollations = grpCollations;
6681 plan->targetlist = tlist;
6682 plan->lefttree = lefttree;
6683 plan->righttree = NULL;
6702 Oid *uniqCollations;
6707 plan->lefttree = lefttree;
6708 plan->righttree = NULL;
6717 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6719 foreach(slitem, distinctList)
6724 uniqColIdx[keyno] = tle->
resno;
6725 uniqOperators[keyno] = sortcl->
eqop;
6732 node->uniqColIdx = uniqColIdx;
6733 node->uniqOperators = uniqOperators;
6734 node->uniqCollations = uniqCollations;
6750 Oid *uniqCollations;
6755 plan->lefttree = lefttree;
6756 plan->righttree = NULL;
6766 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6768 foreach(lc, pathkeys)
6779 if (keyno >= numCols)
6790 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6803 foreach(
j,
plan->targetlist)
6818 elog(
ERROR,
"could not find pathkey item to sort");
6829 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6833 uniqColIdx[keyno] = tle->
resno;
6834 uniqOperators[keyno] = eqop;
6841 node->uniqColIdx = uniqColIdx;
6842 node->uniqOperators = uniqOperators;
6843 node->uniqCollations = uniqCollations;
6859 plan->targetlist = qptlist;
6860 plan->qual = qpqual;
6861 plan->lefttree = subplan;
6862 plan->righttree = NULL;
6893 plan->lefttree = lefttree;
6894 plan->righttree = NULL;
6904 foreach(slitem, distinctList)
6909 dupColIdx[keyno] = tle->
resno;
6910 dupOperators[keyno] = sortcl->
eqop;
6919 node->dupColIdx = dupColIdx;
6920 node->dupOperators = dupOperators;
6921 node->dupCollations = dupCollations;
6941 plan->lefttree = lefttree;
6942 plan->righttree = NULL;
6957 Oid *uniqOperators,
Oid *uniqCollations)
6964 plan->lefttree = lefttree;
6965 plan->righttree = NULL;
6971 node->uniqColIdx = uniqColIdx;
6972 node->uniqOperators = uniqOperators;
6973 node->uniqCollations = uniqCollations;
6984 Node *resconstantqual,
6990 plan->targetlist = tlist;
6992 plan->lefttree = subplan;
6993 plan->righttree = NULL;
7010 plan->targetlist = tlist;
7012 plan->lefttree = subplan;
7013 plan->righttree = NULL;
7024 CmdType operation,
bool canSetTag,
7026 bool partColsUpdated,
7027 List *resultRelations,
7028 List *updateColnosLists,
7029 List *withCheckOptionLists,
List *returningLists,
7031 List *mergeActionLists,
List *mergeJoinConditions,
7035 List *fdw_private_list;
7043 updateColnosLists ==
NIL));
7109 fdw_private_list =
NIL;
7110 direct_modify_plans = NULL;
7112 foreach(lc, resultRelations)
7126 if (rti < root->simple_rel_array_size &&
7127 root->simple_rel_array[rti] != NULL)
7131 fdwroutine = resultRel->fdwroutine;
7138 rte->relkind == RELKIND_FOREIGN_TABLE)
7151 if (operation ==
CMD_MERGE && fdwroutine != NULL)
7156 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7157 errmsg(
"cannot execute MERGE on relation \"%s\"",
7169 direct_modify =
false;
7170 if (fdwroutine != NULL &&
7175 withCheckOptionLists ==
NIL &&
7182 if (!direct_modify &&
7183 fdwroutine != NULL &&
7188 fdw_private_list =
lappend(fdw_private_list, fdw_private);
7211 case T_IncrementalSort:
7218 case T_RecursiveUnion:
7268 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)