145 context.sublevels_up = levelsup;
172 var->varnullingrels);
180 if (
context->sublevels_up == 0)
220 if (phv->
phid <
context->root->placeholder_array_size)
221 phinfo =
context->root->placeholder_array[phv->
phid];
249 newevalat =
bms_join(newevalat, delta);
300 context.varattnos = *varattnos;
305 *varattnos =
context.varattnos;
345 context.sublevels_up = levelsup;
420 if (((
Var *) node)->varlevelsup == 0)
448 int sublevels_up = levelsup;
452 (
void *) &sublevels_up,
463 if (((
Var *) node)->varlevelsup == *sublevels_up)
469 if (*sublevels_up == 0)
487 (
void *) sublevels_up,
494 (
void *) sublevels_up);
519 context.sublevels_up = levelsup;
638 if (((
Var *) node)->varlevelsup != 0)
639 elog(
ERROR,
"Upper-level Var found where not expected");
645 if (((
Aggref *) node)->agglevelsup != 0)
646 elog(
ERROR,
"Upper-level Aggref found where not expected");
658 elog(
ERROR,
"Aggref found where not expected");
663 elog(
ERROR,
"Upper-level GROUPING found where not expected");
675 elog(
ERROR,
"GROUPING found where not expected");
691 elog(
ERROR,
"WindowFunc found where not expected");
696 elog(
ERROR,
"Upper-level PlaceHolderVar found where not expected");
708 elog(
ERROR,
"PlaceHolderVar found where not expected");
764 context.possible_sublink = query->hasSubLinks;
766 context.inserted_sublink = query->hasSubLinks;
799 forboth(lv, rte->joinaliasvars, ln, rte->eref->colnames)
811 if (
context->sublevels_up != 0)
819 fields =
lappend(fields, newvar);
824 rowexpr->
args = fields;
825 rowexpr->row_typeid = var->vartype;
828 rowexpr->colnames = colnames;
846 if (
context->sublevels_up != 0)
885 bool save_inserted_sublink;
888 save_inserted_sublink =
context->inserted_sublink;
889 context->inserted_sublink = ((
Query *) node)->hasSubLinks;
894 newnode->hasSubLinks |=
context->inserted_sublink;
895 context->inserted_sublink = save_inserted_sublink;
897 return (
Node *) newnode;
944 context.possible_sublink = query->hasSubLinks;
946 context.inserted_sublink = query->hasSubLinks;
980 if (
context->sublevels_up != 0)
999 if ((
int) agg->agglevelsup ==
context->sublevels_up)
1011 return (
Node *) agg;
1020 if ((
int) agg->agglevelsup >
context->sublevels_up)
1040 bool save_inserted_sublink;
1043 save_inserted_sublink =
context->inserted_sublink;
1044 context->inserted_sublink = ((
Query *) node)->hasSubLinks;
1049 newnode->hasSubLinks |=
context->inserted_sublink;
1050 context->inserted_sublink = save_inserted_sublink;
1052 return (
Node *) newnode;
1070 if (oldvar->varnullingrels == NULL)
1091 oldvar->varnullingrels);
1122 newnode = (
Node *) newphv;
1136 if (oldvar->varnullingrels == NULL)
1157 elog(
ERROR,
"unsupported join alias expression");
1167 newnode = (
Node *) newphv;
1172 elog(
ERROR,
"unsupported join alias expression");
1188 if (newnode == NULL)
1244 foreach(lc, cexpr->
args)
1265 Var *newvar = (
Var *) newnode;
1268 oldvar->varnullingrels);
1276 oldvar->varnullingrels);
1308 foreach(lc, cexpr->
args)
#define InvalidAttrNumber
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_make_singleton(int x)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_del_member(Bitmapset *a, int x)
Bitmapset * bms_copy(const Bitmapset *a)
#define Assert(condition)
bool contain_agg_clause(Node *clause)
bool contain_window_function(Node *clause)
bool contain_volatile_functions(Node *clause)
List * lappend(List *list, void *datum)
bool expression_returns_set(Node *clause)
#define expression_tree_mutator(n, m, c)
#define query_tree_walker(q, w, c, f)
#define query_or_expression_tree_walker(n, w, c, f)
#define QTW_IGNORE_GROUPEXPRS
#define expression_tree_walker(n, w, c)
#define query_tree_mutator(q, m, c, f)
#define QTW_IGNORE_JOINALIASES
#define IsA(nodeptr, _type_)
#define PVC_RECURSE_AGGREGATES
#define PVC_RECURSE_PLACEHOLDERS
#define PVC_RECURSE_WINDOWFUNCS
#define PVC_INCLUDE_WINDOWFUNCS
#define PVC_INCLUDE_PLACEHOLDERS
#define PVC_INCLUDE_AGGREGATES
#define rt_fetch(rangetable_index, rangetable)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
static void * list_nth(const List *list, int n)
PlaceHolderVar * make_placeholder_expr(PlannerInfo *root, Expr *expr, Relids phrels)
Relids get_relids_for_join(Query *query, int joinrelid)
Relids get_relids_in_jointree(Node *jtnode, bool include_outer_joins, bool include_inner_joins)
bool checkExprHasSubLink(Node *node)
Node * add_nulling_relids(Node *node, const Bitmapset *target_relids, const Bitmapset *added_relids)
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
#define FirstLowInvalidHeapAttributeNumber
static bool pull_varattnos_walker(Node *node, pull_varattnos_context *context)
List * pull_vars_of_level(Node *node, int levelsup)
static Node * add_nullingrels_if_needed(PlannerInfo *root, Node *newnode, Var *oldvar)
bool contain_vars_of_level(Node *node, int levelsup)
List * pull_var_clause(Node *node, int flags)
static Node * flatten_join_alias_vars_mutator(Node *node, flatten_join_alias_vars_context *context)
bool contain_var_clause(Node *node)
Relids pull_varnos_of_level(PlannerInfo *root, Node *node, int levelsup)
Relids pull_varnos(PlannerInfo *root, Node *node)
static bool pull_varnos_walker(Node *node, pull_varnos_context *context)
static bool pull_var_clause_walker(Node *node, pull_var_clause_context *context)
static Node * flatten_group_exprs_mutator(Node *node, flatten_join_alias_vars_context *context)
static Relids alias_relid_set(Query *query, Relids relids)
static bool contain_vars_of_level_walker(Node *node, int *sublevels_up)
static bool is_standard_join_alias_expression(Node *newnode, Var *oldvar)
static Node * mark_nullable_by_grouping(PlannerInfo *root, Node *newnode, Var *oldvar)
Node * flatten_join_alias_vars(PlannerInfo *root, Query *query, Node *node)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
static void adjust_standard_join_alias_expression(Node *newnode, Var *oldvar)
static bool locate_var_of_level_walker(Node *node, locate_var_of_level_context *context)
int locate_var_of_level(Node *node, int levelsup)
static bool contain_var_clause_walker(Node *node, void *context)
Node * flatten_group_exprs(PlannerInfo *root, Query *query, Node *node)
static bool pull_vars_walker(Node *node, pull_vars_context *context)