|
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"#include "utils/lsyscache.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 | IncrementVarSublevelsUp_context |
| struct | SetVarReturningType_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 1240 of file rewriteManip.c.
References add_nulling_relids_mutator(), add_nulling_relids_context::added_relids, query_or_expression_tree_mutator, add_nulling_relids_context::sublevels_up, and add_nulling_relids_context::target_relids.
Referenced by deconstruct_distribute_oj_quals(), mark_nullable_by_grouping(), pullup_replace_vars_callback(), and transform_MERGE_to_join().
|
static |
Definition at line 1256 of file rewriteManip.c.
References add_nulling_relids_mutator(), add_nulling_relids_context::added_relids, bms_is_member(), bms_overlap(), bms_union(), copyObject, expression_tree_mutator, fb(), IsA, makeNode, query_tree_mutator, add_nulling_relids_context::sublevels_up, add_nulling_relids_context::target_relids, Var::varlevelsup, and Var::varno.
Referenced by add_nulling_relids(), and add_nulling_relids_mutator().
Definition at line 1216 of file rewriteManip.c.
References AddQual(), fb(), IS_NOT_TRUE, and makeNode.
Referenced by CopyAndAddInvertedQual().
Definition at line 1148 of file rewriteManip.c.
References Assert, checkExprHasSubLink(), CMD_UTILITY, Query::commandType, contain_aggs_of_level(), copyObject, ereport, errcode(), errmsg(), ERROR, fb(), IsA, Query::jointree, make_and_qual(), FromExpr::quals, Query::setOperations, and Query::utilityStmt.
Referenced by AddInvertedQual(), rewriteRuleAction(), and rewriteTargetView().
Definition at line 761 of file rewriteManip.c.
References bms_add_member(), bms_copy(), bms_del_member(), bms_is_member(), fb(), and IS_SPECIAL_VARNO.
Referenced by ChangeVarNodes_walker(), remove_rel_from_eclass(), remove_rel_from_query(), remove_self_join_rel(), replace_relid_callback(), and update_eclasses().
Definition at line 733 of file rewriteManip.c.
References ChangeVarNodesExtended(), and fb().
Referenced by add_security_quals(), add_with_check_options(), ApplyRetrieveRule(), CopyAndAddInvertedQual(), expand_generated_columns_internal(), expand_virtual_generated_columns(), 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 552 of file rewriteManip.c.
References adjust_relid_set(), Assert, ChangeVarNodes_context::callback, ChangeVarNodes_walker(), CurrentOfExpr::cvarno, expression_tree_walker, fb(), IsA, j, ChangeVarNodes_context::new_index, PlanRowMark::prti, query_tree_walker, ChangeVarNodes_context::rt_index, PlanRowMark::rti, ChangeVarNodes_context::sublevels_up, Var::varlevelsup, and Var::varno.
Referenced by ChangeVarNodes_walker(), ChangeVarNodesExtended(), and ChangeVarNodesWalkExpression().
| void ChangeVarNodesExtended | ( | Node * | node, |
| int | rt_index, | ||
| int | new_index, | ||
| int | sublevels_up, | ||
| ChangeVarNodes_callback | callback | ||
| ) |
Definition at line 677 of file rewriteManip.c.
References ChangeVarNodes_context::callback, callback(), ChangeVarNodes_walker(), OnConflictExpr::exclRelIndex, IsA, lfirst, ChangeVarNodes_context::new_index, Query::onConflict, query_tree_walker, Query::rowMarks, ChangeVarNodes_context::rt_index, RowMarkClause::rti, and ChangeVarNodes_context::sublevels_up.
Referenced by ChangeVarNodes(), match_unique_clauses(), remove_rel_from_eclass(), remove_rel_from_query(), remove_self_join_rel(), split_selfjoin_quals(), and update_eclasses().
| bool ChangeVarNodesWalkExpression | ( | Node * | node, |
| ChangeVarNodes_context * | context | ||
| ) |
Definition at line 744 of file rewriteManip.c.
References ChangeVarNodes_walker(), and expression_tree_walker.
Referenced by replace_relid_callback().
Definition at line 292 of file rewriteManip.c.
References checkExprHasSubLink_walker(), fb(), 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().
Definition at line 305 of file rewriteManip.c.
References checkExprHasSubLink_walker(), expression_tree_walker, fb(), and IsA.
Referenced by checkExprHasSubLink(), and checkExprHasSubLink_walker().
| void CombineRangeTables | ( | List ** | dst_rtable, |
| List ** | dst_perminfos, | ||
| List * | src_rtable, | ||
| List * | src_perminfos | ||
| ) |
Definition at line 347 of file rewriteManip.c.
References fb(), 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().
Definition at line 85 of file rewriteManip.c.
References contain_aggs_of_level_walker(), query_or_expression_tree_walker, and contain_aggs_of_level_context::sublevels_up.
Referenced by AddQual(), checkTargetlistEntrySQL92(), convert_EXISTS_to_ANY(), and transformGroupClause().
|
static |
Definition at line 102 of file rewriteManip.c.
References contain_aggs_of_level_walker(), expression_tree_walker, fb(), IsA, query_tree_walker, and contain_aggs_of_level_context::sublevels_up.
Referenced by contain_aggs_of_level(), and contain_aggs_of_level_walker().
Definition at line 214 of file rewriteManip.c.
References contain_windowfuncs_walker(), fb(), and query_or_expression_tree_walker.
Referenced by checkTargetlistEntrySQL92(), contain_window_function(), transformGroupClause(), and transformWindowFuncCall().
Definition at line 227 of file rewriteManip.c.
References contain_windowfuncs_walker(), expression_tree_walker, fb(), and IsA.
Referenced by contain_windowfuncs(), and contain_windowfuncs_walker().
Definition at line 321 of file rewriteManip.c.
References contains_multiexpr_param(), expression_tree_walker, fb(), IsA, and PARAM_MULTIEXPR.
Referenced by contains_multiexpr_param(), and ReplaceVarFromTargetList().
Definition at line 1090 of file rewriteManip.c.
References Assert, CMD_INSERT, CMD_SELECT, Query::commandType, elog, ERROR, fb(), FromExpr::fromlist, IsA, Query::jointree, linitial, list_length(), PRS2_NEW_VARNO, PRS2_OLD_VARNO, rt_fetch, Query::rtable, and RTE_SUBQUERY.
Referenced by DefineQueryRewrite(), InsertRule(), make_ruledef(), rewriteRuleAction(), and transformRuleStmt().
Definition at line 881 of file rewriteManip.c.
References IncrementVarSublevelsUp_context::delta_sublevels_up, IncrementVarSublevelsUp_walker(), IncrementVarSublevelsUp_context::min_sublevels_up, 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(), replace_outer_returning(), ReplaceVarsFromTargetList_callback(), rewriteSearchAndCycle(), and substitute_actual_parameters_in_from_mutator().
Definition at line 904 of file rewriteManip.c.
References IncrementVarSublevelsUp_context::delta_sublevels_up, IncrementVarSublevelsUp_walker(), IncrementVarSublevelsUp_context::min_sublevels_up, QTW_EXAMINE_RTES_BEFORE, and range_table_walker.
Referenced by pull_up_simple_union_all().
|
static |
Definition at line 801 of file rewriteManip.c.
References IncrementVarSublevelsUp_context::delta_sublevels_up, elog, ERROR, expression_tree_walker, fb(), IncrementVarSublevelsUp_walker(), IsA, IncrementVarSublevelsUp_context::min_sublevels_up, QTW_EXAMINE_RTES_BEFORE, query_tree_walker, ReturningExpr::retlevelsup, RTE_CTE, and Var::varlevelsup.
Referenced by IncrementVarSublevelsUp(), IncrementVarSublevelsUp_rtable(), and IncrementVarSublevelsUp_walker().
Definition at line 149 of file rewriteManip.c.
References locate_agg_of_level_context::agg_location, fb(), locate_agg_of_level_walker(), query_or_expression_tree_walker, and locate_agg_of_level_context::sublevels_up.
Referenced by check_agg_arguments(), checkTargetlistEntrySQL92(), and parseCheckAggregates().
|
static |
Definition at line 169 of file rewriteManip.c.
References locate_agg_of_level_context::agg_location, expression_tree_walker, fb(), IsA, locate_agg_of_level_walker(), query_tree_walker, and locate_agg_of_level_context::sublevels_up.
Referenced by locate_agg_of_level(), and locate_agg_of_level_walker().
Definition at line 251 of file rewriteManip.c.
References fb(), locate_windowfunc_walker(), query_or_expression_tree_walker, and locate_windowfunc_context::win_location.
Referenced by checkTargetlistEntrySQL92(), and transformWindowFuncCall().
|
static |
Definition at line 270 of file rewriteManip.c.
References expression_tree_walker, fb(), IsA, locate_windowfunc_walker(), and locate_windowfunc_context::win_location.
Referenced by locate_windowfunc(), and locate_windowfunc_walker().
| 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 1702 of file rewriteManip.c.
References map_variable_attnos_context::attno_map, map_variable_attnos_context::found_whole_row, map_variable_attnos_mutator(), query_or_expression_tree_mutator, map_variable_attnos_context::sublevels_up, map_variable_attnos_context::target_varno, and map_variable_attnos_context::to_rowtype.
Referenced by ATPrepAlterColumnType(), CompareIndexInfo(), createTableConstraints(), ExecInitMerge(), ExecInitPartitionInfo(), expandTableLikeClause(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), map_partition_varattnos(), and MergeAttributes().
|
static |
Definition at line 1580 of file rewriteManip.c.
References ConvertRowtypeExpr::arg, Assert, map_variable_attnos_context::attno_map, AttrMap::attnums, COERCE_IMPLICIT_CAST, elog, ERROR, expression_tree_mutator, fb(), map_variable_attnos_context::found_whole_row, IsA, ConvertRowtypeExpr::location, makeNode, map_variable_attnos_mutator(), AttrMap::maplen, OidIsValid, palloc_object, query_tree_mutator, ConvertRowtypeExpr::resulttype, map_variable_attnos_context::sublevels_up, map_variable_attnos_context::target_varno, map_variable_attnos_context::to_rowtype, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by map_variable_attnos(), and map_variable_attnos_mutator().
Definition at line 527 of file rewriteManip.c.
References bms_add_member(), bms_next_member(), and fb().
Referenced by OffsetVarNodes_walker().
Definition at line 476 of file rewriteManip.c.
References OnConflictExpr::exclRelIndex, IsA, lfirst, OffsetVarNodes_context::offset, OffsetVarNodes_walker(), Query::onConflict, query_tree_walker, Query::rowMarks, RowMarkClause::rti, and OffsetVarNodes_context::sublevels_up.
Referenced by convert_EXISTS_sublink_to_join(), pull_up_simple_subquery(), and rewriteRuleAction().
|
static |
Definition at line 388 of file rewriteManip.c.
References Assert, CurrentOfExpr::cvarno, expression_tree_walker, fb(), IsA, j, OffsetVarNodes_context::offset, offset_relid_set(), OffsetVarNodes_walker(), query_tree_walker, OffsetVarNodes_context::sublevels_up, Var::varlevelsup, and Var::varno.
Referenced by OffsetVarNodes(), and OffsetVarNodes_walker().
Definition at line 1058 of file rewriteManip.c.
References query_or_expression_tree_walker, rangeTableEntry_used_walker(), rangeTableEntry_used_context::rt_index, and rangeTableEntry_used_context::sublevels_up.
Referenced by fireRIRrules(), matchLocks(), rewriteRuleAction(), and transformRuleStmt().
|
static |
Definition at line 992 of file rewriteManip.c.
References Assert, bms_is_member(), CurrentOfExpr::cvarno, expression_tree_walker, fb(), IsA, j, query_tree_walker, rangeTableEntry_used_walker(), rangeTableEntry_used_context::rt_index, rangeTableEntry_used_context::sublevels_up, Var::varlevelsup, and Var::varno.
Referenced by rangeTableEntry_used(), and rangeTableEntry_used_walker().
| Node * remove_nulling_relids | ( | Node * | node, |
| const Bitmapset * | removable_relids, | ||
| const Bitmapset * | except_relids | ||
| ) |
Definition at line 1328 of file rewriteManip.c.
References remove_nulling_relids_context::except_relids, query_or_expression_tree_mutator, remove_nulling_relids_context::removable_relids, remove_nulling_relids_mutator(), and remove_nulling_relids_context::sublevels_up.
Referenced by add_unique_group_var(), deconstruct_distribute_oj_quals(), estimate_multivariate_bucketsize(), examine_variable(), have_partkey_equi_join(), make_group_input_target(), make_pathkeys_for_sortclauses_extended(), reconsider_full_join_clause(), reduce_outer_joins(), remove_useless_result_rtes(), set_upper_references(), and split_pathtarget_walker().
|
static |
Definition at line 1344 of file rewriteManip.c.
References Assert, bms_difference(), bms_is_empty, bms_is_member(), bms_overlap(), copyObject, remove_nulling_relids_context::except_relids, expression_tree_mutator, fb(), IsA, query_tree_mutator, remove_nulling_relids_context::removable_relids, remove_nulling_relids_mutator(), remove_nulling_relids_context::sublevels_up, Var::varlevelsup, and Var::varno.
Referenced by remove_nulling_relids(), and remove_nulling_relids_mutator().
| 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 1435 of file rewriteManip.c.
References replace_rte_variables_context::callback, callback(), replace_rte_variables_context::callback_arg, elog, ERROR, replace_rte_variables_context::inserted_sublink, IsA, query_or_expression_tree_mutator, replace_rte_variables_mutator(), replace_rte_variables_context::sublevels_up, and replace_rte_variables_context::target_varno.
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 1482 of file rewriteManip.c.
References replace_rte_variables_context::callback, checkExprHasSubLink(), CurrentOfExpr::cvarno, ereport, errcode(), errmsg(), ERROR, expression_tree_mutator, fb(), replace_rte_variables_context::inserted_sublink, IsA, query_tree_mutator, replace_rte_variables_mutator(), replace_rte_variables_context::sublevels_up, replace_rte_variables_context::target_varno, Var::varlevelsup, and Var::varno.
Referenced by replace_rte_variables(), and replace_rte_variables_mutator().
| Node * ReplaceVarFromTargetList | ( | Var * | var, |
| RangeTblEntry * | target_rte, | ||
| List * | targetlist, | ||
| int | result_relation, | ||
| ReplaceVarsNoMatchOption | nomatch_option, | ||
| int | nomatch_varno | ||
| ) |
Definition at line 1792 of file rewriteManip.c.
References RowExpr::args, COERCE_IMPLICIT_CAST, coerce_null_to_domain(), contains_multiexpr_param(), copyObject, elog, ereport, errcode(), errmsg(), ERROR, expandRTE(), fb(), get_tle_by_resno(), get_typlenbyval(), InvalidAttrNumber, IsA, lappend(), lfirst, Var::location, RowExpr::location, makeNode, NIL, ReplaceVarFromTargetList(), REPLACEVARS_CHANGE_VARNO, REPLACEVARS_REPORT_ERROR, REPLACEVARS_SUBSTITUTE_NULL, ReturningExpr::retexpr, ReturningExpr::retlevelsup, ReturningExpr::retold, SetVarReturningType(), VAR_RETURNING_DEFAULT, VAR_RETURNING_OLD, Var::varattno, Var::varlevelsup, Var::varno, and Var::varreturningtype.
Referenced by pullup_replace_vars_callback(), ReplaceVarFromTargetList(), and ReplaceVarsFromTargetList_callback().
| 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 | ||
| ) |
Definition at line 1958 of file rewriteManip.c.
References ReplaceVarsFromTargetList_context::nomatch_option, ReplaceVarsFromTargetList_context::nomatch_varno, replace_rte_variables(), ReplaceVarsFromTargetList_callback(), ReplaceVarsFromTargetList_context::result_relation, ReplaceVarsFromTargetList_context::target_rte, and ReplaceVarsFromTargetList_context::targetlist.
Referenced by CopyAndAddInvertedQual(), expand_generated_columns_internal(), rewriteRuleAction(), rewriteTargetView(), and subquery_push_qual().
|
static |
Definition at line 1771 of file rewriteManip.c.
References replace_rte_variables_context::callback_arg, fb(), IncrementVarSublevelsUp(), ReplaceVarFromTargetList(), and Var::varlevelsup.
Referenced by ReplaceVarsFromTargetList().
|
static |
Definition at line 967 of file rewriteManip.c.
References SetVarReturningType_context::result_relation, SetVarReturningType_context::returning_type, SetVarReturningType_walker(), and SetVarReturningType_context::sublevels_up.
Referenced by ReplaceVarFromTargetList().
|
static |
Definition at line 937 of file rewriteManip.c.
References expression_tree_walker, fb(), IsA, query_tree_walker, SetVarReturningType_context::result_relation, SetVarReturningType_context::returning_type, SetVarReturningType_walker(), SetVarReturningType_context::sublevels_up, Var::varlevelsup, Var::varno, and Var::varreturningtype.
Referenced by SetVarReturningType(), and SetVarReturningType_walker().