89 context.sublevels_up = levelsup;
154 context.sublevels_up = levelsup;
176 if (((
Aggref *) node)->agglevelsup ==
context->sublevels_up &&
177 ((
Aggref *) node)->location >= 0)
351 List *src_rtable,
List *src_perminfos)
358 foreach(l, src_rtable)
362 if (rte->perminfoindex > 0)
363 rte->perminfoindex += offset;
367 *dst_perminfos =
list_concat(*dst_perminfos, src_perminfos);
368 *dst_rtable =
list_concat(*dst_rtable, src_rtable);
404 if (var->varnosyn > 0)
405 var->varnosyn +=
context->offset;
413 if (
context->sublevels_up == 0)
421 if (
context->sublevels_up == 0)
430 if (
j->rtindex &&
context->sublevels_up == 0)
451 if (
context->sublevels_up == 0)
485 context.sublevels_up = sublevels_up;
504 if (sublevels_up == 0)
508 if (qry->resultRelation)
509 qry->resultRelation += offset;
511 if (qry->mergeTargetRelation)
512 qry->mergeTargetRelation += offset;
579 if (var->varnosyn ==
context->rt_index)
580 var->varnosyn =
context->new_index;
588 if (
context->sublevels_up == 0 &&
597 if (
context->sublevels_up == 0 &&
607 if (
context->sublevels_up == 0 &&
631 if (
context->sublevels_up == 0)
644 if (
context->sublevels_up == 0)
680 context.sublevels_up = sublevels_up;
699 if (sublevels_up == 0)
703 if (qry->resultRelation == rt_index)
704 qry->resultRelation = new_index;
706 if (qry->mergeTargetRelation == rt_index)
707 qry->mergeTargetRelation = new_index;
717 if (rc->
rti == rt_index)
792 if (
context->min_sublevels_up == 0)
793 elog(
ERROR,
"cannot push down CurrentOfExpr");
800 if (agg->agglevelsup >=
context->min_sublevels_up)
801 agg->agglevelsup +=
context->delta_sublevels_up;
850 int min_sublevels_up)
854 context.delta_sublevels_up = delta_sublevels_up;
855 context.min_sublevels_up = min_sublevels_up;
873 int min_sublevels_up)
877 context.delta_sublevels_up = delta_sublevels_up;
878 context.min_sublevels_up = min_sublevels_up;
918 if (
context->sublevels_up == 0 &&
937 if (
j->rtindex ==
context->rt_index &&
971 context.sublevels_up = sublevels_up;
1005 *subquery_ptr = NULL;
1007 if (parsetree == NULL)
1026 elog(
ERROR,
"expected to find SELECT subquery");
1029 elog(
ERROR,
"expected to find SELECT subquery");
1035 elog(
ERROR,
"expected to find SELECT subquery");
1044 *subquery_ptr = &(selectrte->
subquery);
1047 elog(
ERROR,
"could not find rule placeholders");
1082 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1083 errmsg(
"conditional utility statements are not implemented")));
1094 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1095 errmsg(
"conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
1113 if (!parsetree->hasSubLinks)
1154 context.target_relids = target_relids;
1155 context.added_relids = added_relids;
1174 (
context->target_relids == NULL ||
1183 var->varnullingrels = newnullingrels;
1184 return (
Node *) var;
1193 (
context->target_relids == NULL ||
1209 return (
Node *) phv;
1224 return (
Node *) newnode;
1243 context.removable_relids = removable_relids;
1244 context.except_relids = except_relids;
1271 return (
Node *) var;
1300 return (
Node *) phv;
1315 return (
Node *) newnode;
1348 bool *outer_hasSubLinks)
1354 context.callback_arg = callback_arg;
1355 context.target_varno = target_varno;
1356 context.sublevels_up = sublevels_up;
1363 context.inserted_sublink = ((
Query *) node)->hasSubLinks;
1364 else if (outer_hasSubLinks)
1365 context.inserted_sublink = *outer_hasSubLinks;
1367 context.inserted_sublink =
false;
1381 ((
Query *) result)->hasSubLinks =
true;
1382 else if (outer_hasSubLinks)
1383 *outer_hasSubLinks =
true;
1385 elog(
ERROR,
"replace_rte_variables inserted a SubLink, but has noplace to record it");
1409 if (!
context->inserted_sublink)
1429 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1430 errmsg(
"WHERE CURRENT OF on a view is not implemented")));
1438 bool save_inserted_sublink;
1441 save_inserted_sublink =
context->inserted_sublink;
1442 context->inserted_sublink = ((
Query *) node)->hasSubLinks;
1447 newnode->hasSubLinks |=
context->inserted_sublink;
1448 context->inserted_sublink = save_inserted_sublink;
1450 return (
Node *) newnode;
1512 if (attno >
context->attno_map->maplen ||
1513 context->attno_map->attnums[attno - 1] == 0)
1514 elog(
ERROR,
"unexpected varattno %d in expression to be mapped",
1518 if (newvar->varnosyn ==
context->target_varno)
1519 newvar->varattnosyn = newvar->
varattno;
1521 else if (attno == 0)
1524 *(
context->found_whole_row) =
true;
1528 context->to_rowtype != var->vartype)
1533 Assert(var->vartype != RECORDOID);
1536 newvar->vartype =
context->to_rowtype;
1551 return (
Node *) newvar;
1572 context->to_rowtype != var->vartype)
1578 *(
context->found_whole_row) =
true;
1583 Assert(var->vartype != RECORDOID);
1586 newvar->vartype =
context->to_rowtype;
1590 newnode->
arg = (
Expr *) newvar;
1592 return (
Node *) newnode;
1607 return (
Node *) newnode;
1615 int target_varno,
int sublevels_up,
1617 Oid to_rowtype,
bool *found_whole_row)
1621 context.target_varno = target_varno;
1622 context.sublevels_up = sublevels_up;
1623 context.attno_map = attno_map;
1624 context.to_rowtype = to_rowtype;
1625 context.found_whole_row = found_whole_row;
1627 *found_whole_row =
false;
1690 (var->vartype != RECORDOID),
1691 &colnames, &fields);
1696 rowexpr->
args = fields;
1697 rowexpr->row_typeid = var->vartype;
1699 rowexpr->colnames = (var->vartype == RECORDOID) ? colnames :
NIL;
1702 return (
Node *) rowexpr;
1708 if (tle == NULL || tle->resjunk)
1721 return (
Node *) var;
1739 elog(
ERROR,
"could not find replacement targetlist entry for attno %d",
1764 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1765 errmsg(
"NEW variables in ON UPDATE rules cannot reference columns that are part of a multiple assignment in the subject UPDATE command")));
1767 return (
Node *) newnode;
1773 int target_varno,
int sublevels_up,
1778 bool *outer_hasSubLinks)
1782 context.target_rte = target_rte;
1783 context.targetlist = targetlist;
1784 context.nomatch_option = nomatch_option;
1785 context.nomatch_varno = nomatch_varno;
#define InvalidAttrNumber
int bms_next_member(const Bitmapset *a, int prevbit)
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)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
#define Assert(condition)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
if(TABLE==NULL||TABLE_index==NULL)
List * list_concat(List *list1, const List *list2)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Node * make_and_qual(Node *qual1, Node *qual2)
#define expression_tree_mutator(n, m, c)
#define query_or_expression_tree_mutator(n, m, c, f)
#define range_table_walker(rt, w, c, f)
#define query_tree_walker(q, w, c, f)
#define query_or_expression_tree_walker(n, w, c, f)
#define expression_tree_walker(n, w, c)
#define query_tree_mutator(q, m, c, f)
#define QTW_IGNORE_RC_SUBQUERIES
#define QTW_EXAMINE_RTES_BEFORE
#define IsA(nodeptr, _type_)
Node * coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod, Oid typeId, CoercionContext ccontext, CoercionForm cformat, int location, bool hideInputCoercion)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
#define rt_fetch(rangetable_index, rangetable)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define IS_SPECIAL_VARNO(varno)
bool contain_windowfuncs(Node *node)
static Node * remove_nulling_relids_mutator(Node *node, remove_nulling_relids_context *context)
Node * ReplaceVarsFromTargetList(Node *node, int target_varno, int sublevels_up, RangeTblEntry *target_rte, List *targetlist, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno, bool *outer_hasSubLinks)
void IncrementVarSublevelsUp_rtable(List *rtable, int delta_sublevels_up, int min_sublevels_up)
void ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up)
static bool contain_windowfuncs_walker(Node *node, void *context)
static Relids adjust_relid_set(Relids relids, int oldrelid, int newrelid)
Node * replace_rte_variables_mutator(Node *node, replace_rte_variables_context *context)
static bool contains_multiexpr_param(Node *node, void *context)
void OffsetVarNodes(Node *node, int offset, int sublevels_up)
bool checkExprHasSubLink(Node *node)
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
static bool locate_windowfunc_walker(Node *node, locate_windowfunc_context *context)
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
void CombineRangeTables(List **dst_rtable, List **dst_perminfos, List *src_rtable, List *src_perminfos)
static bool rangeTableEntry_used_walker(Node *node, rangeTableEntry_used_context *context)
void AddQual(Query *parsetree, Node *qual)
Node * remove_nulling_relids(Node *node, const Bitmapset *removable_relids, const Bitmapset *except_relids)
Node * replace_rte_variables(Node *node, int target_varno, int sublevels_up, replace_rte_variables_callback callback, void *callback_arg, bool *outer_hasSubLinks)
int locate_agg_of_level(Node *node, int levelsup)
static bool checkExprHasSubLink_walker(Node *node, void *context)
static bool IncrementVarSublevelsUp_walker(Node *node, IncrementVarSublevelsUp_context *context)
static bool ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context)
static bool locate_agg_of_level_walker(Node *node, locate_agg_of_level_context *context)
bool rangeTableEntry_used(Node *node, int rt_index, int sublevels_up)
static bool contain_aggs_of_level_walker(Node *node, contain_aggs_of_level_context *context)
bool contain_aggs_of_level(Node *node, int levelsup)
int locate_windowfunc(Node *node)
void AddInvertedQual(Query *parsetree, Node *qual)
static bool OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context)
Node * add_nulling_relids(Node *node, const Bitmapset *target_relids, const Bitmapset *added_relids)
static Node * ReplaceVarsFromTargetList_callback(Var *var, replace_rte_variables_context *context)
static Node * map_variable_attnos_mutator(Node *node, map_variable_attnos_context *context)
static Node * add_nulling_relids_mutator(Node *node, add_nulling_relids_context *context)
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
static Relids offset_relid_set(Relids relids, int offset)
Node *(* replace_rte_variables_callback)(Var *var, replace_rte_variables_context *context)
@ REPLACEVARS_SUBSTITUTE_NULL
@ REPLACEVARS_CHANGE_VARNO
@ REPLACEVARS_REPORT_ERROR
BoolTestType booltesttype
OnConflictExpr * onConflict
ReplaceVarsNoMatchOption nomatch_option
RangeTblEntry * target_rte
const Bitmapset * target_relids
const Bitmapset * added_relids
const AttrMap * attno_map
const Bitmapset * removable_relids
const Bitmapset * except_relids
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)