177 ((
Aggref *) node)->location >= 0)
348 List *src_rtable,
List *src_perminfos)
355 foreach(l, src_rtable)
359 if (rte->perminfoindex > 0)
360 rte->perminfoindex += offset;
364 *dst_perminfos =
list_concat(*dst_perminfos, src_perminfos);
365 *dst_rtable =
list_concat(*dst_rtable, src_rtable);
401 if (var->varnosyn > 0)
402 var->varnosyn += context->
offset;
500 if (sublevels_up == 0)
504 if (qry->resultRelation)
505 qry->resultRelation += offset;
507 if (qry->mergeTargetRelation)
508 qry->mergeTargetRelation += offset;
577 if (var->varnosyn == context->
rt_index)
644 bool clause_relids_is_multiple =
652 rinfo->clause_relids =
653 adjust_relid_set(rinfo->clause_relids, context->rt_index, context->new_index);
656 adjust_relid_set(rinfo->left_relids, context->rt_index, context->new_index);
657 rinfo->right_relids =
658 adjust_relid_set(rinfo->right_relids, context->rt_index, context->new_index);
672 if (rinfo->mergeopfamilies &&
674 clause_relids_is_multiple &&
690 if (leftOp != NULL &&
equal(leftOp, rightOp))
696 ntest->argisrow =
false;
699 rinfo->mergeopfamilies =
NIL;
700 rinfo->left_em = NULL;
701 rinfo->right_em = NULL;
703 Assert(rinfo->orclause == NULL);
752 int sublevels_up,
bool change_RangeTblRef)
765 if (sublevels_up == 0)
769 if (qry->resultRelation == rt_index)
770 qry->resultRelation = new_index;
772 if (qry->mergeTargetRelation == rt_index)
773 qry->mergeTargetRelation = new_index;
782 if (rc->
rti == rt_index)
865 elog(
ERROR,
"cannot push down CurrentOfExpr");
929 int min_sublevels_up)
952 int min_sublevels_up)
1144 *subquery_ptr = NULL;
1146 if (parsetree == NULL)
1165 elog(
ERROR,
"expected to find SELECT subquery");
1168 elog(
ERROR,
"expected to find SELECT subquery");
1174 elog(
ERROR,
"expected to find SELECT subquery");
1183 *subquery_ptr = &(selectrte->
subquery);
1186 elog(
ERROR,
"could not find rule placeholders");
1221 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1222 errmsg(
"conditional utility statements are not implemented")));
1233 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1234 errmsg(
"conditional UNION/INTERSECT/EXCEPT statements are not implemented")));
1252 if (!parsetree->hasSubLinks)
1322 var->varnullingrels = newnullingrels;
1323 return (
Node *) var;
1348 return (
Node *) phv;
1363 return (
Node *) newnode;
1409 return (
Node *) var;
1438 return (
Node *) phv;
1453 return (
Node *) newnode;
1485 bool *outer_hasSubLinks)
1501 else if (outer_hasSubLinks)
1518 ((
Query *) result)->hasSubLinks =
true;
1519 else if (outer_hasSubLinks)
1520 *outer_hasSubLinks =
true;
1522 elog(
ERROR,
"replace_rte_variables inserted a SubLink, but has noplace to record it");
1544 newnode = context->
callback(var, context);
1566 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1567 errmsg(
"WHERE CURRENT OF on a view is not implemented")));
1575 bool save_inserted_sublink;
1587 return (
Node *) newnode;
1650 elog(
ERROR,
"unexpected varattno %d in expression to be mapped",
1655 newvar->varattnosyn = newvar->
varattno;
1657 else if (attno == 0)
1669 Assert(var->vartype != RECORDOID);
1687 return (
Node *) newvar;
1719 Assert(var->vartype != RECORDOID);
1726 newnode->
arg = (
Expr *) newvar;
1728 return (
Node *) newnode;
1743 return (
Node *) newnode;
1750 int target_varno,
int sublevels_up,
1752 Oid to_rowtype,
bool *found_whole_row)
1762 *found_whole_row =
false;
1842 int result_relation,
1873 (var->vartype != RECORDOID),
1874 &colnames, &fields);
1878 rowexpr->row_typeid = var->vartype;
1880 rowexpr->colnames = (var->vartype == RECORDOID) ? colnames :
NIL;
1887 if (field &&
IsA(field,
Var))
1906 return (
Node *) rexpr;
1909 return (
Node *) rowexpr;
1915 if (tle == NULL || tle->resjunk)
1918 switch (nomatch_option)
1926 var->
varno = nomatch_varno;
1929 return (
Node *) var;
1948 elog(
ERROR,
"could not find replacement targetlist entry for attno %d",
1969 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1970 errmsg(
"NEW variables in ON UPDATE rules cannot reference columns that are part of a multiple assignment in the subject UPDATE command")));
1979 if (result_relation == 0)
1980 elog(
ERROR,
"variable returning old/new found outside RETURNING list");
1986 if (!
IsA(newnode,
Var) ||
1987 ((
Var *) newnode)->varno != result_relation ||
1988 ((
Var *) newnode)->varlevelsup != 0)
1996 newnode = (
Expr *) rexpr;
2000 return (
Node *) newnode;
2006 int target_varno,
int sublevels_up,
2009 int result_relation,
2012 bool *outer_hasSubLinks)
#define InvalidAttrNumber
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_del_member(Bitmapset *a, int x)
int bms_num_members(const 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)
BMS_Membership bms_membership(const Bitmapset *a)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
bool bms_get_singleton_member(const Bitmapset *a, int *member)
Bitmapset * bms_copy(const Bitmapset *a)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
Assert(PointerIsAligned(start, uint64))
if(TABLE==NULL||TABLE_index==NULL)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
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)
static Node * get_rightop(const void *clause)
#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
static Node * get_leftop(const void *clause)
#define IsA(nodeptr, _type_)
Node * coerce_null_to_domain(Oid typid, int32 typmod, Oid collation, int typlen, bool typbyval)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, VarReturningType returning_type, 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 bool SetVarReturningType_walker(Node *node, SetVarReturningType_context *context)
static Node * remove_nulling_relids_mutator(Node *node, remove_nulling_relids_context *context)
void ChangeVarNodesExtended(Node *node, int rt_index, int new_index, int sublevels_up, bool change_RangeTblRef)
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)
Node * replace_rte_variables_mutator(Node *node, replace_rte_variables_context *context)
static bool contain_windowfuncs_walker(Node *node, void *context)
Relids adjust_relid_set(Relids relids, int oldrelid, int newrelid)
static bool contains_multiexpr_param(Node *node, void *context)
void OffsetVarNodes(Node *node, int offset, int sublevels_up)
bool checkExprHasSubLink(Node *node)
static bool locate_windowfunc_walker(Node *node, locate_windowfunc_context *context)
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)
static Node * map_variable_attnos_mutator(Node *node, map_variable_attnos_context *context)
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)
Node * add_nulling_relids(Node *node, const Bitmapset *target_relids, const Bitmapset *added_relids)
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)
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
static Node * ReplaceVarsFromTargetList_callback(Var *var, replace_rte_variables_context *context)
int locate_windowfunc(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)
Node * remove_nulling_relids(Node *node, const Bitmapset *removable_relids, const Bitmapset *except_relids)
void AddInvertedQual(Query *parsetree, Node *qual)
static void SetVarReturningType(Node *node, int result_relation, int sublevels_up, VarReturningType returning_type)
static bool OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context)
Node * replace_rte_variables(Node *node, int target_varno, int sublevels_up, replace_rte_variables_callback callback, void *callback_arg, bool *outer_hasSubLinks)
Node * ReplaceVarFromTargetList(Var *var, RangeTblEntry *target_rte, List *targetlist, int result_relation, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno)
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 * ReplaceVarsFromTargetList(Node *node, int target_varno, int sublevels_up, RangeTblEntry *target_rte, List *targetlist, int result_relation, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno, bool *outer_hasSubLinks)
Node *(* replace_rte_variables_callback)(Var *var, replace_rte_variables_context *context)
@ REPLACEVARS_SUBSTITUTE_NULL
@ REPLACEVARS_CHANGE_VARNO
@ REPLACEVARS_REPORT_ERROR
BoolTestType booltesttype
NullTestType nulltesttype
OnConflictExpr * onConflict
ReplaceVarsNoMatchOption nomatch_option
RangeTblEntry * target_rte
Relids incompatible_relids
VarReturningType returning_type
VarReturningType varreturningtype
const Bitmapset * target_relids
const Bitmapset * added_relids
const AttrMap * attno_map
const Bitmapset * removable_relids
const Bitmapset * except_relids
replace_rte_variables_callback callback
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)