68 #define CP_EXACT_TLIST 0x0001
69 #define CP_SMALL_TLIST 0x0002
70 #define CP_LABEL_TLIST 0x0004
71 #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);
185 List *indexorderby,
List *indexorderbyorig,
186 List *indexorderbyops,
196 List *indexqualorig);
200 List *bitmapqualorig,
217 Index scanrelid,
int ctePlanId,
int cteParam);
219 Index scanrelid,
char *enrname);
221 Index scanrelid,
int wtParam);
231 List *joinclauses,
List *otherclauses,
List *nestParams,
233 JoinType jointype,
bool inner_unique);
235 List *joinclauses,
List *otherclauses,
237 List *hashoperators,
List *hashcollations,
240 JoinType jointype,
bool inner_unique);
247 List *joinclauses,
List *otherclauses,
250 Oid *mergecollations,
251 int *mergestrategies,
252 bool *mergenullsfirst,
254 JoinType jointype,
bool inner_unique,
255 bool skip_mark_restore);
258 Oid *collations,
bool *nullsFirst);
260 int numCols,
int nPresortedCols,
262 Oid *collations,
bool *nullsFirst);
266 bool adjust_tlist_in_place,
269 Oid **p_sortOperators,
271 bool **p_nullsFirst);
275 List *pathkeys,
Relids relids,
int nPresortedCols);
281 Oid *collations,
List *param_exprs,
282 bool singlerow,
bool binary_mode,
285 int partNumCols,
AttrNumber *partColIdx,
Oid *partOperators,
Oid *partCollations,
286 int ordNumCols,
AttrNumber *ordColIdx,
Oid *ordOperators,
Oid *ordCollations,
287 int frameOptions,
Node *startOffset,
Node *endOffset,
288 Oid startInRangeFunc,
Oid endInRangeFunc,
289 Oid inRangeColl,
bool inRangeAsc,
bool inRangeNullsFirst,
290 List *runCondition,
List *qual,
bool topWindow,
297 List *pathkeys,
int numCols);
299 int nworkers,
int rescan_param,
bool single_copy,
Plan *subplan);
307 CmdType operation,
bool canSetTag,
309 bool partColsUpdated,
310 List *resultRelations,
311 List *updateColnosLists,
312 List *withCheckOptionLists,
List *returningLists,
314 List *mergeActionList,
int epqParam);
370 elog(
ERROR,
"failed to assign all NestLoopParams to plan nodes");
543 elog(
ERROR,
"unrecognized node type: %d",
544 (
int) best_path->pathtype);
561 List *gating_clauses;
780 elog(
ERROR,
"unrecognized node type: %d",
954 if (expr &&
IsA(expr,
Var))
956 int attno = ((
Var *) expr)->varattno;
1031 (
Node *) gating_quals,
1063 List *gating_clauses;
1080 elog(
ERROR,
"unrecognized node type: %d",
1103 if (get_loc_restrictinfo(best_path) !=
NIL)
1104 set_qpqual((
Plan) plan,
1155 Assert(fdwroutine != NULL);
1200 bool tlist_was_changed =
false;
1204 int nasyncplans = 0;
1207 int nodenumsortkeys = 0;
1209 Oid *nodeSortOperators = NULL;
1210 Oid *nodeCollations = NULL;
1211 bool *nodeNullsFirst = NULL;
1212 bool consider_async =
false;
1256 if (pathkeys !=
NIL)
1282 foreach(subpaths, best_path->
subpaths)
1294 if (pathkeys !=
NIL)
1324 Assert(numsortkeys == nodenumsortkeys);
1325 if (memcmp(sortColIdx, nodeSortColIdx,
1327 elog(
ERROR,
"Append child's targetlist doesn't match Append");
1328 Assert(memcmp(sortOperators, nodeSortOperators,
1329 numsortkeys *
sizeof(
Oid)) == 0);
1330 Assert(memcmp(collations, nodeCollations,
1331 numsortkeys *
sizeof(
Oid)) == 0);
1332 Assert(memcmp(nullsFirst, nodeNullsFirst,
1333 numsortkeys *
sizeof(
bool)) == 0);
1339 sortColIdx, sortOperators,
1340 collations, nullsFirst);
1354 subplans =
lappend(subplans, subplan);
1379 if (prunequal !=
NIL)
1406 return (
Plan *) plan;
1424 bool tlist_was_changed;
1466 foreach(subpaths, best_path->
subpaths)
1500 elog(
ERROR,
"MergeAppend child's targetlist doesn't match MergeAppend");
1502 numsortkeys *
sizeof(
Oid)) == 0);
1504 numsortkeys *
sizeof(
Oid)) == 0);
1506 numsortkeys *
sizeof(
bool)) == 0);
1512 sortColIdx, sortOperators,
1513 collations, nullsFirst);
1519 subplans =
lappend(subplans, subplan);
1544 if (prunequal !=
NIL)
1675 operators =
palloc(nkeys *
sizeof(
Oid));
1676 collations =
palloc(nkeys *
sizeof(
Oid));
1684 operators[
i] = opno;
1691 plan =
make_memoize(subplan, operators, collations, param_exprs,
1719 Oid *groupCollations;
1754 foreach(l, uniq_exprs)
1766 newtlist =
lappend(newtlist, tle);
1786 groupCollations = (
Oid *)
palloc(numGroupCols *
sizeof(
Oid));
1789 foreach(l, uniq_exprs)
1796 elog(
ERROR,
"failed to find unique expression in subplan tlist");
1797 groupColIdx[groupColPos] = tle->
resno;
1804 Oid *groupOperators;
1812 groupOperators = (
Oid *)
palloc(numGroupCols *
sizeof(
Oid));
1814 foreach(l, in_operators)
1820 elog(
ERROR,
"could not find compatible hash operator for operator %u",
1822 groupOperators[groupColPos++] = eq_oper;
1851 foreach(l, in_operators)
1861 elog(
ERROR,
"could not find ordering operator for equality operator %u",
1872 elog(
ERROR,
"could not find equality operator for ordering operator %u",
1876 groupColIdx[groupColPos]);
1882 sortcl->
eqop = eqop;
1886 sortList =
lappend(sortList, sortcl);
1987 elog(
ERROR,
"gather merge input not sufficiently sorted");
2011 bool needs_result_node =
false;
2071 if (!needs_result_node)
2151 tlist_parallel_safe);
2354 foreach(lc, groupClause)
2361 return new_grpColIdx;
2447 Plan *sort_plan = NULL;
2453 if (!rollup->
is_hashed && !is_first_sort)
2455 sort_plan = (
Plan *)
2462 is_first_sort =
false;
2494 chain =
lappend(chain, agg_plan);
2528 return (
Plan *) plan;
2564 0, NULL, NULL, NULL);
2615 Oid *partCollations;
2644 partCollations = (
Oid *)
palloc(
sizeof(
Oid) * numPart);
2653 partColIdx[partNumCols] = tle->
resno;
2654 partOperators[partNumCols] = sgc->
eqop;
2661 ordCollations = (
Oid *)
palloc(
sizeof(
Oid) * numOrder);
2670 ordColIdx[ordNumCols] = tle->
resno;
2671 ordOperators[ordNumCols] = sgc->
eqop;
2851 int numUniqkeys = 0;
2853 Oid *uniqOperators = NULL;
2854 Oid *uniqCollations = NULL;
2867 uniqOperators = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2868 uniqCollations = (
Oid *)
palloc(numUniqkeys *
sizeof(
Oid));
2871 foreach(l,
parse->sortClause)
2876 uniqColIdx[numUniqkeys] = tle->
resno;
2877 uniqOperators[numUniqkeys] = sortcl->
eqop;
2887 numUniqkeys, uniqColIdx, uniqOperators, uniqCollations);
2927 scan_clauses = (
List *)
2970 scan_clauses = (
List *)
3010 List *stripped_indexquals;
3011 List *fixed_indexquals;
3012 List *fixed_indexorderbys;
3027 &stripped_indexquals,
3064 foreach(l, scan_clauses)
3076 qpqual =
lappend(qpqual, rinfo);
3096 stripped_indexquals = (
List *)
3100 indexorderbys = (
List *)
3132 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
3134 indexorderbyops =
lappend_oid(indexorderbyops, sortop);
3163 stripped_indexquals,
3164 fixed_indexorderbys,
3173 stripped_indexquals,
3174 fixed_indexorderbys,
3196 Plan *bitmapqualplan;
3197 List *bitmapqualorig;
3210 &bitmapqualorig, &indexquals,
3243 foreach(l, scan_clauses)
3257 qpqual =
lappend(qpqual, rinfo);
3283 bitmapqualorig = (
List *)
3349 &subqual, &subindexqual,
3351 subplans =
lappend(subplans, subplan);
3355 subindexECs =
list_concat(subindexECs, subindexEC);
3366 *indexqual = subindexquals;
3367 *indexECs = subindexECs;
3375 bool const_true_subqual =
false;
3376 bool const_true_subindexqual =
false;
3396 &subqual, &subindexqual,
3398 subplans =
lappend(subplans, subplan);
3400 const_true_subqual =
true;
3401 else if (!const_true_subqual)
3404 if (subindexqual ==
NIL)
3405 const_true_subindexqual =
true;
3406 else if (!const_true_subindexqual)
3407 subindexquals =
lappend(subindexquals,
3436 if (const_true_subqual)
3442 if (const_true_subindexqual)
3445 *indexqual = subindexquals;
3455 List *subindexquals;
3478 subindexquals =
NIL;
3505 subquals =
lappend(subquals, pred);
3506 subindexquals =
lappend(subindexquals, pred);
3510 *indexqual = subindexquals;
3511 *indexECs = subindexECs;
3563 foreach(l, scan_clauses)
3573 qpqual =
lappend(qpqual, rinfo);
3575 scan_clauses = qpqual;
3605 scan_clauses = (
List *)
3645 foreach(l, scan_clauses)
3653 qpqual =
lappend(qpqual, rinfo);
3655 scan_clauses = qpqual;
3668 tidrangequals = (
List *)
3670 scan_clauses = (
List *)
3718 scan_clauses = (
List *)
3763 scan_clauses = (
List *)
3806 scan_clauses = (
List *)
3849 scan_clauses = (
List *)
3852 values_lists = (
List *)
3894 while (levelsup-- > 0)
3925 if (ctesplan->
plan_id == plan_id)
3946 scan_clauses = (
List *)
3950 scan_plan =
make_ctescan(tlist, scan_clauses, scan_relid,
3951 plan_id, cte_param_id);
3985 scan_clauses = (
List *)
4024 scan_clauses = (
List *)
4065 while (levelsup-- > 0)
4083 scan_clauses = (
List *)
4108 Plan *outer_plan = NULL;
4128 rel_oid = rte->
relid;
4146 tlist, scan_clauses,
4259 custom_plans =
lappend(custom_plans, plan);
4352 &joinclauses, &otherclauses);
4364 joinclauses = (
List *)
4366 otherclauses = (
List *)
4402 List *outerpathkeys;
4403 List *innerpathkeys;
4406 Oid *mergecollations;
4407 int *mergestrategies;
4408 bool *mergenullsfirst;
4440 &joinclauses, &otherclauses);
4462 joinclauses = (
List *)
4464 otherclauses = (
List *)
4523 inner_plan = matplan;
4535 mergefamilies = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4536 mergecollations = (
Oid *)
palloc(nClauses *
sizeof(
Oid));
4537 mergestrategies = (
int *)
palloc(nClauses *
sizeof(
int));
4538 mergenullsfirst = (
bool *)
palloc(nClauses *
sizeof(
bool));
4552 bool first_inner_match =
false;
4583 if (oeclass != opeclass)
4587 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4590 lop =
lnext(outerpathkeys, lop);
4591 if (oeclass != opeclass)
4592 elog(
ERROR,
"outer pathkeys do not match mergeclauses");
4614 if (ieclass == ipeclass)
4617 lip =
lnext(innerpathkeys, lip);
4618 first_inner_match =
true;
4621 if (!first_inner_match)
4626 foreach(l2, innerpathkeys)
4632 if (ieclass == ipeclass)
4635 if (ieclass != ipeclass)
4636 elog(
ERROR,
"inner pathkeys do not match mergeclauses");
4655 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4656 if (first_inner_match &&
4659 elog(
ERROR,
"left and right pathkeys do not match in mergejoin");
4716 bool skewInherit =
false;
4742 &joinclauses, &otherclauses);
4764 joinclauses = (
List *)
4766 otherclauses = (
List *)
4802 skewTable = rte->
relid;
4804 skewInherit = rte->
inh;
4817 foreach(lc, hashclauses)
4949 return (
Node *) newphv;
4981 List **stripped_indexquals_p,
List **fixed_indexquals_p)
4984 List *stripped_indexquals;
4985 List *fixed_indexquals;
4988 stripped_indexquals = fixed_indexquals =
NIL;
5001 stripped_indexquals =
lappend(stripped_indexquals, clause);
5004 fixed_indexquals =
lappend(fixed_indexquals, clause);
5008 *stripped_indexquals_p = stripped_indexquals;
5009 *fixed_indexquals_p = fixed_indexquals;
5024 List *fixed_indexorderbys;
5028 fixed_indexorderbys =
NIL;
5036 fixed_indexorderbys =
lappend(fixed_indexorderbys, clause);
5039 return fixed_indexorderbys;
5104 elog(
ERROR,
"unsupported indexqual type: %d",
5133 Assert(indexcol >= 0 && indexcol < index->ncolumns);
5135 if (
index->indexkeys[indexcol] != 0)
5139 ((
Var *) node)->varno ==
index->rel->relid &&
5140 ((
Var *) node)->varattno ==
index->indexkeys[indexcol])
5145 return (
Node *) result;
5148 elog(
ERROR,
"index key does not match expected index column");
5153 for (pos = 0; pos <
index->ncolumns; pos++)
5155 if (
index->indexkeys[pos] == 0)
5157 if (indexpr_item == NULL)
5158 elog(
ERROR,
"too few entries in indexprs list");
5159 if (pos == indexcol)
5166 if (
equal(node, indexkey))
5172 return (
Node *) result;
5175 elog(
ERROR,
"index key does not match expected index column");
5177 indexpr_item =
lnext(
index->indexprs, indexpr_item);
5182 elog(
ERROR,
"index key does not match expected index column");
5226 t_list =
lappend(t_list, temp);
5232 t_list =
lappend(t_list, clause);
5279 Index security_level;
5295 items = (QualItem *)
palloc(nitems *
sizeof(QualItem));
5297 foreach(lc, clauses)
5303 items[
i].clause = clause;
5320 items[
i].security_level = 0;
5325 items[
i].security_level = 0;
5334 for (
i = 1;
i < nitems;
i++)
5336 QualItem newitem = items[
i];
5340 for (
j =
i;
j > 0;
j--)
5342 QualItem *olditem = &items[
j - 1];
5344 if (newitem.security_level > olditem->security_level ||
5345 (newitem.security_level == olditem->security_level &&
5346 newitem.cost >= olditem->cost))
5348 items[
j] = *olditem;
5355 for (
i = 0;
i < nitems;
i++)
5356 result =
lappend(result, items[
i].clause);
5389 dest->parallel_aware =
false;
5442 ((
BitmapOr *) plan)->isshared =
true;
5474 plan->
qual = qpqual;
5492 plan->
qual = qpqual;
5507 List *indexqualorig,
5509 List *indexorderbyorig,
5510 List *indexorderbyops,
5517 plan->
qual = qpqual;
5547 plan->
qual = qpqual;