163 int rtindex,
Relids relids);
171 Node *node,
int varno);
173 int varno,
Relids subrelids);
269 rtr->rtindex =
parse->mergeTargetRelation;
286 elog(
ERROR,
"unrecognized source node type: %d",
335 parse->mergeJoinCondition =
347 action->targetList = (
List *)
388 ntest->argisrow =
false;
392 parse->mergeJoinCondition =
425 for (rt_index = 0; rt_index < rtable_size; rt_index++)
450 rte->inh = relation->
rd_rel->relhassubclass;
501 for (
int i = 0;
i < tupdesc->
natts;
i++)
562 if (
parse->groupingSets)
596 if (
parse->jointree->fromlist !=
NIL)
600 if (
parse->setOperations)
791 elog(
ERROR,
"unrecognized join type: %d",
810 elog(
ERROR,
"unrecognized node type: %d",
856 return (
Node *) saop;
1040 foreach(l, ((
BoolExpr *) node)->args)
1099 foreach(
rt,
root->parse->rtable)
1118 rte->security_barrier =
false;
1127 rte->funcordinality =
false;
1270 switch (
j->jointype)
1307 elog(
ERROR,
"unrecognized join type: %d",
1313 elog(
ERROR,
"unrecognized node type: %d",
1358 subroot->
parse = subquery;
1362 subroot->parent_root =
root->parent_root;
1378 memset(subroot->upper_rels, 0,
sizeof(subroot->upper_rels));
1379 memset(subroot->upper_targets, 0,
sizeof(subroot->upper_targets));
1384 subroot->grouping_map =
NULL;
1417 if (subquery->hasSubLinks)
1532 if (
parse->groupingSets)
1585 subquery->
rtable, subquery->rteperminfos);
1604 if (
root->glob->lastPHId != 0 ||
root->append_rel_list)
1610 if (
root->glob->lastPHId != 0)
1647 parse->hasSubLinks |= subquery->hasSubLinks;
1650 parse->hasRowSecurity |= subquery->hasRowSecurity;
1725 rtable, subquery->rteperminfos);
1819 elog(
ERROR,
"unrecognized node type: %d",
1899 if (subquery->hasAggs ||
1900 subquery->hasWindowFuncs ||
1901 subquery->hasTargetSRFs ||
1909 subquery->hasForUpdate ||
1918 if (
rte->security_barrier)
2179 if (
rte->funcordinality)
2194 if (
rtf->funccolcount != 1)
2198 if (
rtf->funccolnames !=
NIL)
2237 if (
parse->groupingSets)
2262 rte->lateral =
false;
2338 elog(
ERROR,
"unrecognized node type: %d",
2460 elog(
ERROR,
"unrecognized node type: %d",
2513 if (
parse->onConflict)
2515 parse->onConflict->onConflictSet = (
List *)
2518 parse->onConflict->onConflictWhere =
2527 if (
parse->mergeActionList)
2529 foreach(
lc,
parse->mergeActionList)
2534 action->targetList = (
List *)
2547 foreach(
lc,
root->append_rel_list)
2596 if (varno != context->
varno)
2603 switch (
rte->rtekind)
2676 elog(
ERROR,
"unrecognized node type: %d",
2748 rcon->result_relation,
2784 if (
rcon->target_rte->lateral &&
2801 if (
rcon->target_rte->lateral &&
2865 if (!
rcon->target_rte->lateral)
2928 if (var->varnullingrels !=
NULL)
2936 var->varnullingrels);
2944 var->varnullingrels);
2967 if (
rcon->target_rte->lateral)
2998 var->varnullingrels);
3063 if (
root->hasRecursion)
3185 elog(
ERROR,
"so where are the outer joins?");
3217 foreach(
lc,
state2.partial_reduced)
3294 elog(
ERROR,
"unrecognized node type: %d",
3364 int rtindex =
j->rtindex;
3417 elog(
ERROR,
"unrecognized join type: %d",
3473 if (rtindex && jointype !=
j->jointype)
3479 rte->jointype = jointype;
3484 j->jointype = jointype;
3584 elog(
ERROR,
"unrecognized node type: %d",
3591 int rtindex,
Relids relids)
3596 statep->full_join_rti = rtindex;
3597 statep->unreduced_side = relids;
3708 foreach(cell,
root->rowMarks)
3811 f !=
root->parse->jointree &&
3857 switch (
j->jointype)
3887 if (
j->quals !=
NULL)
3903 if (
j->quals !=
NULL)
3932 (
j->quals ==
NULL ||
3972 if (
j->quals !=
NULL)
3986 elog(
ERROR,
"unrecognized join type: %d",
3992 elog(
ERROR,
"unrecognized node type: %d",
4037 if (
root->glob->lastPHId != 0)
4112 if (
root->glob->lastPHId == 0)
4136 if (
root->glob->lastPHId == 0)
4237 context.
varno = varno;
4272 foreach(l,
root->append_rel_list)
4279 if (
appinfo->child_relid == varno)
4287 if (
root->glob->lastPHId != 0)
4357 elog(
ERROR,
"unrecognized node type: %d",
4410 if (relid ==
j->rtindex)
4420 elog(
ERROR,
"unrecognized node type: %d",
4479 switch (
j->jointype)
4506 elog(
ERROR,
"unrecognized join type: %d",
4512 elog(
ERROR,
"unrecognized node type: %d",
#define InvalidAttrNumber
Bitmapset * bms_make_singleton(int x)
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_del_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
int bms_singleton_member(const Bitmapset *a)
void bms_free(Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
#define Assert(condition)
List * find_forced_null_vars(Node *node)
Query * inline_function_in_from(PlannerInfo *root, RangeTblEntry *rte)
Node * eval_const_expressions(PlannerInfo *root, Node *node)
List * find_nonnullable_vars(Node *clause)
Relids find_nonnullable_rels(Node *clause)
bool contain_nonstrict_functions(Node *clause)
bool contain_volatile_functions(Node *clause)
#define palloc_object(type)
#define palloc0_array(type, count)
TypeFuncClass get_expr_result_type(Node *expr, Oid *resultTypeId, TupleDesc *resultTupleDesc)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
Alias * makeAlias(const char *aliasname, List *colnames)
Var * makeVarFromTargetEntry(int varno, TargetEntry *tle)
FromExpr * makeFromExpr(List *fromlist, Node *quals)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Var * makeWholeRowVar(RangeTblEntry *rte, int varno, Index varlevelsup, bool allowScalar)
Expr * make_andclause(List *andclauses)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Node * make_and_qual(Node *qual1, Node *qual2)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define CHECK_FOR_INTERRUPTS()
List * mbms_add_members(List *a, const List *b)
Bitmapset * mbms_overlap_sets(const List *a, const List *b)
bool expression_returns_set(Node *clause)
static bool is_andclause(const void *clause)
#define query_tree_walker(q, w, c, f)
#define query_or_expression_tree_walker(n, w, c, f)
#define range_table_entry_walker(r, w, c, f)
#define expression_tree_walker(n, w, c)
static bool is_notclause(const void *clause)
static Expr * get_notclausearg(const void *notclause)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
#define castNode(_type_, nodeptr)
#define rt_fetch(rangetable_index, rangetable)
FormData_pg_attribute * Form_pg_attribute
static int list_length(const List *l)
#define linitial_node(type, l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_delete_current(lst, var_or_cell)
#define foreach_node(type, var, lst)
static rewind_source * source
PlaceHolderVar * make_placeholder_expr(PlannerInfo *root, Expr *expr, Relids phrels)
void get_relation_notnullatts(PlannerInfo *root, Relation relation)
static Node * pull_up_subqueries_recurse(PlannerInfo *root, Node *jtnode, JoinExpr *lowest_outer_join, AppendRelInfo *containing_appendrel)
static nullingrel_info * get_nullingrels(Query *parse)
static void remove_result_refs(PlannerInfo *root, int varno, Node *newjtloc)
static Node * pull_up_constant_function(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, AppendRelInfo *containing_appendrel)
void preprocess_function_rtes(PlannerInfo *root)
static bool find_dependent_phvs_walker(Node *node, find_dependent_phvs_context *context)
static Node * find_jointree_node_for_rel(Node *jtnode, int relid)
static Node * pull_up_simple_union_all(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte)
static void reduce_outer_joins_pass2(Node *jtnode, reduce_outer_joins_pass1_state *state1, reduce_outer_joins_pass2_state *state2, PlannerInfo *root, Relids nonnullable_rels, List *forced_null_vars)
static void pull_up_union_leaf_queries(Node *setOp, PlannerInfo *root, int parentRTindex, Query *setOpQuery, int childRToffset)
static bool is_simple_values(PlannerInfo *root, RangeTblEntry *rte)
static void make_setop_translation_list(Query *query, int newvarno, AppendRelInfo *appinfo)
void flatten_simple_union_all(PlannerInfo *root)
void transform_MERGE_to_join(Query *parse)
static void report_reduced_full_join(reduce_outer_joins_pass2_state *state2, int rtindex, Relids relids)
static void perform_pullup_replace_vars(PlannerInfo *root, pullup_replace_vars_context *rvcontext, AppendRelInfo *containing_appendrel)
void remove_useless_result_rtes(PlannerInfo *root)
static Node * pull_up_sublinks_jointree_recurse(PlannerInfo *root, Node *jtnode, Relids *relids)
static void get_nullingrels_recurse(Node *jtnode, Relids upper_nullingrels, nullingrel_info *info)
static reduce_outer_joins_pass1_state * reduce_outer_joins_pass1(Node *jtnode)
static void replace_vars_in_jointree(Node *jtnode, pullup_replace_vars_context *context)
static bool is_simple_subquery(PlannerInfo *root, Query *subquery, RangeTblEntry *rte, JoinExpr *lowest_outer_join)
static void substitute_phv_relids(Node *node, int varno, Relids subrelids)
void pull_up_sublinks(PlannerInfo *root)
static Node * pullup_replace_vars_callback(Var *var, replace_rte_variables_context *context)
static Node * pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, JoinExpr *lowest_outer_join, AppendRelInfo *containing_appendrel)
void replace_empty_jointree(Query *parse)
static bool is_simple_union_all_recurse(Node *setOp, Query *setOpQuery, List *colTypes)
static bool substitute_phv_relids_walker(Node *node, substitute_phv_relids_context *context)
static void fix_append_rel_relids(PlannerInfo *root, int varno, Relids subrelids)
static Node * remove_useless_results_recurse(PlannerInfo *root, Node *jtnode, Node **parent_quals, Relids *dropped_outer_joins)
static Query * pullup_replace_vars_subquery(Query *query, pullup_replace_vars_context *context)
Relids get_relids_for_join(Query *query, int joinrelid)
void pull_up_subqueries(PlannerInfo *root)
Relids get_relids_in_jointree(Node *jtnode, bool include_outer_joins, bool include_inner_joins)
static int get_result_relid(PlannerInfo *root, Node *jtnode)
Query * preprocess_relation_rtes(PlannerInfo *root)
static Node * pull_up_simple_values(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte)
static bool is_safe_append_member(Query *subquery)
static Node * pull_up_sublinks_qual_recurse(PlannerInfo *root, Node *node, Node **jtlink1, Relids available_rels1, Node **jtlink2, Relids available_rels2)
void reduce_outer_joins(PlannerInfo *root)
static Query * expand_virtual_generated_columns(PlannerInfo *root, Query *parse, RangeTblEntry *rte, int rt_index, Relation relation)
static bool find_dependent_phvs(PlannerInfo *root, int varno)
static bool jointree_contains_lateral_outer_refs(PlannerInfo *root, Node *jtnode, bool restricted, Relids safe_upper_varnos)
static Node * pullup_replace_vars(Node *expr, pullup_replace_vars_context *context)
static bool is_simple_union_all(Query *subquery)
static bool find_dependent_phvs_in_jointree(PlannerInfo *root, Node *node, int varno)
#define NUM_MERGE_MATCH_KINDS
@ MERGE_WHEN_NOT_MATCHED_BY_TARGET
@ MERGE_WHEN_NOT_MATCHED_BY_SOURCE
#define RelationGetDescr(relation)
Node * build_generation_expression(Relation rel, int attrno)
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)
void OffsetVarNodes(Node *node, int offset, int sublevels_up)
void CombineRangeTables(List **dst_rtable, List **dst_perminfos, List *src_rtable, List *src_perminfos)
Node * add_nulling_relids(Node *node, const Bitmapset *target_relids, const Bitmapset *added_relids)
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)
Node * ReplaceVarFromTargetList(Var *var, RangeTblEntry *target_rte, List *targetlist, int result_relation, ReplaceVarsNoMatchOption nomatch_option, int nomatch_varno)
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
@ REPLACEVARS_REPORT_ERROR
void check_stack_depth(void)
Index qual_security_level
struct Path * non_recursive_path
List * processed_groupClause
List * processed_distinctClause
Relids leaf_result_relids
bool has_generated_virtual
nullingrel_info * nullinfo
ReplaceWrapOption wrap_option
RangeTblEntry * target_rte
JoinExpr * convert_ANY_sublink_to_join(PlannerInfo *root, SubLink *sublink, Relids available_rels)
ScalarArrayOpExpr * convert_VALUES_to_ANY(PlannerInfo *root, Node *testexpr, Query *values)
JoinExpr * convert_EXISTS_sublink_to_join(PlannerInfo *root, SubLink *sublink, bool under_not, Relids available_rels)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
bool tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
bool contain_vars_of_level(Node *node, int levelsup)
Relids pull_varnos_of_level(PlannerInfo *root, Node *node, int levelsup)
Relids pull_varnos(PlannerInfo *root, Node *node)
Node * flatten_join_alias_vars(PlannerInfo *root, Query *query, Node *node)