70#define CP_EXACT_TLIST 0x0001
71#define CP_SMALL_TLIST 0x0002
72#define CP_LABEL_TLIST 0x0004
73#define CP_IGNORE_TLIST 0x0008
126 List *tlist,
List *scan_clauses,
bool indexonly);
167 List **stripped_indexquals_p,
168 List **fixed_indexquals_p);
179 double limit_tuples);
181 List *pathkeys,
double limit_tuples);
187 List *indexorderby,
List *indexorderbyorig,
188 List *indexorderbyops,
198 List *indexqualorig);
202 List *bitmapqualorig,
219 Index scanrelid,
int ctePlanId,
int cteParam);
221 Index scanrelid,
char *enrname);
223 Index scanrelid,
int wtParam);
233 List *joinclauses,
List *otherclauses,
List *nestParams,
235 JoinType jointype,
bool inner_unique);
237 List *joinclauses,
List *otherclauses,
239 List *hashoperators,
List *hashcollations,
242 JoinType jointype,
bool inner_unique);
249 List *joinclauses,
List *otherclauses,
252 Oid *mergecollations,
253 bool *mergereversals,
254 bool *mergenullsfirst,
256 JoinType jointype,
bool inner_unique,
257 bool skip_mark_restore);
260 Oid *collations,
bool *nullsFirst);
262 int numCols,
int nPresortedCols,
264 Oid *collations,
bool *nullsFirst);
268 bool adjust_tlist_in_place,
271 Oid **p_sortOperators,
273 bool **p_nullsFirst);
277 List *pathkeys,
Relids relids,
int nPresortedCols);
283 Oid *collations,
List *param_exprs,
284 bool singlerow,
bool binary_mode,
288 double est_hit_ratio);
290 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
291 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
292 List *runCondition,
List *qual,
bool topWindow,
298 List *pathkeys,
int numCols,
301 int nworkers,
int rescan_param,
bool single_copy,
Plan *subplan);
304 List *groupList,
long numGroups);
312 CmdType operation,
bool canSetTag,
314 bool partColsUpdated,
315 List *resultRelations,
316 List *updateColnosLists,
317 List *withCheckOptionLists,
List *returningLists,
319 List *mergeActionLists,
List *mergeJoinConditions,
349 root->curOuterRels = NULL;
375 if (
root->curOuterParams !=
NIL)
376 elog(
ERROR,
"failed to assign all NestLoopParams to plan nodes");
404 case T_IndexOnlyScan:
405 case T_BitmapHeapScan:
410 case T_TableFuncScan:
413 case T_WorkTableScan:
414 case T_NamedTuplestoreScan:
487 case T_IncrementalSort:
516 case T_RecursiveUnion:
539 elog(
ERROR,
"unrecognized node type: %d",
540 (
int) best_path->pathtype);
557 List *gating_clauses;
576 case T_IndexOnlyScan:
590 if (best_path->param_info)
592 best_path->param_info->ppi_clauses);
609 best_path->
pathtype == T_CustomScan);
610 if (best_path->
pathtype == T_ForeignScan)
611 join_clauses = ((
ForeignPath *) best_path)->fdw_restrictinfo;
613 join_clauses = ((
CustomPath *) best_path)->custom_restrictinfo;
638 if (best_path->
pathtype == T_IndexOnlyScan)
695 case T_IndexOnlyScan:
703 case T_BitmapHeapScan:
738 case T_TableFuncScan:
759 case T_NamedTuplestoreScan:
773 case T_WorkTableScan:
795 elog(
ERROR,
"unrecognized node type: %d",
822 Index *sortgrouprefs = path->pathtarget->sortgrouprefs;
826 foreach(v, path->pathtarget->exprs)
837 if (path->param_info)
906 path->pathtarget->exprs ==
NIL)
924 foreach(lc,
root->placeholder_list)
938 if (path->
pathtype == T_IndexOnlyScan)
944 if (!indexinfo->canreturn[
i])
963 foreach(lc, path->pathtarget->exprs)
967 if (path->pathtarget->sortgrouprefs[
i])
969 if (expr &&
IsA(expr,
Var))
971 int attno = ((
Var *) expr)->varattno;
999 if (!
root->hasPseudoConstantQuals)
1066 return &gplan->
plan;
1078 List *gating_clauses;
1080 switch (best_path->path.pathtype)
1095 elog(
ERROR,
"unrecognized node type: %d",
1096 (
int) best_path->path.pathtype);
1118 if (get_loc_restrictinfo(best_path) !=
NIL)
1138 case T_SubqueryScanPath:
1161 FdwRoutine *fdwroutine = path->parent->fdwroutine;
1170 Assert(fdwroutine != NULL);
1176 case T_ProjectionPath:
1197 plan->async_capable =
true;
1215 bool tlist_was_changed =
false;
1219 int nasyncplans = 0;
1221 int nodenumsortkeys = 0;
1223 Oid *nodeSortOperators = NULL;
1224 Oid *nodeCollations = NULL;
1225 bool *nodeNullsFirst = NULL;
1226 bool consider_async =
false;
1245 best_path->
path.parent);
1264 plan->plan.targetlist = tlist;
1266 plan->plan.lefttree = NULL;
1267 plan->plan.righttree = NULL;
1270 if (pathkeys !=
NIL)
1279 best_path->
path.parent->relids,
1287 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->plan.targetlist));
1296 foreach(subpaths, best_path->
subpaths)
1308 if (pathkeys !=
NIL)
1339 Assert(numsortkeys == nodenumsortkeys);
1340 if (memcmp(sortColIdx, nodeSortColIdx,
1342 elog(
ERROR,
"Append child's targetlist doesn't match Append");
1343 Assert(memcmp(sortOperators, nodeSortOperators,
1344 numsortkeys *
sizeof(
Oid)) == 0);
1345 Assert(memcmp(collations, nodeCollations,
1346 numsortkeys *
sizeof(
Oid)) == 0);
1347 Assert(memcmp(nullsFirst, nodeNullsFirst,
1348 numsortkeys *
sizeof(
bool)) == 0);
1362 sort_plan = (
Plan *)
1364 sortColIdx, sortOperators,
1365 collations, nullsFirst);
1375 sortColIdx, sortOperators,
1376 collations, nullsFirst);
1382 subplan = sort_plan;
1393 subplans =
lappend(subplans, subplan);
1397 plan->part_prune_index = -1;
1410 if (best_path->
path.param_info)
1412 List *prmquals = best_path->
path.param_info->ppi_clauses;
1421 if (prunequal !=
NIL)
1427 plan->appendplans = subplans;
1428 plan->nasyncplans = nasyncplans;
1442 plan->plan.parallel_safe);
1463 bool tlist_was_changed;
1476 plan->targetlist = tlist;
1478 plan->lefttree = NULL;
1479 plan->righttree = NULL;
1489 best_path->
path.parent->relids,
1494 &node->sortOperators,
1497 tlist_was_changed = (orig_tlist_length !=
list_length(
plan->targetlist));
1504 foreach(subpaths, best_path->
subpaths)
1537 if (memcmp(sortColIdx, node->sortColIdx,
1539 elog(
ERROR,
"MergeAppend child's targetlist doesn't match MergeAppend");
1540 Assert(memcmp(sortOperators, node->sortOperators,
1541 numsortkeys *
sizeof(
Oid)) == 0);
1542 Assert(memcmp(collations, node->collations,
1543 numsortkeys *
sizeof(
Oid)) == 0);
1544 Assert(memcmp(nullsFirst, node->nullsFirst,
1545 numsortkeys *
sizeof(
bool)) == 0);
1559 sort_plan = (
Plan *)
1561 sortColIdx, sortOperators,
1562 collations, nullsFirst);
1572 sortColIdx, sortOperators,
1573 collations, nullsFirst);
1579 subplan = sort_plan;
1582 subplans =
lappend(subplans, subplan);
1602 if (prunequal !=
NIL)
1732 operators =
palloc(nkeys *
sizeof(
Oid));
1733 collations =
palloc(nkeys *
sizeof(
Oid));
1741 operators[
i] = opno;
1791 root->glob->parallelModeNeeded =
true;
1827 best_path->
subpath->parent->relids,
1828 gm_plan->sortColIdx,
1831 &gm_plan->sortColIdx,
1832 &gm_plan->sortOperators,
1833 &gm_plan->collations,
1834 &gm_plan->nullsFirst);
1846 root->glob->parallelModeNeeded =
true;
1864 bool needs_result_node =
false;
1890 best_path->
path.pathtarget);
1924 if (!needs_result_node)
1928 plan->targetlist = tlist;
1934 plan->plan_width = best_path->
path.pathtarget->width;
1974 plan->parallel_safe = parallel_safe;
2003 tlist_parallel_safe);
2041 best_path->
path.parent->relids : NULL);
2066 best_path->
spath.
path.parent->relids : NULL,
2142 best_path->
path.parent->relids : NULL);
2214 foreach(lc, groupClause)
2221 return new_grpColIdx;
2266 foreach(lc,
root->processed_groupClause)
2277 foreach(lc,
root->processed_groupClause)
2290 root->grouping_map = grouping_map;
2307 Plan *sort_plan = NULL;
2313 if (!rollup->
is_hashed && !is_first_sort)
2315 sort_plan = (
Plan *)
2322 is_first_sort =
false;
2354 chain =
lappend(chain, agg_plan);
2424 0, NULL, NULL, NULL);
2430 plan->plan_rows = 1;
2431 plan->plan_width = mminfo->
path->pathtarget->width;
2432 plan->parallel_aware =
false;
2443 best_path->
path.parent);
2478 Oid *partCollations;
2502 partCollations = (
Oid *)
palloc(
sizeof(
Oid) * numPart);
2511 partColIdx[partNumCols] = tle->
resno;
2512 partOperators[partNumCols] = sgc->
eqop;
2519 ordCollations = (
Oid *)
palloc(
sizeof(
Oid) * numOrder);
2528 ordColIdx[ordNumCols] = tle->
resno;
2529 ordOperators[ordNumCols] = sgc->
eqop;
2706 int numUniqkeys = 0;
2708 Oid *uniqOperators = NULL;
2709 Oid *uniqCollations = NULL;
2722 uniqOperators = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2723 uniqCollations = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2726 foreach(l,
parse->sortClause)
2731 uniqColIdx[numUniqkeys] = tle->
resno;
2732 uniqOperators[numUniqkeys] = sortcl->
eqop;
2742 numUniqkeys, uniqColIdx, uniqOperators, uniqCollations);
2767 Index scan_relid = best_path->parent->relid;
2780 if (best_path->param_info)
2782 scan_clauses = (
List *)
2805 Index scan_relid = best_path->parent->relid;
2823 if (best_path->param_info)
2825 scan_clauses = (
List *)
2861 Index baserelid = best_path->
path.parent->relid;
2865 List *stripped_indexquals;
2866 List *fixed_indexquals;
2867 List *fixed_indexorderbys;
2885 &stripped_indexquals,
2922 foreach(l, scan_clauses)
2926 if (rinfo->pseudoconstant)
2934 qpqual =
lappend(qpqual, rinfo);
2952 if (best_path->
path.param_info)
2954 stripped_indexquals = (
List *)
2958 indexorderbys = (
List *)
2990 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
2992 indexorderbyops =
lappend_oid(indexorderbyops, sortop);
3009 indextle->resjunk = !indexinfo->canreturn[
i];
3021 stripped_indexquals,
3022 fixed_indexorderbys,
3031 stripped_indexquals,
3032 fixed_indexorderbys,
3053 Index baserelid = best_path->
path.parent->relid;
3054 Plan *bitmapqualplan;
3055 List *bitmapqualorig;
3068 &bitmapqualorig, &indexquals,
3101 foreach(l, scan_clauses)
3106 if (rinfo->pseudoconstant)
3115 qpqual =
lappend(qpqual, rinfo);
3137 if (best_path->
path.param_info)
3141 bitmapqualorig = (
List *)
3207 &subqual, &subindexqual,
3209 subplans =
lappend(subplans, subplan);
3213 subindexECs =
list_concat(subindexECs, subindexEC);
3220 plan->plan_width = 0;
3221 plan->parallel_aware =
false;
3224 *indexqual = subindexquals;
3225 *indexECs = subindexECs;
3233 bool const_true_subqual =
false;
3234 bool const_true_subindexqual =
false;
3254 &subqual, &subindexqual,
3256 subplans =
lappend(subplans, subplan);
3258 const_true_subqual =
true;
3259 else if (!const_true_subqual)
3262 if (subindexqual ==
NIL)
3263 const_true_subindexqual =
true;
3264 else if (!const_true_subindexqual)
3265 subindexquals =
lappend(subindexquals,
3284 plan->plan_width = 0;
3285 plan->parallel_aware =
false;
3294 if (const_true_subqual)
3300 if (const_true_subindexqual)
3303 *indexqual = subindexquals;
3313 List *subindexquals;
3327 plan->startup_cost = 0.0;
3331 plan->plan_width = 0;
3332 plan->parallel_aware =
false;
3336 subindexquals =
NIL;
3343 Assert(!rinfo->pseudoconstant);
3347 if (rinfo->parent_ec)
3348 subindexECs =
lappend(subindexECs, rinfo->parent_ec);
3363 subquals =
lappend(subquals, pred);
3364 subindexquals =
lappend(subindexquals, pred);
3368 *indexqual = subindexquals;
3369 *indexECs = subindexECs;
3390 Index scan_relid = best_path->
path.parent->relid;
3421 foreach(l, scan_clauses)
3425 if (rinfo->pseudoconstant)
3431 qpqual =
lappend(qpqual, rinfo);
3433 scan_clauses = qpqual;
3459 if (best_path->
path.param_info)
3463 scan_clauses = (
List *)
3487 Index scan_relid = best_path->
path.parent->relid;
3503 foreach(l, scan_clauses)
3507 if (rinfo->pseudoconstant)
3511 qpqual =
lappend(qpqual, rinfo);
3513 scan_clauses = qpqual;
3524 if (best_path->
path.param_info)
3526 tidrangequals = (
List *)
3528 scan_clauses = (
List *)
3583 if (best_path->
path.param_info)
3587 scan_clauses = (
List *)
3611 Index scan_relid = best_path->parent->relid;
3628 if (best_path->param_info)
3630 scan_clauses = (
List *)
3654 Index scan_relid = best_path->parent->relid;
3671 if (best_path->param_info)
3673 scan_clauses = (
List *)
3697 Index scan_relid = best_path->parent->relid;
3714 if (best_path->param_info)
3716 scan_clauses = (
List *)
3719 values_lists = (
List *)
3741 Index scan_relid = best_path->parent->relid;
3754 Assert(!rte->self_reference);
3761 while (levelsup-- > 0)
3763 cteroot = cteroot->parent_root;
3792 if (ctesplan->
plan_id == plan_id)
3811 if (best_path->param_info)
3813 scan_clauses = (
List *)
3817 scan_plan =
make_ctescan(tlist, scan_clauses, scan_relid,
3818 plan_id, cte_param_id);
3836 Index scan_relid = best_path->parent->relid;
3850 if (best_path->param_info)
3852 scan_clauses = (
List *)
3875 Index scan_relid = best_path->parent->relid;
3889 if (best_path->param_info)
3891 scan_clauses = (
List *)
3913 Index scan_relid = best_path->parent->relid;
3921 Assert(rte->self_reference);
3933 while (levelsup-- > 0)
3935 cteroot = cteroot->parent_root;
3949 if (best_path->param_info)
3951 scan_clauses = (
List *)
3976 Plan *outer_plan = NULL;
3978 Assert(rel->fdwroutine != NULL);
3996 rel_oid = rte->relid;
4012 scan_plan = rel->fdwroutine->GetForeignPlan(
root, rel, rel_oid,
4014 tlist, scan_clauses,
4042 root->outer_join_rels);
4050 root->glob->dependsOnRole =
true;
4060 if (best_path->
path.param_info)
4062 scan_plan->
scan.plan.qual = (
List *)
4176 if (best_path->
path.param_info)
4208 bool outer_parallel_safe;
4239 root->curOuterRels = saveOuterRels;
4249 best_path->
jpath.path.parent->relids,
4250 &joinclauses, &otherclauses);
4260 if (best_path->
jpath.path.param_info)
4262 joinclauses = (
List *)
4264 otherclauses = (
List *)
4289 foreach(lc, nestParams)
4312 (
Node *) phv->phexpr);
4322 outer_tlist =
lappend(outer_tlist, tle);
4324 if (outer_parallel_safe)
4329 outer_parallel_safe);
4357 List *outerpathkeys;
4358 List *innerpathkeys;
4361 Oid *mergecollations;
4362 bool *mergereversals;
4363 bool *mergenullsfirst;
4394 best_path->
jpath.path.parent->relids,
4395 &joinclauses, &otherclauses);
4415 if (best_path->
jpath.path.param_info)
4417 joinclauses = (
List *)
4419 otherclauses = (
List *)
4436 Relids outer_relids = outer_path->parent->relids;
4453 sort_plan = (
Plan *)
4466 sort_plan = (
Plan *)
4474 outer_plan = sort_plan;
4487 Relids inner_relids = inner_path->parent->relids;
4525 inner_plan = matplan;
4537 mergefamilies = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4538 mergecollations = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4539 mergereversals = (
bool *)
palloc(nClauses *
sizeof(
bool));
4540 mergenullsfirst = (
bool *)
palloc(nClauses *
sizeof(
bool));
4554 bool first_inner_match =
false;
4557 if (rinfo->outer_is_left)
4559 oeclass = rinfo->left_ec;
4560 ieclass = rinfo->right_ec;
4564 oeclass = rinfo->right_ec;
4565 ieclass = rinfo->left_ec;
4585 if (oeclass != opeclass)
4589 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4591 opeclass = opathkey->pk_eclass;
4592 lop =
lnext(outerpathkeys, lop);
4593 if (oeclass != opeclass)
4594 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4615 ipeclass = ipathkey->pk_eclass;
4616 if (ieclass == ipeclass)
4619 lip =
lnext(innerpathkeys, lip);
4620 first_inner_match =
true;
4623 if (!first_inner_match)
4628 foreach(l2, innerpathkeys)
4633 ipeclass = ipathkey->pk_eclass;
4634 if (ieclass == ipeclass)
4637 if (ieclass != ipeclass)
4638 elog(
ERROR,
"inner pathkeys do not match mergeclauses");
4656 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation)
4657 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4658 if (first_inner_match &&
4661 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4665 mergecollations[
i] = opathkey->pk_eclass->ec_collation;
4718 bool skewInherit =
false;
4743 best_path->
jpath.path.parent->relids,
4744 &joinclauses, &otherclauses);
4764 if (best_path->
jpath.path.param_info)
4766 joinclauses = (
List *)
4768 otherclauses = (
List *)
4801 rte =
root->simple_rte_array[var->
varno];
4804 skewTable = rte->relid;
4806 skewInherit = rte->
inh;
4819 foreach(lc, hashclauses)
4824 hashcollations =
lappend_oid(hashcollations, hclause->inputcollid);
4850 if (best_path->
jpath.path.parallel_aware)
4923 root->curOuterRels))
4943 newphv->phexpr = (
Expr *)
4946 return (
Node *) newphv;
4976 List **stripped_indexquals_p,
List **fixed_indexquals_p)
4979 List *stripped_indexquals;
4980 List *fixed_indexquals;
4983 stripped_indexquals = fixed_indexquals =
NIL;
4996 stripped_indexquals =
lappend(stripped_indexquals, clause);
4999 fixed_indexquals =
lappend(fixed_indexquals, clause);
5003 *stripped_indexquals_p = stripped_indexquals;
5004 *fixed_indexquals_p = fixed_indexquals;
5019 List *fixed_indexorderbys;
5023 fixed_indexorderbys =
NIL;
5031 fixed_indexorderbys =
lappend(fixed_indexorderbys, clause);
5034 return fixed_indexorderbys;
5099 elog(
ERROR,
"unsupported indexqual type: %d",
5128 Assert(indexcol >= 0 && indexcol < index->ncolumns);
5130 if (
index->indexkeys[indexcol] != 0)
5134 ((
Var *) node)->varno ==
index->rel->relid &&
5135 ((
Var *) node)->varattno ==
index->indexkeys[indexcol])
5140 return (
Node *) result;
5143 elog(
ERROR,
"index key does not match expected index column");
5148 for (pos = 0; pos <
index->ncolumns; pos++)
5150 if (
index->indexkeys[pos] == 0)
5152 if (indexpr_item == NULL)
5153 elog(
ERROR,
"too few entries in indexprs list");
5154 if (pos == indexcol)
5161 if (
equal(node, indexkey))
5167 return (
Node *) result;
5170 elog(
ERROR,
"index key does not match expected index column");
5172 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5177 elog(
ERROR,
"index key does not match expected index column");
5213 temp->opresulttype = clause->opresulttype;
5214 temp->opretset = clause->opretset;
5215 temp->opcollid = clause->opcollid;
5216 temp->inputcollid = clause->inputcollid;
5221 t_list =
lappend(t_list, temp);
5222 restrictinfo->outer_is_left =
false;
5227 t_list =
lappend(t_list, clause);
5228 restrictinfo->outer_is_left =
true;
5274 Index security_level;
5292 foreach(lc, clauses)
5298 items[
i].clause = clause;
5315 items[
i].security_level = 0;
5320 items[
i].security_level = 0;
5331 QualItem newitem =
items[
i];
5335 for (
j =
i;
j > 0;
j--)
5337 QualItem *olditem = &
items[
j - 1];
5339 if (newitem.security_level > olditem->security_level ||
5340 (newitem.security_level == olditem->security_level &&
5341 newitem.cost >= olditem->cost))
5368 dest->plan_width = src->pathtarget->width;
5386 dest->parallel_aware =
false;
5403 Plan *lefttree =
plan->plan.lefttree;
5409 plan->plan.disabled_nodes,
5420 plan->plan.parallel_aware =
false;
5430 List *pathkeys,
double limit_tuples)
5432 Plan *lefttree =
plan->sort.plan.lefttree;
5438 plan->nPresortedCols,
5439 plan->sort.plan.disabled_nodes,
5451 plan->sort.plan.parallel_aware =
false;
5498 plan->targetlist = qptlist;
5499 plan->qual = qpqual;
5500 plan->lefttree = NULL;
5501 plan->righttree = NULL;
5516 plan->targetlist = qptlist;
5517 plan->qual = qpqual;
5518 plan->lefttree = NULL;
5519 plan->righttree = NULL;
5532 List *indexqualorig,
5534 List *indexorderbyorig,
5535 List *indexorderbyops,
5541 plan->targetlist = qptlist;
5542 plan->qual = qpqual;
5543 plan->lefttree = NULL;
5544 plan->righttree = NULL;
5571 plan->targetlist = qptlist;
5572 plan->qual = qpqual;
5573 plan->lefttree = NULL;
5574 plan->righttree = NULL;
5590 List *indexqualorig)
5597 plan->lefttree = NULL;
5598 plan->righttree = NULL;
5611 List *bitmapqualorig,
5617 plan->targetlist = qptlist;
5618 plan->qual = qpqual;
5619 plan->lefttree = lefttree;
5620 plan->righttree = NULL;
5636 plan->targetlist = qptlist;
5637 plan->qual = qpqual;
5638 plan->lefttree = NULL;
5639 plan->righttree = NULL;
5650 List *tidrangequals)
5655 plan->targetlist = qptlist;
5656 plan->qual = qpqual;
5657 plan->lefttree = NULL;
5658 plan->righttree = NULL;
5674 plan->targetlist = qptlist;
5675 plan->qual = qpqual;
5676 plan->lefttree = NULL;
5677 plan->righttree = NULL;
5690 bool funcordinality)
5695 plan->targetlist = qptlist;
5696 plan->qual = qpqual;
5697 plan->lefttree = NULL;
5698 plan->righttree = NULL;
5715 plan->targetlist = qptlist;
5716 plan->qual = qpqual;
5717 plan->lefttree = NULL;
5718 plan->righttree = NULL;
5734 plan->targetlist = qptlist;
5735 plan->qual = qpqual;
5736 plan->lefttree = NULL;
5737 plan->righttree = NULL;
5754 plan->targetlist = qptlist;
5755 plan->qual = qpqual;
5756 plan->lefttree = NULL;
5757 plan->righttree = NULL;
5775 plan->targetlist = qptlist;
5776 plan->qual = qpqual;
5777 plan->lefttree = NULL;
5778 plan->righttree = NULL;
5794 plan->targetlist = qptlist;
5795 plan->qual = qpqual;
5796 plan->lefttree = NULL;
5797 plan->righttree = NULL;
5810 List *fdw_scan_tlist,
5811 List *fdw_recheck_quals,
5818 plan->targetlist = qptlist;
5819 plan->qual = qpqual;
5820 plan->lefttree = outer_plan;
5821 plan->righttree = NULL;
5856 plan->targetlist = tlist;
5858 plan->lefttree = lefttree;
5859 plan->righttree = righttree;
5879 foreach(slitem, distinctList)
5885 dupColIdx[keyno] = tle->
resno;
5886 dupOperators[keyno] = sortcl->
eqop;
5891 node->dupColIdx = dupColIdx;
5892 node->dupOperators = dupOperators;
5893 node->dupCollations = dupCollations;
5908 plan->lefttree = NULL;
5909 plan->righttree = NULL;
5923 plan->lefttree = NULL;
5924 plan->righttree = NULL;
5943 plan->targetlist = tlist;
5944 plan->qual = otherclauses;
5945 plan->lefttree = lefttree;
5946 plan->righttree = righttree;
5960 List *hashoperators,
5961 List *hashcollations,
5971 plan->targetlist = tlist;
5972 plan->qual = otherclauses;
5973 plan->lefttree = lefttree;
5974 plan->righttree = righttree;
5998 plan->lefttree = lefttree;
5999 plan->righttree = NULL;
6015 Oid *mergecollations,
6016 bool *mergereversals,
6017 bool *mergenullsfirst,
6022 bool skip_mark_restore)
6027 plan->targetlist = tlist;
6028 plan->qual = otherclauses;
6029 plan->lefttree = lefttree;
6030 plan->righttree = righttree;
6033 node->mergeFamilies = mergefamilies;
6034 node->mergeCollations = mergecollations;
6035 node->mergeReversals = mergereversals;
6036 node->mergeNullsFirst = mergenullsfirst;
6053 Oid *collations,
bool *nullsFirst)
6064 plan->lefttree = lefttree;
6065 plan->righttree = NULL;
6067 node->sortColIdx = sortColIdx;
6068 node->sortOperators = sortOperators;
6069 node->collations = collations;
6070 node->nullsFirst = nullsFirst;
6084 Oid *collations,
bool *nullsFirst)
6094 plan->lefttree = lefttree;
6095 plan->righttree = NULL;
6098 node->
sort.sortColIdx = sortColIdx;
6099 node->
sort.sortOperators = sortOperators;
6100 node->
sort.collations = collations;
6101 node->
sort.nullsFirst = nullsFirst;
6151 bool adjust_tlist_in_place,
6154 Oid **p_sortOperators,
6156 bool **p_nullsFirst)
6171 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6172 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6173 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6177 foreach(
i, pathkeys)
6195 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6201 else if (reqColIdx != NULL)
6261 elog(
ERROR,
"could not find pathkey item to sort");
6267 if (!adjust_tlist_in_place &&
6277 adjust_tlist_in_place =
true;
6299 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6300 pathkey->
pk_cmptype, pk_datatype, pk_datatype,
6304 sortColIdx[numsortkeys] = tle->
resno;
6305 sortOperators[numsortkeys] = sortop;
6312 *p_numsortkeys = numsortkeys;
6313 *p_sortColIdx = sortColIdx;
6314 *p_sortOperators = sortOperators;
6315 *p_collations = collations;
6316 *p_nullsFirst = nullsFirst;
6351 sortColIdx, sortOperators,
6352 collations, nullsFirst);
6366 Relids relids,
int nPresortedCols)
6387 sortColIdx, sortOperators,
6388 collations, nullsFirst);
6412 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6413 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6414 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6422 sortColIdx[numsortkeys] = tle->
resno;
6423 sortOperators[numsortkeys] = sortcl->
sortop;
6430 sortColIdx, sortOperators,
6431 collations, nullsFirst);
6463 sortOperators = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6464 collations = (
Oid *)
palloc(numsortkeys *
sizeof(
Oid));
6465 nullsFirst = (
bool *)
palloc(numsortkeys *
sizeof(
bool));
6468 foreach(l, groupcls)
6474 elog(
ERROR,
"could not retrieve tle for sort-from-groupcols");
6476 sortColIdx[numsortkeys] = tle->
resno;
6477 sortOperators[numsortkeys] = grpcl->
sortop;
6484 sortColIdx, sortOperators,
6485 collations, nullsFirst);
6496 plan->lefttree = lefttree;
6497 plan->righttree = NULL;
6516 bool unsafe_initplans;
6531 &initplan_cost, &unsafe_initplans);
6555 List *param_exprs,
bool singlerow,
bool binary_mode,
6558 double est_hit_ratio)
6565 plan->lefttree = lefttree;
6566 plan->righttree = NULL;
6569 node->hashOperators = hashoperators;
6570 node->collations = collations;
6586 int numGroupCols,
AttrNumber *grpColIdx,
Oid *grpOperators,
Oid *grpCollations,
6587 List *groupingSets,
List *chain,
double dNumGroups,
6588 Size transitionSpace,
Plan *lefttree)
6600 node->grpColIdx = grpColIdx;
6601 node->grpOperators = grpOperators;
6602 node->grpCollations = grpCollations;
6607 node->
chain = chain;
6610 plan->targetlist = tlist;
6611 plan->lefttree = lefttree;
6612 plan->righttree = NULL;
6619 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
6620 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
6621 List *runCondition,
List *qual,
bool topWindow,
Plan *lefttree)
6629 node->partColIdx = partColIdx;
6630 node->partOperators = partOperators;
6631 node->partCollations = partCollations;
6633 node->ordColIdx = ordColIdx;
6634 node->ordOperators = ordOperators;
6635 node->ordCollations = ordCollations;
6649 plan->targetlist = tlist;
6650 plan->lefttree = lefttree;
6651 plan->righttree = NULL;
6670 node->grpColIdx = grpColIdx;
6671 node->grpOperators = grpOperators;
6672 node->grpCollations = grpCollations;
6675 plan->targetlist = tlist;
6676 plan->lefttree = lefttree;
6677 plan->righttree = NULL;
6697 Oid *uniqCollations;
6702 plan->lefttree = lefttree;
6703 plan->righttree = NULL;
6713 uniqCollations = (
Oid *)
palloc(
sizeof(
Oid) * numCols);
6715 foreach(lc, pathkeys)
6726 if (keyno >= numCols)
6737 elog(
ERROR,
"volatile EquivalenceClass has no sortref");
6750 foreach(
j,
plan->targetlist)
6765 elog(
ERROR,
"could not find pathkey item to sort");
6776 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
6780 uniqColIdx[keyno] = tle->
resno;
6781 uniqOperators[keyno] = eqop;
6788 node->uniqColIdx = uniqColIdx;
6789 node->uniqOperators = uniqOperators;
6790 node->uniqCollations = uniqCollations;
6806 plan->targetlist = qptlist;
6807 plan->qual = qpqual;
6808 plan->lefttree = subplan;
6809 plan->righttree = NULL;
6827 List *groupList,
long numGroups)
6836 bool *cmpNullsFirst;
6839 plan->targetlist = tlist;
6841 plan->lefttree = lefttree;
6842 plan->righttree = righttree;
6851 cmpNullsFirst = (
bool *)
palloc(
sizeof(
bool) * numCols);
6853 foreach(slitem, groupList)
6858 cmpColIdx[keyno] = tle->
resno;
6860 cmpOperators[keyno] = sortcl->
eqop;
6862 cmpOperators[keyno] = sortcl->
sortop;
6872 node->cmpColIdx = cmpColIdx;
6873 node->cmpOperators = cmpOperators;
6874 node->cmpCollations = cmpCollations;
6875 node->cmpNullsFirst = cmpNullsFirst;
6893 plan->lefttree = lefttree;
6894 plan->righttree = NULL;
6909 Oid *uniqOperators,
Oid *uniqCollations)
6916 plan->lefttree = lefttree;
6917 plan->righttree = NULL;
6923 node->uniqColIdx = uniqColIdx;
6924 node->uniqOperators = uniqOperators;
6925 node->uniqCollations = uniqCollations;
6937 Node *resconstantqual,
6945 plan->targetlist = tlist;
6947 plan->lefttree = subplan;
6948 plan->righttree = NULL;
6968 Node *resconstantqual,
6974 plan->targetlist = tlist;
6976 plan->lefttree = NULL;
6977 plan->righttree = NULL;
6997 plan->targetlist = tlist;
6999 plan->lefttree = subplan;
7000 plan->righttree = NULL;
7011 CmdType operation,
bool canSetTag,
7013 bool partColsUpdated,
7014 List *resultRelations,
7015 List *updateColnosLists,
7016 List *withCheckOptionLists,
List *returningLists,
7018 List *mergeActionLists,
List *mergeJoinConditions,
7022 bool returning_old_or_new =
false;
7023 bool returning_old_or_new_valid =
false;
7024 bool transition_tables =
false;
7025 bool transition_tables_valid =
false;
7026 List *fdw_private_list;
7034 updateColnosLists ==
NIL));
7102 fdw_private_list =
NIL;
7103 direct_modify_plans = NULL;
7105 foreach(lc, resultRelations)
7119 if (rti < root->simple_rel_array_size &&
7120 root->simple_rel_array[rti] != NULL)
7124 fdwroutine = resultRel->fdwroutine;
7131 rte->relkind == RELKIND_FOREIGN_TABLE)
7139 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
7140 errmsg(
"access to non-system foreign table is restricted")));
7156 if (operation ==
CMD_MERGE && fdwroutine != NULL)
7161 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7162 errmsg(
"cannot execute MERGE on relation \"%s\"",
7175 direct_modify =
false;
7176 if (fdwroutine != NULL &&
7181 withCheckOptionLists ==
NIL &&
7189 if (!returning_old_or_new_valid)
7191 returning_old_or_new =
7193 root->parse->returningList);
7194 returning_old_or_new_valid =
true;
7196 if (!returning_old_or_new)
7198 if (!transition_tables_valid)
7203 transition_tables_valid =
true;
7205 if (!transition_tables)
7213 if (!direct_modify &&
7214 fdwroutine != NULL &&
7219 fdw_private_list =
lappend(fdw_private_list, fdw_private);
7242 case T_IncrementalSort:
7249 case T_RecursiveUnion:
7299 case T_RecursiveUnion:
Datum sort(PG_FUNCTION_ARGS)
#define InvalidAttrNumber
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
void bms_free(Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
#define PG_USED_FOR_ASSERTS_ONLY
#define OidIsValid(objectId)
bool contain_mutable_functions(Node *clause)
bool is_parallel_safe(PlannerInfo *root, Node *node)
Bitmapset * pull_paramids(Expr *expr)
void CommuteOpExpr(OpExpr *clause)
void cost_material(Path *path, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double tuples, int width)
void cost_sort(Path *path, PlannerInfo *root, List *pathkeys, int input_disabled_nodes, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root)
void cost_incremental_sort(Path *path, PlannerInfo *root, List *pathkeys, int presorted_keys, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double input_tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
double clamp_row_est(double nrows)
long clamp_cardinality_to_long(Cardinality x)
bool enable_partition_pruning
bool enable_incremental_sort
static Plan * create_join_plan(PlannerInfo *root, JoinPath *best_path)
static bool use_physical_tlist(PlannerInfo *root, Path *path, int flags)
static SeqScan * create_seqscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static WorkTableScan * make_worktablescan(List *qptlist, List *qpqual, Index scanrelid, int wtParam)
static Plan * create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, int flags)
static List * order_qual_clauses(PlannerInfo *root, List *clauses)
static MergeJoin * make_mergejoin(List *tlist, List *joinclauses, List *otherclauses, List *mergeclauses, Oid *mergefamilies, Oid *mergecollations, bool *mergereversals, bool *mergenullsfirst, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique, bool skip_mark_restore)
static GatherMerge * create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path)
static ValuesScan * create_valuesscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static SetOp * make_setop(SetOpCmd cmd, SetOpStrategy strategy, List *tlist, Plan *lefttree, Plan *righttree, List *groupList, long numGroups)
static void copy_generic_path_info(Plan *dest, Path *src)
static WindowAgg * make_windowagg(List *tlist, WindowClause *wc, int partNumCols, AttrNumber *partColIdx, Oid *partOperators, Oid *partCollations, int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators, Oid *ordCollations, List *runCondition, List *qual, bool topWindow, Plan *lefttree)
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
static BitmapOr * make_bitmap_or(List *bitmapplans)
static HashJoin * create_hashjoin_plan(PlannerInfo *root, HashPath *best_path)
static SeqScan * make_seqscan(List *qptlist, List *qpqual, Index scanrelid)
static TableFuncScan * create_tablefuncscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static CustomScan * create_customscan_plan(PlannerInfo *root, CustomPath *best_path, List *tlist, List *scan_clauses)
static Node * fix_indexqual_operand(Node *node, IndexOptInfo *index, int indexcol)
static void fix_indexqual_references(PlannerInfo *root, IndexPath *index_path, List **stripped_indexquals_p, List **fixed_indexquals_p)
static List * fix_indexorderby_references(PlannerInfo *root, IndexPath *index_path)
static AttrNumber * remap_groupColIdx(PlannerInfo *root, List *groupClause)
static Plan * create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
static void bitmap_subplan_mark_shared(Plan *plan)
static Unique * create_unique_plan(PlannerInfo *root, UniquePath *best_path, int flags)
static Result * make_one_row_result(List *tlist, Node *resconstantqual, RelOptInfo *rel)
static TidScan * make_tidscan(List *qptlist, List *qpqual, Index scanrelid, List *tidquals)
static MergeJoin * create_mergejoin_plan(PlannerInfo *root, MergePath *best_path)
static Plan * create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
static void label_sort_with_costsize(PlannerInfo *root, Sort *plan, double limit_tuples)
static ForeignScan * create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path, List *tlist, List *scan_clauses)
static BitmapHeapScan * create_bitmap_scan_plan(PlannerInfo *root, BitmapHeapPath *best_path, List *tlist, List *scan_clauses)
static IncrementalSort * make_incrementalsort(Plan *lefttree, int numCols, int nPresortedCols, AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst)
static Result * create_group_result_plan(PlannerInfo *root, GroupResultPath *best_path)
static Limit * create_limit_plan(PlannerInfo *root, LimitPath *best_path, int flags)
static Unique * make_unique_from_pathkeys(Plan *lefttree, List *pathkeys, int numCols, Relids relids)
static Agg * create_agg_plan(PlannerInfo *root, AggPath *best_path)
bool is_projection_capable_path(Path *path)
static CteScan * make_ctescan(List *qptlist, List *qpqual, Index scanrelid, int ctePlanId, int cteParam)
static TidScan * create_tidscan_plan(PlannerInfo *root, TidPath *best_path, List *tlist, List *scan_clauses)
static TidRangeScan * make_tidrangescan(List *qptlist, List *qpqual, Index scanrelid, List *tidrangequals)
static Plan * create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, List **qual, List **indexqual, List **indexECs)
static Node * fix_indexqual_clause(PlannerInfo *root, IndexOptInfo *index, int indexcol, Node *clause, List *indexcolnos)
static WorkTableScan * create_worktablescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Plan * create_gating_plan(PlannerInfo *root, Path *path, Plan *plan, List *gating_quals)
static Memoize * make_memoize(Plan *lefttree, Oid *hashoperators, Oid *collations, List *param_exprs, bool singlerow, bool binary_mode, uint32 est_entries, Bitmapset *keyparamids, Cardinality est_calls, Cardinality est_unique_keys, double est_hit_ratio)
static FunctionScan * create_functionscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Result * create_resultscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static BitmapHeapScan * make_bitmap_heapscan(List *qptlist, List *qpqual, Plan *lefttree, List *bitmapqualorig, Index scanrelid)
static Node * replace_nestloop_params_mutator(Node *node, PlannerInfo *root)
static SetOp * create_setop_plan(PlannerInfo *root, SetOpPath *best_path, int flags)
bool is_projection_capable_plan(Plan *plan)
static CteScan * create_ctescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Sort * create_sort_plan(PlannerInfo *root, SortPath *best_path, int flags)
static ProjectSet * make_project_set(List *tlist, Plan *subplan)
static Sort * make_sort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids)
static HashJoin * make_hashjoin(List *tlist, List *joinclauses, List *otherclauses, List *hashclauses, List *hashoperators, List *hashcollations, List *hashkeys, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique)
static Gather * make_gather(List *qptlist, List *qpqual, int nworkers, int rescan_param, bool single_copy, Plan *subplan)
static Gather * create_gather_plan(PlannerInfo *root, GatherPath *best_path)
static Sort * make_sort(Plan *lefttree, int numCols, AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst)
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
static ProjectSet * create_project_set_plan(PlannerInfo *root, ProjectSetPath *best_path)
static void label_incrementalsort_with_costsize(PlannerInfo *root, IncrementalSort *plan, List *pathkeys, double limit_tuples)
ForeignScan * make_foreignscan(List *qptlist, List *qpqual, Index scanrelid, List *fdw_exprs, List *fdw_private, List *fdw_scan_tlist, List *fdw_recheck_quals, Plan *outer_plan)
static Group * create_group_plan(PlannerInfo *root, GroupPath *best_path)
static ModifyTable * create_modifytable_plan(PlannerInfo *root, ModifyTablePath *best_path)
static Result * create_minmaxagg_plan(PlannerInfo *root, MinMaxAggPath *best_path)
static LockRows * create_lockrows_plan(PlannerInfo *root, LockRowsPath *best_path, int flags)
static Material * create_material_plan(PlannerInfo *root, MaterialPath *best_path, int flags)
static List * get_gating_quals(PlannerInfo *root, List *quals)
static Plan * create_scan_plan(PlannerInfo *root, Path *best_path, int flags)
static Group * make_group(List *tlist, List *qual, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations, Plan *lefttree)
static LockRows * make_lockrows(Plan *lefttree, List *rowMarks, int epqParam)
static IncrementalSort * create_incrementalsort_plan(PlannerInfo *root, IncrementalSortPath *best_path, int flags)
static NamedTuplestoreScan * create_namedtuplestorescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Plan * create_projection_plan(PlannerInfo *root, ProjectionPath *best_path, int flags)
static RecursiveUnion * make_recursive_union(List *tlist, Plan *lefttree, Plan *righttree, int wtParam, List *distinctList, long numGroups)
static IndexOnlyScan * make_indexonlyscan(List *qptlist, List *qpqual, Index scanrelid, Oid indexid, List *indexqual, List *recheckqual, List *indexorderby, List *indextlist, ScanDirection indexscandir)
static List * build_path_tlist(PlannerInfo *root, Path *path)
static IndexScan * make_indexscan(List *qptlist, List *qpqual, Index scanrelid, Oid indexid, List *indexqual, List *indexqualorig, List *indexorderby, List *indexorderbyorig, List *indexorderbyops, ScanDirection indexscandir)
static FunctionScan * make_functionscan(List *qptlist, List *qpqual, Index scanrelid, List *functions, bool funcordinality)
static TableFuncScan * make_tablefuncscan(List *qptlist, List *qpqual, Index scanrelid, TableFunc *tablefunc)
static SubqueryScan * create_subqueryscan_plan(PlannerInfo *root, SubqueryScanPath *best_path, List *tlist, List *scan_clauses)
Agg * make_agg(List *tlist, List *qual, AggStrategy aggstrategy, AggSplit aggsplit, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations, List *groupingSets, List *chain, double dNumGroups, Size transitionSpace, Plan *lefttree)
static Plan * inject_projection_plan(Plan *subplan, List *tlist, bool parallel_safe)
static TidRangeScan * create_tidrangescan_plan(PlannerInfo *root, TidRangePath *best_path, List *tlist, List *scan_clauses)
static List * get_switched_clauses(List *clauses, Relids outerrelids)
static void copy_plan_costsize(Plan *dest, Plan *src)
static ValuesScan * make_valuesscan(List *qptlist, List *qpqual, Index scanrelid, List *values_lists)
Plan * materialize_finished_plan(Plan *subplan)
static SampleScan * make_samplescan(List *qptlist, List *qpqual, Index scanrelid, TableSampleClause *tsc)
static NestLoop * create_nestloop_plan(PlannerInfo *root, NestPath *best_path)
static Memoize * create_memoize_plan(PlannerInfo *root, MemoizePath *best_path, int flags)
static Result * make_gating_result(List *tlist, Node *resconstantqual, Plan *subplan)
static NamedTuplestoreScan * make_namedtuplestorescan(List *qptlist, List *qpqual, Index scanrelid, char *enrname)
static bool mark_async_capable_plan(Plan *plan, Path *path)
static Material * make_material(Plan *lefttree)
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
static NestLoop * make_nestloop(List *tlist, List *joinclauses, List *otherclauses, List *nestParams, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique)
static BitmapIndexScan * make_bitmap_indexscan(Index scanrelid, Oid indexid, List *indexqual, List *indexqualorig)
static SubqueryScan * make_subqueryscan(List *qptlist, List *qpqual, Index scanrelid, Plan *subplan)
static Hash * make_hash(Plan *lefttree, List *hashkeys, Oid skewTable, AttrNumber skewColumn, bool skewInherit)
static WindowAgg * create_windowagg_plan(PlannerInfo *root, WindowAggPath *best_path)
static Node * replace_nestloop_params(PlannerInfo *root, Node *expr)
static BitmapAnd * make_bitmap_and(List *bitmapplans)
static Plan * create_groupingsets_plan(PlannerInfo *root, GroupingSetsPath *best_path)
static RecursiveUnion * create_recursiveunion_plan(PlannerInfo *root, RecursiveUnionPath *best_path)
static Sort * make_sort_from_groupcols(List *groupcls, AttrNumber *grpColIdx, Plan *lefttree)
static Scan * create_indexscan_plan(PlannerInfo *root, IndexPath *best_path, List *tlist, List *scan_clauses, bool indexonly)
static 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 IncrementalSort * make_incrementalsort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids, int nPresortedCols)
static SampleScan * create_samplescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
Plan * create_plan(PlannerInfo *root, Path *best_path)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
bool is_redundant_with_indexclauses(RestrictInfo *rinfo, List *indexclauses)
EquivalenceMember * find_ec_member_matching_expr(EquivalenceClass *ec, Expr *expr, Relids relids)
EquivalenceMember * find_computable_ec_member(PlannerInfo *root, EquivalenceClass *ec, List *exprs, Relids relids, bool require_parallel_safe)
bool is_redundant_derived_clause(RestrictInfo *rinfo, List *clauselist)
#define CUSTOMPATH_SUPPORT_PROJECTION
FdwRoutine * GetFdwRoutineByRelId(Oid relid)
Assert(PointerIsAligned(start, uint64))
if(TABLE==NULL||TABLE_index==NULL)
List * list_difference(const List *list1, const List *list2)
List * lappend(List *list, void *datum)
List * list_difference_ptr(const List *list1, const List *list2)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lappend_oid(List *list, Oid datum)
bool list_member_ptr(const List *list, const void *datum)
bool list_member(const List *list, const void *datum)
List * list_copy_head(const List *oldlist, int len)
List * list_concat_unique(List *list1, const List *list2)
char * get_rel_name(Oid relid)
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Datum lca(PG_FUNCTION_ARGS)
Datum subpath(PG_FUNCTION_ARGS)
Expr * make_orclause(List *orclauses)
Expr * make_ands_explicit(List *andclauses)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Node * makeBoolConst(bool value, bool isnull)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
void * palloc0(Size size)
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
#define expression_tree_mutator(n, m, c)
static bool is_opclause(const void *clause)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
#define castNode(_type_, nodeptr)
void process_subquery_nestloop_params(PlannerInfo *root, List *subplan_params)
List * identify_current_nestloop_params(PlannerInfo *root, Relids leftrelids, Relids outerrelids)
Param * replace_nestloop_param_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
int assign_special_exec_param(PlannerInfo *root)
Param * replace_nestloop_param_var(PlannerInfo *root, Var *var)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
int make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, List *subpaths, List *prunequal)
bool pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
bool pathkeys_contained_in(List *keys1, List *keys2)
Path * reparameterize_path_by_child(PlannerInfo *root, Path *path, RelOptInfo *child_rel)
#define IS_DUMMY_APPEND(p)
#define PATH_REQ_OUTER(path)
#define planner_rt_fetch(rti, root)
#define IS_OTHER_REL(rel)
#define IS_UPPER_REL(rel)
int errdetail_relkind_not_supported(char relkind)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define for_each_from(cell, lst, N)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
static int list_nth_int(const List *list, int n)
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
bool has_stored_generated_columns(PlannerInfo *root, Index rti)
bool has_row_triggers(PlannerInfo *root, Index rti, CmdType event)
List * build_physical_tlist(PlannerInfo *root, RelOptInfo *rel)
bool has_transition_tables(PlannerInfo *root, Index rti, CmdType event)
List * infer_arbiter_indexes(PlannerInfo *root)
int restrict_nonsystem_relation_kind
bool predicate_implied_by(List *predicate_list, List *clause_list, bool weak)
List * extract_update_targetlist_colnos(List *tlist)
#define IS_SPECIAL_VARNO(varno)
static const struct fns functions
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
List * extract_actual_clauses(List *restrictinfo_list, bool pseudoconstant)
void extract_actual_join_clauses(List *restrictinfo_list, Relids joinrelids, List **joinquals, List **otherquals)
List * get_actual_clauses(List *restrictinfo_list)
bool trivial_subqueryscan(SubqueryScan *plan)
void check_stack_depth(void)
Selectivity bitmapselectivity
Selectivity bitmapselectivity
struct Plan *(* PlanCustomPath)(PlannerInfo *root, RelOptInfo *rel, struct CustomPath *best_path, List *tlist, List *clauses, List *custom_plans)
const struct CustomPathMethods * methods
Bitmapset * custom_relids
BeginDirectModify_function BeginDirectModify
PlanForeignModify_function PlanForeignModify
PlanDirectModify_function PlanDirectModify
IterateDirectModify_function IterateDirectModify
EndDirectModify_function EndDirectModify
IsForeignPathAsyncCapable_function IsForeignPathAsyncCapable
Bitmapset * fs_base_relids
Cardinality inner_rows_total
struct RestrictInfo * rinfo
ScanDirection indexorderdir
ScanDirection indexscandir
Selectivity indexselectivity
ScanDirection indexorderdir
Cardinality est_unique_keys
Cardinality est_unique_keys
List * withCheckOptionLists
List * mergeJoinConditions
OnConflictExpr * onconflict
List * mergeJoinConditions
Bitmapset * fdwDirectModifyPlans
List * withCheckOptionLists
OnConflictAction onConflictAction
struct TableSampleClause * tablesample
struct PathTarget * reltarget
struct TableSampleClause * tablesample
SubqueryScanStatus scanstatus
void SS_attach_initplans(PlannerInfo *root, Plan *plan)
void SS_compute_initplan_cost(List *init_plans, Cost *initplan_cost_p, bool *unsafe_initplans_p)
void SS_make_initplan_from_plan(PlannerInfo *root, PlannerInfo *subroot, Plan *plan, Param *prm)
#define FirstLowInvalidHeapAttributeNumber
#define RESTRICT_RELKIND_FOREIGN_TABLE
Oid * extract_grouping_ops(List *groupClause)
TargetEntry * tlist_member(Expr *node, List *targetlist)
bool tlist_same_exprs(List *tlist1, List *tlist2)
void apply_tlist_labeling(List *dest_tlist, List *src_tlist)
void apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target)
AttrNumber * extract_grouping_cols(List *groupClause, List *tlist)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
Oid * extract_grouping_collations(List *groupClause, List *tlist)
#define FirstNormalObjectId
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
bool contain_vars_returning_old_or_new(Node *node)