PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/hash.h"
#include "access/nbtree.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/appendinfo.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "parser/parsetree.h"
#include "partitioning/partbounds.h"
#include "partitioning/partprune.h"
#include "utils/array.h"
#include "utils/lsyscache.h"
Go to the source code of this file.
Data Structures | |
struct | PartClauseInfo |
struct | GeneratePruningStepsContext |
struct | PruneStepResult |
Macros | |
#define | PartCollMatchesExprColl(partcoll, exprcoll) ((partcoll) == InvalidOid || (partcoll) == (exprcoll)) |
Typedefs | |
typedef struct PartClauseInfo | PartClauseInfo |
typedef enum PartClauseMatchStatus | PartClauseMatchStatus |
typedef enum PartClauseTarget | PartClauseTarget |
typedef struct GeneratePruningStepsContext | GeneratePruningStepsContext |
typedef struct PruneStepResult | PruneStepResult |
#define PartCollMatchesExprColl | ( | partcoll, | |
exprcoll | |||
) | ((partcoll) == InvalidOid || (partcoll) == (exprcoll)) |
Definition at line 1777 of file partprune.c.
typedef struct GeneratePruningStepsContext GeneratePruningStepsContext |
typedef struct PartClauseInfo PartClauseInfo |
typedef enum PartClauseMatchStatus PartClauseMatchStatus |
typedef enum PartClauseTarget PartClauseTarget |
typedef struct PruneStepResult PruneStepResult |
Enumerator | |
---|---|
PARTCLAUSE_NOMATCH | |
PARTCLAUSE_MATCH_CLAUSE | |
PARTCLAUSE_MATCH_NULLNESS | |
PARTCLAUSE_MATCH_STEPS | |
PARTCLAUSE_MATCH_CONTRADICT | |
PARTCLAUSE_UNSUPPORTED |
Definition at line 77 of file partprune.c.
enum PartClauseTarget |
Enumerator | |
---|---|
PARTTARGET_PLANNER | |
PARTTARGET_INITIAL | |
PARTTARGET_EXEC |
Definition at line 91 of file partprune.c.
Definition at line 399 of file partprune.c.
References Assert, bms_add_members(), bms_next_member(), lappend(), and lfirst.
Referenced by make_partition_pruneinfo().
|
static |
Definition at line 736 of file partprune.c.
References gen_partprune_steps_internal(), list_concat_copy(), partition_bound_has_default, RelOptInfo::partition_qual, GeneratePruningStepsContext::rel, and GeneratePruningStepsContext::target.
Referenced by make_partitionedrel_pruneinfo(), and prune_append_rel_partitions().
|
static |
Definition at line 983 of file partprune.c.
References arg, generate_unaccent_rules::args, Assert, bms_add_member(), bms_is_empty, bms_is_member(), bms_num_members(), GeneratePruningStepsContext::contradictory, DatumGetBool(), gen_partprune_steps_internal(), gen_prune_step_combine(), gen_prune_step_op(), gen_prune_steps_from_opexps(), i, InvalidStrategy, is_andclause(), is_orclause(), IsA, lappend(), lappend_int(), lfirst, linitial, list_concat(), list_length(), list_make1, llast, match_clause_to_partition_key(), NIL, PARTCLAUSE_MATCH_CLAUSE, PARTCLAUSE_MATCH_CONTRADICT, PARTCLAUSE_MATCH_NULLNESS, PARTCLAUSE_MATCH_STEPS, PARTCLAUSE_NOMATCH, PARTCLAUSE_UNSUPPORTED, partition_bound_has_default, PARTITION_MAX_KEYS, RelOptInfo::partition_qual, PARTITION_STRATEGY_HASH, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, PartitionSchemeData::partnatts, PARTPRUNE_COMBINE_INTERSECT, PARTPRUNE_COMBINE_UNION, predicate_refuted_by(), GeneratePruningStepsContext::rel, PartitionPruneStep::step_id, and PartitionSchemeData::strategy.
Referenced by gen_partprune_steps(), gen_partprune_steps_internal(), and match_clause_to_partition_key().
|
static |
Definition at line 1368 of file partprune.c.
References PartitionPruneStepCombine::combineOp, lappend(), makeNode, GeneratePruningStepsContext::next_step_id, PartitionPruneStepCombine::source_stepids, PartitionPruneStepCombine::step, PartitionPruneStep::step_id, and GeneratePruningStepsContext::steps.
Referenced by gen_partprune_steps_internal().
|
static |
Definition at line 1335 of file partprune.c.
References Assert, PartitionPruneStepOp::cmpfns, PartitionPruneStepOp::exprs, InvalidStrategy, lappend(), list_length(), makeNode, GeneratePruningStepsContext::next_step_id, PartitionPruneStepOp::nullkeys, PartitionPruneStepOp::opstrategy, PartitionPruneStepOp::step, PartitionPruneStep::step_id, and GeneratePruningStepsContext::steps.
Referenced by gen_partprune_steps_internal(), get_steps_using_prefix(), and get_steps_using_prefix_recurse().
|
static |
Definition at line 1405 of file partprune.c.
References Assert, bms_is_member(), BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, BTMaxStrategyNumber, PartClauseInfo::cmpfn, elog, ERROR, PartClauseInfo::expr, for_each_cell, get_op_opfamily_properties(), get_steps_using_prefix(), HTEqualStrategyNumber, HTMaxStrategyNumber, i, InvalidStrategy, PartClauseInfo::keyno, lappend(), lfirst, list_concat(), list_head(), llast, NIL, PartClauseInfo::op_is_ne, PartClauseInfo::op_strategy, PartClauseInfo::opno, PARTITION_STRATEGY_HASH, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, PartitionSchemeData::partnatts, PartitionSchemeData::partopfamily, GeneratePruningStepsContext::rel, and PartitionSchemeData::strategy.
Referenced by gen_partprune_steps_internal().
|
static |
Definition at line 2685 of file partprune.c.
References Assert, bms_add_range(), bms_is_member(), bms_make_singleton(), bms_num_members(), PruneStepResult::bound_offsets, PartitionPruneContext::boundinfo, compute_partition_hash_value(), HTEqualStrategyNumber, i, PartitionBoundInfoData::indexes, PartitionBoundInfoData::nindexes, palloc0(), PartitionPruneContext::partcollation, PARTITION_MAX_KEYS, PARTITION_STRATEGY_HASH, PartitionPruneContext::partnatts, PruneStepResult::scan_default, PruneStepResult::scan_null, PartitionPruneContext::strategy, and values.
Referenced by perform_pruning_base_step().
|
static |
Definition at line 2762 of file partprune.c.
References Assert, bms_add_range(), bms_del_member(), bms_is_empty, bms_make_singleton(), PruneStepResult::bound_offsets, PartitionPruneContext::boundinfo, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, elog, ERROR, PartitionBoundInfoData::indexes, InvalidStrategy, PartitionBoundInfoData::ndatums, palloc0(), PartitionPruneContext::partcollation, partition_bound_accepts_nulls, partition_bound_has_default, partition_list_bsearch(), PARTITION_STRATEGY_LIST, PartitionPruneContext::partnatts, PruneStepResult::scan_default, PruneStepResult::scan_null, PartitionPruneContext::strategy, and value.
Referenced by perform_pruning_base_step().
Bitmapset * get_matching_partitions | ( | PartitionPruneContext * | context, |
List * | pruning_steps | ||
) |
Definition at line 839 of file partprune.c.
References Assert, bms_add_member(), bms_add_range(), bms_next_member(), PruneStepResult::bound_offsets, PartitionPruneContext::boundinfo, PartitionBoundInfoData::default_index, elog, ERROR, i, PartitionBoundInfoData::indexes, lfirst, list_length(), nodeTag, PartitionPruneContext::nparts, PartitionBoundInfoData::null_index, palloc0(), partition_bound_accepts_nulls, partition_bound_has_default, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, perform_pruning_base_step(), perform_pruning_combine_step(), PruneStepResult::scan_default, PruneStepResult::scan_null, PartitionPruneStep::step_id, and PartitionPruneContext::strategy.
Referenced by find_matching_subplans_recurse(), and prune_append_rel_partitions().
|
static |
Definition at line 2973 of file partprune.c.
References Assert, bms_add_range(), bms_is_empty, bms_make_singleton(), PruneStepResult::bound_offsets, PartitionPruneContext::boundinfo, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, PartitionBoundInfoData::datums, elog, ERROR, PartitionBoundInfoData::indexes, PartitionBoundInfoData::kind, PartitionBoundInfoData::ndatums, palloc0(), PartitionPruneContext::partcollation, partition_bound_has_default, partition_range_datum_bsearch(), PARTITION_RANGE_DATUM_MAXVALUE, PARTITION_RANGE_DATUM_MINVALUE, partition_rbound_datum_cmp(), PARTITION_STRATEGY_RANGE, PartitionPruneContext::partnatts, PruneStepResult::scan_default, PruneStepResult::scan_null, PartitionPruneContext::strategy, and values.
Referenced by perform_pruning_base_step().
Definition at line 3401 of file partprune.c.
References bms_join(), PartitionPruneStepOp::exprs, IsA, lfirst, and pull_exec_paramids().
Referenced by make_partitionedrel_pruneinfo().
|
static |
Definition at line 2460 of file partprune.c.
References Assert, gen_prune_step_op(), get_steps_using_prefix_recurse(), list_head(), list_make1, list_make1_oid, NIL, PARTITION_STRATEGY_HASH, and GeneratePruningStepsContext::rel.
Referenced by gen_prune_steps_from_opexps().
|
static |
Definition at line 2518 of file partprune.c.
References Assert, bms_is_empty, bms_num_members(), check_stack_depth(), PartClauseInfo::cmpfn, PartClauseInfo::expr, for_each_cell, gen_prune_step_op(), get_steps_using_prefix_recurse(), PartClauseInfo::keyno, lappend(), lappend_oid(), lfirst, list_concat(), list_copy(), list_free(), list_length(), llast, NIL, PARTITION_STRATEGY_HASH, GeneratePruningStepsContext::rel, and start.
Referenced by get_steps_using_prefix(), and get_steps_using_prefix_recurse().
int make_partition_pruneinfo | ( | PlannerInfo * | root, |
RelOptInfo * | parentrel, | ||
List * | subpaths, | ||
List * | prunequal | ||
) |
Definition at line 224 of file partprune.c.
References add_part_relids(), Assert, bms_add_member(), bms_add_range(), bms_copy(), bms_del_members(), bms_join(), bms_num_members(), find_base_rel(), i, IS_PARTITIONED_REL, lappend(), lfirst, list_length(), make_partitionedrel_pruneinfo(), makeNode, NIL, PartitionPruneInfo::other_subplans, palloc0(), AppendRelInfo::parent_relid, pfree(), PartitionPruneInfo::prune_infos, RelOptInfo::relid, RelOptInfo::relids, PartitionPruneInfo::relids, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, and root.
Referenced by create_append_plan(), and create_merge_append_plan().
|
static |
Definition at line 445 of file partprune.c.
References adjust_appendrel_attrs(), adjust_appendrel_attrs_multilevel(), Assert, bms_add_member(), bms_equal(), bms_is_empty, bms_next_member(), GeneratePruningStepsContext::contradictory, PartitionedRelPruneInfo::exec_pruning_steps, PartitionedRelPruneInfo::execparamids, find_appinfos_by_relids(), find_base_rel(), gen_partprune_steps(), get_partkey_exec_paramids(), GeneratePruningStepsContext::has_exec_param, GeneratePruningStepsContext::has_mutable_arg, GeneratePruningStepsContext::has_mutable_op, i, PartitionedRelPruneInfo::initial_pruning_steps, lappend(), lfirst, RelOptInfo::live_parts, makeNode, NIL, RelOptInfo::nparts, PartitionedRelPruneInfo::nparts, palloc(), palloc0(), PARTTARGET_EXEC, PARTTARGET_INITIAL, pfree(), planner_rt_fetch, PartitionedRelPruneInfo::present_parts, RelOptInfo::relid, RelOptInfo::relids, root, PartitionedRelPruneInfo::rtindex, and GeneratePruningStepsContext::steps.
Referenced by make_partition_pruneinfo().
|
static |
Definition at line 3694 of file partprune.c.
References arg, BooleanTest::arg, BooleanTest::booltesttype, equal(), get_notclausearg(), IS_FALSE, IS_NOT_FALSE, IS_NOT_TRUE, IS_NOT_UNKNOWN, is_notclause(), IS_TRUE, IS_UNKNOWN, IsA, makeBoolConst(), negate_clause(), PARTCLAUSE_MATCH_CLAUSE, PARTCLAUSE_MATCH_NULLNESS, PARTCLAUSE_NOMATCH, and PARTCLAUSE_UNSUPPORTED.
Referenced by match_clause_to_partition_key().
|
static |
Definition at line 1812 of file partprune.c.
References arg, NullTest::arg, generate_unaccent_rules::args, ScalarArrayOpExpr::args, ARR_ELEMTYPE, Assert, bms_is_empty, BooleanTest::booltesttype, BTEqualStrategyNumber, BTORDER_PROC, castNode, PartClauseInfo::cmpfn, contain_var_clause(), contain_volatile_functions(), GeneratePruningStepsContext::contradictory, copyObject, DatumGetArrayTypeP, deconstruct_array(), ArrayExpr::elements, elog, equal(), ERROR, PartClauseInfo::expr, FmgrInfo::fn_oid, gen_partprune_steps_internal(), get_commutator(), get_leftop(), get_negator(), get_op_opfamily_properties(), get_opfamily_proc(), get_rightop(), get_typlenbyvalalign(), GeneratePruningStepsContext::has_exec_param, GeneratePruningStepsContext::has_mutable_arg, GeneratePruningStepsContext::has_mutable_op, HASHEXTENDED_PROC, i, InvalidOid, InvalidStrategy, IS_FALSE, IS_NOT_FALSE, IS_NOT_NULL, IS_NOT_TRUE, IS_NULL, IS_TRUE, IsA, PartClauseInfo::keyno, lappend(), lfirst, linitial, list_length(), list_make1, list_make2, NullTest::location, lsecond, make_opclause(), makeBoolExpr(), makeConst(), makeNode, match_boolean_partition_clause(), NIL, NullTest::nulltesttype, OidIsValid, op_in_opfamily(), PartClauseInfo::op_is_ne, PartClauseInfo::op_strategy, op_strict(), op_volatile(), PartClauseInfo::opno, OpExpr::opno, ScalarArrayOpExpr::opno, OR_EXPR, palloc(), PARTCLAUSE_MATCH_CLAUSE, PARTCLAUSE_MATCH_CONTRADICT, PARTCLAUSE_MATCH_NULLNESS, PARTCLAUSE_MATCH_STEPS, PARTCLAUSE_NOMATCH, PARTCLAUSE_UNSUPPORTED, PartitionSchemeData::partcollation, PartCollMatchesExprColl, PARTITION_STRATEGY_HASH, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, PartitionSchemeData::partopcintype, PartitionSchemeData::partopfamily, PartitionSchemeData::partsupfunc, PARTTARGET_EXEC, PARTTARGET_PLANNER, pull_exec_paramids(), GeneratePruningStepsContext::rel, PartitionSchemeData::strategy, GeneratePruningStepsContext::target, and ScalarArrayOpExpr::useOr.
Referenced by gen_partprune_steps_internal().
|
static |
Definition at line 3781 of file partprune.c.
References Assert, ExecEvalExprSwitchContext(), PartitionPruneContext::exprcontext, PartitionPruneContext::exprstates, IsA, and value.
Referenced by perform_pruning_base_step().
|
static |
Definition at line 3437 of file partprune.c.
References Assert, bms_is_member(), PruneStepResult::bound_offsets, PartitionPruneStepOp::cmpfns, elog, ERROR, PartitionPruneStepOp::exprs, fmgr_info_copy(), fmgr_info_cxt(), FmgrInfo::fn_oid, get_matching_hash_bounds(), get_matching_list_bounds(), get_matching_range_bounds(), lfirst, lfirst_oid, list_head(), list_length(), lnext(), PartitionPruneStepOp::nullkeys, OidIsValid, PartitionPruneStepOp::opstrategy, palloc(), PARTITION_MAX_KEYS, PARTITION_STRATEGY_HASH, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, partkey_datum_from_expr(), PartitionPruneContext::partnatts, PartitionPruneContext::partsupfunc, PartitionPruneContext::ppccontext, PruneCxtStateIdx, PruneStepResult::scan_default, PruneStepResult::scan_null, PartitionPruneStepOp::step, PartitionPruneStep::step_id, PartitionPruneContext::stepcmpfuncs, PartitionPruneContext::strategy, and values.
Referenced by get_matching_partitions().
|
static |
Definition at line 3585 of file partprune.c.
References Assert, bms_add_members(), bms_add_range(), bms_copy(), bms_int_members(), PruneStepResult::bound_offsets, PartitionPruneContext::boundinfo, PartitionPruneStepCombine::combineOp, elog, ERROR, lfirst_int, NIL, PartitionBoundInfoData::nindexes, palloc0(), partition_bound_accepts_nulls, partition_bound_has_default, PARTPRUNE_COMBINE_INTERSECT, PARTPRUNE_COMBINE_UNION, PruneStepResult::scan_default, PruneStepResult::scan_null, PartitionPruneStepCombine::source_stepids, PartitionPruneStepCombine::step, and PartitionPruneStep::step_id.
Referenced by get_matching_partitions().
Bitmapset * prune_append_rel_partitions | ( | RelOptInfo * | rel | ) |
Definition at line 772 of file partprune.c.
References Assert, RelOptInfo::baserestrictinfo, bms_add_range(), PartitionPruneContext::boundinfo, GeneratePruningStepsContext::contradictory, CurrentMemoryContext, enable_partition_pruning, PartitionPruneContext::exprcontext, PartitionPruneContext::exprstates, gen_partprune_steps(), get_matching_partitions(), list_length(), NIL, RelOptInfo::nparts, PartitionPruneContext::nparts, palloc0(), PartitionPruneContext::partcollation, PartitionPruneContext::partnatts, PartitionPruneContext::partsupfunc, PARTTARGET_PLANNER, PartitionPruneContext::planstate, PartitionPruneContext::ppccontext, PartitionPruneContext::stepcmpfuncs, GeneratePruningStepsContext::steps, and PartitionPruneContext::strategy.
Referenced by expand_partitioned_rtentry().
Definition at line 3368 of file partprune.c.
References pull_exec_paramids_walker().
Referenced by get_partkey_exec_paramids(), and match_clause_to_partition_key().
Definition at line 3378 of file partprune.c.
References bms_add_member(), expression_tree_walker, IsA, PARAM_EXEC, Param::paramid, Param::paramkind, and pull_exec_paramids_walker().
Referenced by pull_exec_paramids(), and pull_exec_paramids_walker().