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 1755 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 392 of file partprune.c.
References Assert, bms_add_members(), bms_next_member(), lappend(), and lfirst.
Referenced by make_partition_pruneinfo().
|
static |
Definition at line 714 of file partprune.c.
References context, gen_partprune_steps_internal(), list_concat_copy(), partition_bound_has_default, and RelOptInfo::partition_qual.
Referenced by make_partitionedrel_pruneinfo(), and prune_append_rel_partitions().
|
static |
Definition at line 961 of file partprune.c.
References arg, generate_unaccent_rules::args, Assert, bms_add_member(), bms_is_empty, bms_is_member(), bms_num_members(), context, DatumGetBool(), 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, PARTITION_STRATEGY_HASH, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, PartitionSchemeData::partnatts, PARTPRUNE_COMBINE_INTERSECT, PARTPRUNE_COMBINE_UNION, predicate_refuted_by(), PartitionPruneStep::step_id, and PartitionSchemeData::strategy.
Referenced by gen_partprune_steps(), and match_clause_to_partition_key().
|
static |
Definition at line 1346 of file partprune.c.
References PartitionPruneStepCombine::combineOp, context, lappend(), makeNode, PartitionPruneStepCombine::source_stepids, PartitionPruneStepCombine::step, and PartitionPruneStep::step_id.
Referenced by gen_partprune_steps_internal().
|
static |
Definition at line 1313 of file partprune.c.
References Assert, PartitionPruneStepOp::cmpfns, context, PartitionPruneStepOp::exprs, InvalidStrategy, lappend(), list_length(), makeNode, PartitionPruneStepOp::nullkeys, PartitionPruneStepOp::opstrategy, PartitionPruneStepOp::step, and PartitionPruneStep::step_id.
Referenced by gen_partprune_steps_internal(), get_steps_using_prefix(), and get_steps_using_prefix_recurse().
|
static |
Definition at line 1383 of file partprune.c.
References Assert, bms_is_member(), BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, BTMaxStrategyNumber, PartClauseInfo::cmpfn, context, 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, and PartitionSchemeData::strategy.
Referenced by gen_partprune_steps_internal().
|
static |
Definition at line 2663 of file partprune.c.
References Assert, bms_add_range(), bms_is_member(), bms_make_singleton(), bms_num_members(), PruneStepResult::bound_offsets, compute_partition_hash_value(), context, HTEqualStrategyNumber, i, PartitionBoundInfoData::indexes, PartitionBoundInfoData::nindexes, palloc0(), PARTITION_MAX_KEYS, PARTITION_STRATEGY_HASH, PruneStepResult::scan_default, PruneStepResult::scan_null, and values.
Referenced by perform_pruning_base_step().
|
static |
Definition at line 2740 of file partprune.c.
References Assert, bms_add_range(), bms_del_member(), bms_is_empty, bms_make_singleton(), PruneStepResult::bound_offsets, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, context, elog, ERROR, PartitionBoundInfoData::indexes, InvalidStrategy, PartitionBoundInfoData::ndatums, palloc0(), partition_bound_accepts_nulls, partition_bound_has_default, partition_list_bsearch(), PARTITION_STRATEGY_LIST, PruneStepResult::scan_default, PruneStepResult::scan_null, and value.
Referenced by perform_pruning_base_step().
Bitmapset* get_matching_partitions | ( | PartitionPruneContext * | context, |
List * | pruning_steps | ||
) |
Definition at line 817 of file partprune.c.
References Assert, bms_add_member(), bms_add_range(), bms_next_member(), PruneStepResult::bound_offsets, context, elog, ERROR, i, lfirst, list_length(), nodeTag, 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, and PartitionPruneStep::step_id.
Referenced by find_matching_subplans_recurse(), and prune_append_rel_partitions().
|
static |
Definition at line 2951 of file partprune.c.
References Assert, bms_add_range(), bms_is_empty, bms_make_singleton(), PruneStepResult::bound_offsets, BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, context, PartitionBoundInfoData::datums, elog, ERROR, PartitionBoundInfoData::indexes, PartitionBoundInfoData::kind, PartitionBoundInfoData::ndatums, palloc0(), partition_bound_has_default, partition_range_datum_bsearch(), PARTITION_RANGE_DATUM_MAXVALUE, PARTITION_RANGE_DATUM_MINVALUE, partition_rbound_datum_cmp(), PARTITION_STRATEGY_RANGE, PruneStepResult::scan_default, PruneStepResult::scan_null, and values.
Referenced by perform_pruning_base_step().
Definition at line 3380 of file partprune.c.
References bms_join(), PartitionPruneStepOp::exprs, IsA, lfirst, and pull_exec_paramids().
Referenced by make_partitionedrel_pruneinfo().
|
static |
Definition at line 2438 of file partprune.c.
References Assert, context, gen_prune_step_op(), get_steps_using_prefix_recurse(), list_head(), list_make1, list_make1_oid, NIL, and PARTITION_STRATEGY_HASH.
Referenced by gen_prune_steps_from_opexps().
|
static |
Definition at line 2496 of file partprune.c.
References Assert, bms_is_empty, bms_num_members(), check_stack_depth(), PartClauseInfo::cmpfn, context, PartClauseInfo::expr, for_each_cell, gen_prune_step_op(), PartClauseInfo::keyno, lappend(), lappend_oid(), lfirst, list_concat(), list_copy(), list_free(), list_length(), llast, NIL, PARTITION_STRATEGY_HASH, and start.
Referenced by get_steps_using_prefix().
PartitionPruneInfo* make_partition_pruneinfo | ( | PlannerInfo * | root, |
RelOptInfo * | parentrel, | ||
List * | subpaths, | ||
List * | prunequal | ||
) |
Definition at line 220 of file partprune.c.
References add_part_relids(), Assert, bms_add_member(), bms_add_range(), 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, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, and root.
Referenced by create_append_plan(), and create_merge_append_plan().
|
static |
Definition at line 438 of file partprune.c.
References adjust_appendrel_attrs(), adjust_appendrel_attrs_multilevel(), Assert, bms_add_member(), bms_equal(), bms_is_empty, bms_next_member(), context, PartitionedRelPruneInfo::exec_pruning_steps, PartitionedRelPruneInfo::execparamids, find_appinfos_by_relids(), find_base_rel(), gen_partprune_steps(), get_partkey_exec_paramids(), 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, and PartitionedRelPruneInfo::rtindex.
Referenced by make_partition_pruneinfo().
|
static |
Definition at line 3673 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 1790 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(), context, 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(), 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(), PartitionSchemeData::strategy, and ScalarArrayOpExpr::useOr.
Referenced by gen_partprune_steps_internal().
|
static |
Definition at line 3760 of file partprune.c.
References Assert, context, ExecEvalExprSwitchContext(), IsA, and value.
Referenced by perform_pruning_base_step().
|
static |
Definition at line 3416 of file partprune.c.
References Assert, bms_is_member(), PruneStepResult::bound_offsets, PartitionPruneStepOp::cmpfns, context, elog, ERROR, PartitionPruneStepOp::exprs, fmgr_info_copy(), fmgr_info_cxt(), 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(), PruneCxtStateIdx, PruneStepResult::scan_default, PruneStepResult::scan_null, PartitionPruneStepOp::step, PartitionPruneStep::step_id, and values.
Referenced by get_matching_partitions().
|
static |
Definition at line 3564 of file partprune.c.
References Assert, bms_add_members(), bms_add_range(), bms_copy(), bms_int_members(), PruneStepResult::bound_offsets, PartitionPruneStepCombine::combineOp, context, 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 750 of file partprune.c.
References Assert, RelOptInfo::baserestrictinfo, bms_add_range(), context, GeneratePruningStepsContext::contradictory, CurrentMemoryContext, enable_partition_pruning, gen_partprune_steps(), get_matching_partitions(), list_length(), NIL, RelOptInfo::nparts, palloc0(), PARTTARGET_PLANNER, and GeneratePruningStepsContext::steps.
Referenced by expand_partitioned_rtentry().
Definition at line 3346 of file partprune.c.
References pull_exec_paramids_walker().
Referenced by get_partkey_exec_paramids(), and match_clause_to_partition_key().
Definition at line 3356 of file partprune.c.
References bms_add_member(), context, expression_tree_walker, IsA, PARAM_EXEC, Param::paramid, and Param::paramkind.
Referenced by pull_exec_paramids().