165 int rtindex,
Relids relids);
175 Node *node,
int varno);
177 int varno,
Relids subrelids);
273 rtr->rtindex =
parse->mergeTargetRelation;
290 elog(
ERROR,
"unrecognized source node type: %d",
339 parse->mergeJoinCondition =
351 action->targetList = (
List *)
392 ntest->argisrow =
false;
396 parse->mergeJoinCondition =
429 for (rt_index = 0; rt_index < rtable_size; rt_index++)
454 rte->inh = relation->
rd_rel->relhassubclass;
505 for (
int i = 0;
i < tupdesc->
natts;
i++)
566 if (
parse->groupingSets)
600 if (
parse->jointree->fromlist !=
NIL)
604 if (
parse->setOperations)
795 elog(
ERROR,
"unrecognized join type: %d",
814 elog(
ERROR,
"unrecognized node type: %d",
860 return (
Node *) saop;
1044 foreach(l, ((
BoolExpr *) node)->args)
1103 foreach(
rt,
root->parse->rtable)
1122 rte->security_barrier =
false;
1131 rte->funcordinality =
false;
1274 switch (
j->jointype)
1311 elog(
ERROR,
"unrecognized join type: %d",
1317 elog(
ERROR,
"unrecognized node type: %d",
1362 subroot->
parse = subquery;
1366 subroot->parent_root =
root->parent_root;
1382 memset(subroot->upper_rels, 0,
sizeof(subroot->upper_rels));
1383 memset(subroot->upper_targets, 0,
sizeof(subroot->upper_targets));
1388 subroot->grouping_map =
NULL;
1421 if (subquery->hasSubLinks)
1536 if (
parse->groupingSets)
1589 subquery->
rtable, subquery->rteperminfos);
1608 if (
root->glob->lastPHId != 0 ||
root->append_rel_list)
1614 if (
root->glob->lastPHId != 0)
1651 parse->hasSubLinks |= subquery->hasSubLinks;
1654 parse->hasRowSecurity |= subquery->hasRowSecurity;
1729 rtable, subquery->rteperminfos);
1823 elog(
ERROR,
"unrecognized node type: %d",
1903 if (subquery->hasAggs ||
1904 subquery->hasWindowFuncs ||
1905 subquery->hasTargetSRFs ||
1913 subquery->hasForUpdate ||
1922 if (
rte->security_barrier)
2183 if (
rte->funcordinality)
2198 if (
rtf->funccolcount != 1)
2202 if (
rtf->funccolnames !=
NIL)
2241 if (
parse->groupingSets)
2266 rte->lateral =
false;
2342 elog(
ERROR,
"unrecognized node type: %d",
2464 elog(
ERROR,
"unrecognized node type: %d",
2517 if (
parse->onConflict)
2519 parse->onConflict->onConflictSet = (
List *)
2522 parse->onConflict->onConflictWhere =
2531 if (
parse->mergeActionList)
2533 foreach(
lc,
parse->mergeActionList)
2538 action->targetList = (
List *)
2551 foreach(
lc,
root->append_rel_list)
2600 if (varno != context->
varno)
2607 switch (
rte->rtekind)
2680 elog(
ERROR,
"unrecognized node type: %d",
2752 rcon->result_relation,
2788 if (
rcon->target_rte->lateral &&
2805 if (
rcon->target_rte->lateral &&
2869 if (!
rcon->target_rte->lateral)
2932 if (var->varnullingrels !=
NULL)
2940 var->varnullingrels);
2948 var->varnullingrels);
2971 if (
rcon->target_rte->lateral)
3002 var->varnullingrels);
3067 if (
root->hasRecursion)
3193 elog(
ERROR,
"so where are the outer joins?");
3225 foreach(
lc,
state2.partial_reduced)
3300 switch (
j->jointype)
3330 elog(
ERROR,
"unrecognized join type: %d",
3336 elog(
ERROR,
"unrecognized node type: %d",
3406 int rtindex =
j->rtindex;
3459 elog(
ERROR,
"unrecognized join type: %d",
3520 if (rtindex && jointype !=
j->jointype)
3526 rte->jointype = jointype;
3531 j->jointype = jointype;
3631 elog(
ERROR,
"unrecognized node type: %d",
3638 int rtindex,
Relids relids)
3643 statep->full_join_rti = rtindex;
3644 statep->unreduced_side = relids;
3846 foreach(cell,
root->rowMarks)
3949 f !=
root->parse->jointree &&
3995 switch (
j->jointype)
4025 if (
j->quals !=
NULL)
4041 if (
j->quals !=
NULL)
4070 (
j->quals ==
NULL ||
4110 if (
j->quals !=
NULL)
4124 elog(
ERROR,
"unrecognized join type: %d",
4130 elog(
ERROR,
"unrecognized node type: %d",
4175 if (
root->glob->lastPHId != 0)
4250 if (
root->glob->lastPHId == 0)
4274 if (
root->glob->lastPHId == 0)
4375 context.
varno = varno;
4410 foreach(l,
root->append_rel_list)
4417 if (
appinfo->child_relid == varno)
4425 if (
root->glob->lastPHId != 0)
4495 elog(
ERROR,
"unrecognized node type: %d",
4548 if (relid ==
j->rtindex)
4558 elog(
ERROR,
"unrecognized node type: %d",
4617 switch (
j->jointype)
4644 elog(
ERROR,
"unrecognized join type: %d",
4650 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 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)
#define list_make2(x1, x2)
static rewind_source * source
PlaceHolderVar * make_placeholder_expr(PlannerInfo *root, Expr *expr, Relids phrels)
void get_relation_notnullatts(PlannerInfo *root, Relation relation)
Bitmapset * find_relation_notnullatts(PlannerInfo *root, Oid relid)
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 bool has_notnull_forced_var(PlannerInfo *root, List *forced_null_vars, reduce_outer_joins_pass1_state *right_state)
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)
#define FirstLowInvalidHeapAttributeNumber
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)