|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/table.h"#include "access/tableam.h"#include "catalog/index.h"#include "catalog/partition.h"#include "executor/execPartition.h"#include "executor/executor.h"#include "executor/nodeModifyTable.h"#include "foreign/fdwapi.h"#include "mb/pg_wchar.h"#include "miscadmin.h"#include "partitioning/partbounds.h"#include "partitioning/partdesc.h"#include "partitioning/partprune.h"#include "rewrite/rewriteManip.h"#include "utils/acl.h"#include "utils/injection_point.h"#include "utils/lsyscache.h"#include "utils/partcache.h"#include "utils/rls.h"#include "utils/ruleutils.h"
Go to the source code of this file.
Data Structures | |
| struct | PartitionTupleRouting |
| struct | PartitionDispatchData |
Macros | |
| #define | PARTITION_CACHED_FIND_THRESHOLD 16 |
Typedefs | |
| typedef struct PartitionDispatchData | PartitionDispatchData |
| #define PARTITION_CACHED_FIND_THRESHOLD 16 |
Definition at line 1504 of file execPartition.c.
|
static |
Definition at line 1855 of file execPartition.c.
References adjust_partition_colnos_using_map(), Assert, TupleConversionMap::attrMap, ExecGetChildToRootMap(), and fb().
Referenced by ExecInitPartitionInfo().
Definition at line 1872 of file execPartition.c.
References Assert, AttrMap::attnums, elog, ERROR, fb(), lappend_int(), lfirst_int, AttrMap::maplen, and NIL.
Referenced by adjust_partition_colnos(), and ExecInitPartitionInfo().
|
static |
Definition at line 2122 of file execPartition.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, bms_add_member(), bms_add_members(), bms_copy(), bms_next_member(), CreateExprContext(), CreatePartitionDirectory(), CurrentMemoryContext, ExprContext::ecxt_estate, EState::es_partition_directory, EState::es_query_cxt, EState::es_top_eflags, EXEC_FLAG_EXPLAIN_GENERIC, PartitionedRelPruneInfo::exec_pruning_steps, ExecGetRangeTableRelation(), PartitionedRelPruneInfo::execparamids, fb(), i, PartitionedRelPruneInfo::initial_pruning_steps, InitPartitionPruneContext(), j, lfirst_node, list_length(), PartitionedRelPruneInfo::nparts, PartitionDescData::nparts, OidIsValid, PartitionDescData::oids, palloc(), palloc_array, PartitionDirectoryLookup(), PartitionedRelPruneInfo::present_parts, RelationGetPartitionKey(), and PartitionedRelPruneInfo::rtindex.
Referenced by ExecDoInitialPruning().
|
static |
Definition at line 1767 of file execPartition.c.
References ACL_SELECT, ACLCHECK_OK, appendBinaryStringInfo(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), attnum, buf, check_enable_rls(), fb(), get_partition_col_attnum(), get_partition_col_typid(), get_partition_natts(), getTypeOutputInfo(), GetUserId(), i, initStringInfo(), InvalidAttrNumber, InvalidOid, OidOutputFunctionCall(), pg_attribute_aclcheck(), pg_class_aclcheck(), pg_get_partkeydef_columns(), pg_mbcliplen(), RelationGetPartitionKey(), RelationGetRelid, RLS_ENABLED, val, and values.
Referenced by ExecFindPartition().
| void ExecCleanupTupleRouting | ( | ModifyTableState * | mtstate, |
| PartitionTupleRouting * | proute | ||
| ) |
Definition at line 1389 of file execPartition.c.
References FdwRoutine::EndForeignInsert, ExecCloseIndices(), ExecDropSingleTupleTableSlot(), fb(), i, PartitionTupleRouting::is_borrowed_rel, NoLock, PartitionTupleRouting::num_dispatch, PartitionTupleRouting::num_partitions, PartitionTupleRouting::partition_dispatch_info, PartitionTupleRouting::partitions, ModifyTableState::ps, PartitionDispatchData::reldesc, ResultRelInfo::ri_FdwRoutine, ResultRelInfo::ri_RelationDesc, PlanState::state, table_close(), and PartitionDispatchData::tupslot.
Referenced by CopyFrom(), ExecEndModifyTable(), and finish_edata().
Definition at line 1972 of file execPartition.c.
References bms_add_members(), CreatePartitionPruneState(), EState::es_part_prune_infos, EState::es_part_prune_results, EState::es_part_prune_states, EState::es_unpruned_relids, ExecFindMatchingSubPlans(), fb(), lappend(), and lfirst_node.
Referenced by InitPlan().
| Bitmapset * ExecFindMatchingSubPlans | ( | PartitionPruneState * | prunestate, |
| bool | initial_prune, | ||
| Bitmapset ** | validsubplan_rtis | ||
| ) |
Definition at line 2644 of file execPartition.c.
References Assert, bms_add_members(), bms_copy(), fb(), find_matching_subplans_recurse(), i, MemoryContextReset(), MemoryContextSwitchTo(), and ResetExprContext.
Referenced by choose_next_subplan_for_leader(), choose_next_subplan_for_worker(), choose_next_subplan_locally(), ExecAppendAsyncBegin(), ExecDoInitialPruning(), and ExecMergeAppend().
| ResultRelInfo * ExecFindPartition | ( | ModifyTableState * | mtstate, |
| ResultRelInfo * | rootResultRelInfo, | ||
| PartitionTupleRouting * | proute, | ||
| TupleTableSlot * | slot, | ||
| EState * | estate | ||
| ) |
Definition at line 267 of file execPartition.c.
References Assert, TupleConversionMap::attrMap, PartitionDescData::boundinfo, CHECK_FOR_INTERRUPTS, CheckValidResultRel(), CMD_INSERT, PartitionBoundInfoData::default_index, ereport, errcode(), errdetail(), errmsg(), ERROR, errtable(), ExecBuildSlotPartitionKeyDescription(), ExecClearTuple(), ExecGetRootToChildMap(), ExecInitPartitionDispatchInfo(), ExecInitPartitionInfo(), ExecInitRoutingInfo(), ExecLookupResultRelByOid(), ExecPartitionCheck(), execute_attr_map_slot(), fb(), FormPartitionKeyDatum(), get_partition_for_tuple(), GetPerTupleExprContext, GetPerTupleMemoryContext, PartitionDescData::is_leaf, likely, MemoryContextSwitchTo(), NIL, PartitionTupleRouting::nonleaf_partitions, PartitionDescData::nparts, PartitionTupleRouting::num_dispatch, PartitionTupleRouting::num_partitions, OidIsValid, PartitionDescData::oids, ONCONFLICT_NONE, ModifyTable::onConflictAction, PartitionTupleRouting::partition_dispatch_info, PARTITION_MAX_KEYS, PartitionTupleRouting::partitions, PlanState::plan, ModifyTableState::ps, RelationData::rd_rel, RelationGetRelationName, RelationGetRelid, ResultRelInfo::ri_RelationDesc, ModifyTableState::rootResultRelInfo, and values.
Referenced by apply_handle_tuple_routing(), CopyFrom(), and ExecPrepareTupleRouting().
|
static |
Definition at line 1252 of file execPartition.c.
References Assert, build_attrmap_by_name_if_req(), CreatePartitionDirectory(), EState::es_partition_directory, EState::es_query_cxt, fb(), PartitionDispatchData::indexes, InitResultRelInfo(), IsolationUsesXactSnapshot, PartitionDispatchData::key, PartitionDispatchData::keystate, makeNode, MakeSingleTupleTableSlot(), PartitionTupleRouting::max_dispatch, PartitionTupleRouting::memcxt, MemoryContextSwitchTo(), NIL, PartitionTupleRouting::nonleaf_partitions, PartitionDescData::nparts, PartitionTupleRouting::num_dispatch, palloc(), palloc_array, PartitionDispatchData::partdesc, PartitionTupleRouting::partition_dispatch_info, PartitionTupleRouting::partition_root, PartitionDirectoryLookup(), RelationGetDescr, RelationGetPartitionKey(), RelationGetRelid, PartitionDispatchData::reldesc, repalloc(), RowExclusiveLock, table_open(), TTSOpsVirtual, PartitionDispatchData::tupmap, and PartitionDispatchData::tupslot.
Referenced by ExecFindPartition(), and ExecSetupPartitionTupleRouting().
| PartitionPruneState * ExecInitPartitionExecPruning | ( | PlanState * | planstate, |
| int | n_total_subplans, | ||
| int | part_prune_index, | ||
| Bitmapset * | relids, | ||
| Bitmapset ** | initially_valid_subplans | ||
| ) |
Definition at line 2028 of file execPartition.c.
References Assert, bms_add_range(), bms_equal(), bmsToString(), elog, ERROR, EState::es_part_prune_infos, EState::es_part_prune_results, EState::es_part_prune_states, fb(), InitExecPartitionPruneContexts(), list_nth(), list_nth_node, and PlanState::state.
Referenced by ExecInitAppend(), and ExecInitMergeAppend().
|
static |
Definition at line 563 of file execPartition.c.
References adjust_partition_colnos(), adjust_partition_colnos_using_map(), Assert, build_attrmap_by_name(), castNode, CheckValidResultRel(), CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_NOTHING, CMD_UPDATE, copyObject, elog, ERROR, EState::es_instrument, EState::es_query_cxt, EState::es_tuple_routing_result_relations, EState::es_tupleTable, ExecBuildProjectionInfo(), ExecBuildUpdateProjection(), ExecGetRootToChildMap(), ExecInitMergeTupleSlots(), ExecInitQual(), ExecInitRoutingInfo(), ExecOpenIndices(), fb(), foreach_int, foreach_oid, get_partition_ancestors(), InitResultRelInfo(), INJECTION_POINT, INNER_VAR, IsIndexCompatibleAsArbiter(), lappend(), lappend_int(), lappend_oid(), lfirst, lfirst_node, linitial, linitial_oid, list_free(), list_length(), list_member_oid(), makeNode, map_variable_attnos(), MergeActionState::mas_action, MergeActionState::mas_proj, MergeActionState::mas_whenqual, PartitionTupleRouting::memcxt, MemoryContextSwitchTo(), ModifyTable::mergeActionLists, ModifyTable::mergeJoinConditions, NIL, OnConflictSetState::oc_ProjInfo, OnConflictSetState::oc_ProjSlot, OnConflictSetState::oc_WhereClause, ONCONFLICT_NONE, ONCONFLICT_UPDATE, ModifyTable::onConflictAction, ModifyTable::onConflictCols, ModifyTable::onConflictSet, ModifyTable::onConflictWhere, ModifyTable::operation, PlanState::plan, ModifyTableState::ps, PlanState::ps_ExprContext, PlanState::ps_ResultTupleSlot, RelationData::rd_rel, RelationGetDescr, RelationGetForm, RelationGetRelid, ModifyTable::resultRelations, ModifyTableState::resultRelInfo, ModifyTable::returningLists, ResultRelInfo::ri_onConflict, ResultRelInfo::ri_onConflictArbiterIndexes, ResultRelInfo::ri_RangeTableIndex, ResultRelInfo::ri_RelationDesc, RowExclusiveLock, PlanState::state, table_open(), table_slot_create(), unlikely, and ModifyTable::withCheckOptionLists.
Referenced by ExecFindPartition().
|
static |
Definition at line 1146 of file execPartition.c.
References Assert, EState::es_tupleTable, ExecGetRootToChildMap(), fb(), PartitionTupleRouting::is_borrowed_rel, PartitionTupleRouting::max_partitions, PartitionTupleRouting::memcxt, MemoryContextSwitchTo(), PartitionTupleRouting::num_partitions, palloc_array, PartitionTupleRouting::partitions, repalloc(), and table_slot_create().
Referenced by ExecFindPartition(), and ExecInitPartitionInfo().
| PartitionTupleRouting * ExecSetupPartitionTupleRouting | ( | EState * | estate, |
| Relation | rel | ||
| ) |
Definition at line 220 of file execPartition.c.
References CurrentMemoryContext, ExecInitPartitionDispatchInfo(), fb(), PartitionTupleRouting::memcxt, palloc0_object, PartitionTupleRouting::partition_root, and RelationGetRelid.
Referenced by apply_handle_tuple_routing(), CopyFrom(), ExecCrossPartitionUpdate(), ExecInitMerge(), and ExecInitModifyTable().
|
static |
Definition at line 2717 of file execPartition.c.
References bms_add_member(), bms_next_member(), check_stack_depth(), fb(), find_matching_subplans_recurse(), get_matching_partitions(), and i.
Referenced by ExecFindMatchingSubPlans(), and find_matching_subplans_recurse().
|
static |
Definition at line 1450 of file execPartition.c.
References Assert, elog, ERROR, ExecEvalExprSwitchContext(), ExecPrepareExprList(), fb(), GetPerTupleExprContext, i, PartitionDispatchData::key, PartitionDispatchData::keystate, lfirst, list_head(), lnext(), NIL, PartitionKeyData::partattrs, PartitionKeyData::partexprs, PartitionKeyData::partnatts, slot_getattr(), and values.
Referenced by ExecFindPartition().
|
static |
Definition at line 1547 of file execPartition.c.
References Assert, PartitionDescData::boundinfo, compute_partition_hash_value(), DatumGetInt32(), PartitionBoundInfoData::datums, PartitionBoundInfoData::default_index, elog, equal(), ERROR, fb(), FunctionCall2Coll(), i, PartitionBoundInfoData::indexes, PartitionDispatchData::key, PartitionBoundInfoData::kind, PartitionDescData::last_found_count, PartitionDescData::last_found_datum_index, PartitionDescData::last_found_part_index, PartitionBoundInfoData::ndatums, PartitionBoundInfoData::nindexes, PartitionBoundInfoData::null_index, PartitionDispatchData::partdesc, partition_bound_accepts_nulls, PARTITION_CACHED_FIND_THRESHOLD, partition_list_bsearch(), partition_range_datum_bsearch(), partition_rbound_datum_cmp(), PARTITION_STRATEGY_HASH, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, and values.
Referenced by ExecFindPartition().
|
static |
Definition at line 2487 of file execPartition.c.
References Assert, bms_add_member(), bms_free(), bms_is_empty, bms_next_member(), bms_num_members(), EState::es_partition_directory, fb(), i, InitPartitionPruneContext(), j, NIL, PartitionedRelPruningData::nparts, palloc0_array, PartitionDirectoryLookup(), pfree(), PartitionedRelPruningData::present_parts, and RelationGetPartitionKey().
Referenced by ExecInitPartitionExecPruning().
|
static |
Definition at line 2387 of file execPartition.c.
References Assert, bms_is_member(), PartitionDescData::boundinfo, PartitionPruneContext::boundinfo, CurrentMemoryContext, ExprContext::ecxt_param_list_info, ExecInitExpr(), ExecInitExprWithParams(), PartitionPruneContext::exprcontext, PartitionPruneStepOp::exprs, PartitionPruneContext::exprstates, fb(), IsA, lfirst, list_head(), list_length(), lnext(), PartitionDescData::nparts, PartitionPruneContext::nparts, PartitionPruneStepOp::nullkeys, palloc0_array, PartitionPruneContext::partcollation, PartitionPruneContext::partnatts, PartitionPruneContext::partsupfunc, PartitionPruneContext::planstate, PartitionPruneContext::ppccontext, PruneCxtStateIdx, PartitionPruneStepOp::step, PartitionPruneStep::step_id, PartitionPruneContext::stepcmpfuncs, and PartitionPruneContext::strategy.
Referenced by CreatePartitionPruneState(), and InitExecPartitionPruneContexts().
|
static |
Definition at line 503 of file execPartition.c.
References Assert, fb(), i, IndexInfo::ii_ExclusionOps, IndexInfo::ii_NullsNotDistinct, IndexInfo::ii_NumIndexKeyAttrs, IndexInfo::ii_Unique, list_difference(), NIL, RelationData::rd_indcollation, RelationData::rd_index, RelationData::rd_opfamily, RelationGetIndexExpressions(), and RelationGetIndexPredicate().
Referenced by ExecInitPartitionInfo().