PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/pathnodes.h"
#include "nodes/plannodes.h"
#include "parser/parse_coerce.h"
#include "parser/parse_relation.h"
#include "parser/parsetree.h"
#include "rewrite/rewriteManip.h"
Go to the source code of this file.
Data Structures | |
struct | contain_aggs_of_level_context |
struct | locate_agg_of_level_context |
struct | locate_windowfunc_context |
struct | add_nulling_relids_context |
struct | remove_nulling_relids_context |
struct | OffsetVarNodes_context |
struct | ChangeVarNodes_context |
struct | IncrementVarSublevelsUp_context |
struct | rangeTableEntry_used_context |
struct | map_variable_attnos_context |
struct | ReplaceVarsFromTargetList_context |
Node* add_nulling_relids | ( | Node * | node, |
const Bitmapset * | target_relids, | ||
const Bitmapset * | added_relids | ||
) |
Definition at line 1139 of file rewriteManip.c.
References add_nulling_relids_mutator(), context, and query_or_expression_tree_mutator.
Referenced by deconstruct_distribute_oj_quals(), mark_nullable_by_grouping(), pullup_replace_vars_callback(), and transform_MERGE_to_join().
|
static |
Definition at line 1155 of file rewriteManip.c.
References bms_is_member(), bms_overlap(), bms_union(), context, copyObject, expression_tree_mutator, IsA, makeNode, PlaceHolderVar::phlevelsup, PlaceHolderVar::phnullingrels, query_tree_mutator, Var::varlevelsup, and Var::varno.
Referenced by add_nulling_relids().
Definition at line 1115 of file rewriteManip.c.
References AddQual(), BooleanTest::arg, BooleanTest::booltesttype, IS_NOT_TRUE, BooleanTest::location, and makeNode.
Referenced by CopyAndAddInvertedQual().
Definition at line 1047 of file rewriteManip.c.
References Assert, checkExprHasSubLink(), CMD_UTILITY, Query::commandType, contain_aggs_of_level(), copyObject, ereport, errcode(), errmsg(), ERROR, IsA, Query::jointree, make_and_qual(), FromExpr::quals, Query::setOperations, and Query::utilityStmt.
Referenced by AddInvertedQual(), rewriteRuleAction(), and rewriteTargetView().
Definition at line 730 of file rewriteManip.c.
References bms_add_member(), bms_copy(), bms_del_member(), bms_is_member(), and IS_SPECIAL_VARNO.
Referenced by ChangeVarNodes_walker().
void ChangeVarNodes | ( | Node * | node, |
int | rt_index, | ||
int | new_index, | ||
int | sublevels_up | ||
) |
Definition at line 668 of file rewriteManip.c.
References ChangeVarNodes_walker(), context, OnConflictExpr::exclRelIndex, IsA, lfirst, Query::onConflict, query_tree_walker, Query::rowMarks, and RowMarkClause::rti.
Referenced by add_security_quals(), add_with_check_options(), ApplyRetrieveRule(), CopyAndAddInvertedQual(), get_relation_constraints(), get_relation_info(), get_relation_statistics(), infer_arbiter_indexes(), rewriteRuleAction(), rewriteTargetView(), set_baserel_partition_constraint(), set_baserel_partition_key_exprs(), and TriggerEnabled().
|
static |
Definition at line 559 of file rewriteManip.c.
References adjust_relid_set(), Assert, AppendRelInfo::child_relid, context, CurrentOfExpr::cvarno, expression_tree_walker, IsA, j, AppendRelInfo::parent_relid, PlaceHolderVar::phlevelsup, PlaceHolderVar::phnullingrels, PlanRowMark::prti, query_tree_walker, PlanRowMark::rti, RangeTblRef::rtindex, Var::varlevelsup, and Var::varno.
Referenced by ChangeVarNodes().
bool checkExprHasSubLink | ( | Node * | node | ) |
Definition at line 292 of file rewriteManip.c.
References checkExprHasSubLink_walker(), QTW_IGNORE_RC_SUBQUERIES, and query_or_expression_tree_walker.
Referenced by AddQual(), flatten_group_exprs_mutator(), flatten_join_alias_vars_mutator(), RelationBuildRowSecurity(), replace_rte_variables_mutator(), rewriteRuleAction(), and rewriteTargetView().
|
static |
Definition at line 305 of file rewriteManip.c.
References context, expression_tree_walker, and IsA.
Referenced by checkExprHasSubLink().
void CombineRangeTables | ( | List ** | dst_rtable, |
List ** | dst_perminfos, | ||
List * | src_rtable, | ||
List * | src_perminfos | ||
) |
Definition at line 347 of file rewriteManip.c.
References lfirst_node, list_concat(), and list_length().
Referenced by convert_EXISTS_sublink_to_join(), pull_up_simple_subquery(), pull_up_simple_union_all(), and rewriteRuleAction().
bool contain_aggs_of_level | ( | Node * | node, |
int | levelsup | ||
) |
Definition at line 85 of file rewriteManip.c.
References contain_aggs_of_level_walker(), context, and query_or_expression_tree_walker.
Referenced by AddQual(), checkTargetlistEntrySQL92(), and convert_EXISTS_to_ANY().
|
static |
Definition at line 102 of file rewriteManip.c.
References context, expression_tree_walker, IsA, and query_tree_walker.
Referenced by contain_aggs_of_level().
bool contain_windowfuncs | ( | Node * | node | ) |
Definition at line 214 of file rewriteManip.c.
References contain_windowfuncs_walker(), and query_or_expression_tree_walker.
Referenced by checkTargetlistEntrySQL92(), contain_window_function(), and transformWindowFuncCall().
|
static |
Definition at line 227 of file rewriteManip.c.
References context, expression_tree_walker, and IsA.
Referenced by contain_windowfuncs().
|
static |
Definition at line 321 of file rewriteManip.c.
References context, expression_tree_walker, IsA, and PARAM_MULTIEXPR.
Referenced by ReplaceVarsFromTargetList_callback().
Definition at line 989 of file rewriteManip.c.
References Assert, CMD_INSERT, CMD_SELECT, Query::commandType, elog, ERROR, FromExpr::fromlist, IsA, Query::jointree, linitial, list_length(), PRS2_NEW_VARNO, PRS2_OLD_VARNO, rt_fetch, Query::rtable, RTE_SUBQUERY, RangeTblEntry::rtekind, RangeTblRef::rtindex, and RangeTblEntry::subquery.
Referenced by DefineQueryRewrite(), InsertRule(), make_ruledef(), rewriteRuleAction(), and transformRuleStmt().
void IncrementVarSublevelsUp | ( | Node * | node, |
int | delta_sublevels_up, | ||
int | min_sublevels_up | ||
) |
Definition at line 841 of file rewriteManip.c.
References context, IncrementVarSublevelsUp_walker(), QTW_EXAMINE_RTES_BEFORE, and query_or_expression_tree_walker.
Referenced by assign_param_for_placeholdervar(), build_minmax_path(), convert_EXISTS_sublink_to_join(), convert_EXISTS_to_ANY(), extract_lateral_references(), flatten_group_exprs_mutator(), flatten_join_alias_vars_mutator(), inline_cte_walker(), pull_up_simple_subquery(), pullup_replace_vars_callback(), replace_outer_agg(), replace_outer_grouping(), ReplaceVarsFromTargetList_callback(), rewriteSearchAndCycle(), and substitute_actual_srf_parameters_mutator().
void IncrementVarSublevelsUp_rtable | ( | List * | rtable, |
int | delta_sublevels_up, | ||
int | min_sublevels_up | ||
) |
Definition at line 864 of file rewriteManip.c.
References context, IncrementVarSublevelsUp_walker(), QTW_EXAMINE_RTES_BEFORE, and range_table_walker.
Referenced by pull_up_simple_union_all().
|
static |
Definition at line 769 of file rewriteManip.c.
References GroupingFunc::agglevelsup, context, RangeTblEntry::ctelevelsup, elog, ERROR, expression_tree_walker, IsA, PlaceHolderVar::phlevelsup, QTW_EXAMINE_RTES_BEFORE, query_tree_walker, RTE_CTE, RangeTblEntry::rtekind, and Var::varlevelsup.
Referenced by IncrementVarSublevelsUp(), and IncrementVarSublevelsUp_rtable().
int locate_agg_of_level | ( | Node * | node, |
int | levelsup | ||
) |
Definition at line 149 of file rewriteManip.c.
References context, locate_agg_of_level_walker(), and query_or_expression_tree_walker.
Referenced by check_agg_arguments(), checkTargetlistEntrySQL92(), and parseCheckAggregates().
|
static |
Definition at line 169 of file rewriteManip.c.
References context, expression_tree_walker, IsA, and query_tree_walker.
Referenced by locate_agg_of_level().
int locate_windowfunc | ( | Node * | node | ) |
Definition at line 251 of file rewriteManip.c.
References context, locate_windowfunc_walker(), and query_or_expression_tree_walker.
Referenced by checkTargetlistEntrySQL92(), and transformWindowFuncCall().
|
static |
Definition at line 270 of file rewriteManip.c.
References context, expression_tree_walker, and IsA.
Referenced by locate_windowfunc().
Node* map_variable_attnos | ( | Node * | node, |
int | target_varno, | ||
int | sublevels_up, | ||
const AttrMap * | attno_map, | ||
Oid | to_rowtype, | ||
bool * | found_whole_row | ||
) |
Definition at line 1601 of file rewriteManip.c.
References context, map_variable_attnos_mutator(), and query_or_expression_tree_mutator.
Referenced by ATPrepAlterColumnType(), CompareIndexInfo(), ExecInitPartitionInfo(), expandTableLikeClause(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), map_partition_varattnos(), and MergeAttributes().
|
static |
Definition at line 1479 of file rewriteManip.c.
References ConvertRowtypeExpr::arg, Assert, COERCE_IMPLICIT_CAST, context, elog, ERROR, expression_tree_mutator, if(), IsA, ConvertRowtypeExpr::location, makeNode, OidIsValid, palloc(), query_tree_mutator, ConvertRowtypeExpr::resulttype, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by map_variable_attnos().
Definition at line 527 of file rewriteManip.c.
References bms_add_member(), and bms_next_member().
Referenced by OffsetVarNodes_walker().
void OffsetVarNodes | ( | Node * | node, |
int | offset, | ||
int | sublevels_up | ||
) |
Definition at line 476 of file rewriteManip.c.
References context, OnConflictExpr::exclRelIndex, IsA, lfirst, OffsetVarNodes_walker(), Query::onConflict, query_tree_walker, Query::rowMarks, and RowMarkClause::rti.
Referenced by convert_EXISTS_sublink_to_join(), pull_up_simple_subquery(), and rewriteRuleAction().
|
static |
Definition at line 388 of file rewriteManip.c.
References Assert, AppendRelInfo::child_relid, context, CurrentOfExpr::cvarno, expression_tree_walker, IsA, j, offset_relid_set(), AppendRelInfo::parent_relid, PlaceHolderVar::phlevelsup, PlaceHolderVar::phnullingrels, query_tree_walker, RangeTblRef::rtindex, Var::varlevelsup, and Var::varno.
Referenced by OffsetVarNodes().
bool rangeTableEntry_used | ( | Node * | node, |
int | rt_index, | ||
int | sublevels_up | ||
) |
Definition at line 957 of file rewriteManip.c.
References context, query_or_expression_tree_walker, and rangeTableEntry_used_walker().
Referenced by fireRIRrules(), matchLocks(), rewriteRuleAction(), and transformRuleStmt().
|
static |
Definition at line 891 of file rewriteManip.c.
References Assert, bms_is_member(), context, CurrentOfExpr::cvarno, expression_tree_walker, IsA, j, query_tree_walker, RangeTblRef::rtindex, Var::varlevelsup, and Var::varno.
Referenced by rangeTableEntry_used().
Node* remove_nulling_relids | ( | Node * | node, |
const Bitmapset * | removable_relids, | ||
const Bitmapset * | except_relids | ||
) |
Definition at line 1227 of file rewriteManip.c.
References context, query_or_expression_tree_mutator, and remove_nulling_relids_mutator().
Referenced by deconstruct_distribute_oj_quals(), have_partkey_equi_join(), make_group_input_target(), make_pathkeys_for_sortclauses_extended(), reconsider_full_join_clause(), reduce_outer_joins(), remove_useless_result_rtes(), and set_upper_references().
|
static |
Definition at line 1243 of file rewriteManip.c.
References Assert, bms_difference(), bms_is_empty, bms_is_member(), bms_overlap(), context, copyObject, expression_tree_mutator, IsA, PlaceHolderVar::phlevelsup, PlaceHolderVar::phnullingrels, query_tree_mutator, Var::varlevelsup, and Var::varno.
Referenced by remove_nulling_relids().
Node* replace_rte_variables | ( | Node * | node, |
int | target_varno, | ||
int | sublevels_up, | ||
replace_rte_variables_callback | callback, | ||
void * | callback_arg, | ||
bool * | outer_hasSubLinks | ||
) |
Definition at line 1334 of file rewriteManip.c.
References callback(), context, elog, ERROR, IsA, query_or_expression_tree_mutator, and replace_rte_variables_mutator().
Referenced by pullup_replace_vars(), pullup_replace_vars_subquery(), and ReplaceVarsFromTargetList().
Node* replace_rte_variables_mutator | ( | Node * | node, |
replace_rte_variables_context * | context | ||
) |
Definition at line 1381 of file rewriteManip.c.
References checkExprHasSubLink(), context, CurrentOfExpr::cvarno, ereport, errcode(), errmsg(), ERROR, expression_tree_mutator, IsA, query_tree_mutator, Var::varlevelsup, and Var::varno.
Referenced by pullup_replace_vars_callback(), replace_rte_variables(), and ReplaceVarsFromTargetList_callback().
Node* ReplaceVarsFromTargetList | ( | Node * | node, |
int | target_varno, | ||
int | sublevels_up, | ||
RangeTblEntry * | target_rte, | ||
List * | targetlist, | ||
ReplaceVarsNoMatchOption | nomatch_option, | ||
int | nomatch_varno, | ||
bool * | outer_hasSubLinks | ||
) |
Definition at line 1759 of file rewriteManip.c.
References context, replace_rte_variables(), and ReplaceVarsFromTargetList_callback().
Referenced by CopyAndAddInvertedQual(), rewriteRuleAction(), rewriteTargetView(), and subquery_push_qual().
|
static |
Definition at line 1655 of file rewriteManip.c.
References RowExpr::args, COERCE_IMPLICIT_CAST, coerce_to_domain(), COERCION_IMPLICIT, contains_multiexpr_param(), context, copyObject, elog, ereport, errcode(), errmsg(), ERROR, expandRTE(), get_tle_by_resno(), if(), IncrementVarSublevelsUp(), InvalidAttrNumber, InvalidOid, Var::location, RowExpr::location, makeNode, makeNullConst(), NIL, ReplaceVarsFromTargetList_context::nomatch_option, ReplaceVarsFromTargetList_context::nomatch_varno, replace_rte_variables_mutator(), REPLACEVARS_CHANGE_VARNO, REPLACEVARS_REPORT_ERROR, REPLACEVARS_SUBSTITUTE_NULL, ReplaceVarsFromTargetList_context::target_rte, ReplaceVarsFromTargetList_context::targetlist, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by ReplaceVarsFromTargetList().