Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
execPartition.h132 linesDownload Raw Back to executor
1/*--------------------------------------------------------------------2 * execPartition.h3 *		POSTGRES partitioning executor interface4 *5 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group6 * Portions Copyright (c) 1994, Regents of the University of California7 *8 * IDENTIFICATION9 *		src/include/executor/execPartition.h10 *--------------------------------------------------------------------11 */12 13#ifndef EXECPARTITION_H14#define EXECPARTITION_H15 16#include "nodes/execnodes.h"17#include "nodes/parsenodes.h"18#include "nodes/plannodes.h"19#include "partitioning/partprune.h"20 21/* See execPartition.c for the definitions. */22typedef struct PartitionDispatchData *PartitionDispatch;23typedef struct PartitionTupleRouting PartitionTupleRouting;24 25extern PartitionTupleRouting *ExecSetupPartitionTupleRouting(EState *estate,26															 Relation rel);27extern ResultRelInfo *ExecFindPartition(ModifyTableState *mtstate,28										ResultRelInfo *rootResultRelInfo,29										PartitionTupleRouting *proute,30										TupleTableSlot *slot,31										EState *estate);32extern void ExecCleanupTupleRouting(ModifyTableState *mtstate,33									PartitionTupleRouting *proute);34 35 36/*37 * PartitionedRelPruningData - Per-partitioned-table data for run-time pruning38 * of partitions.  For a multilevel partitioned table, we have one of these39 * for the topmost partition plus one for each non-leaf child partition.40 *41 * subplan_map[] and subpart_map[] have the same definitions as in42 * PartitionedRelPruneInfo (see plannodes.h); though note that here,43 * subpart_map contains indexes into PartitionPruningData.partrelprunedata[].44 *45 * nparts						Length of subplan_map[] and subpart_map[].46 * subplan_map					Subplan index by partition index, or -1.47 * subpart_map					Subpart index by partition index, or -1.48 * present_parts				A Bitmapset of the partition indexes that we49 *								have subplans or subparts for.50 * initial_pruning_steps		List of PartitionPruneSteps used to51 *								perform executor startup pruning.52 * exec_pruning_steps			List of PartitionPruneSteps used to53 *								perform per-scan pruning.54 * initial_context				If initial_pruning_steps isn't NIL, contains55 *								the details needed to execute those steps.56 * exec_context					If exec_pruning_steps isn't NIL, contains57 *								the details needed to execute those steps.58 */59typedef struct PartitionedRelPruningData60{61	int			nparts;62	int		   *subplan_map;63	int		   *subpart_map;64	Bitmapset  *present_parts;65	List	   *initial_pruning_steps;66	List	   *exec_pruning_steps;67	PartitionPruneContext initial_context;68	PartitionPruneContext exec_context;69} PartitionedRelPruningData;70 71/*72 * PartitionPruningData - Holds all the run-time pruning information for73 * a single partitioning hierarchy containing one or more partitions.74 * partrelprunedata[] is an array ordered such that parents appear before75 * their children; in particular, the first entry is the topmost partition,76 * which was actually named in the SQL query.77 */78typedef struct PartitionPruningData79{80	int			num_partrelprunedata;	/* number of array entries */81	PartitionedRelPruningData partrelprunedata[FLEXIBLE_ARRAY_MEMBER];82} PartitionPruningData;83 84/*85 * PartitionPruneState - State object required for plan nodes to perform86 * run-time partition pruning.87 *88 * This struct can be attached to plan types which support arbitrary Lists of89 * subplans containing partitions, to allow subplans to be eliminated due to90 * the clauses being unable to match to any tuple that the subplan could91 * possibly produce.92 *93 * execparamids			Contains paramids of PARAM_EXEC Params found within94 *						any of the partprunedata structs.  Pruning must be95 *						done again each time the value of one of these96 *						parameters changes.97 * other_subplans		Contains indexes of subplans that don't belong to any98 *						"partprunedata", e.g UNION ALL children that are not99 *						partitioned tables, or a partitioned table that the100 *						planner deemed run-time pruning to be useless for.101 *						These must not be pruned.102 * prune_context		A short-lived memory context in which to execute the103 *						partition pruning functions.104 * do_initial_prune		true if pruning should be performed during executor105 *						startup (at any hierarchy level).106 * do_exec_prune		true if pruning should be performed during107 *						executor run (at any hierarchy level).108 * num_partprunedata	Number of items in "partprunedata" array.109 * partprunedata		Array of PartitionPruningData pointers for the plan's110 *						partitioned relation(s), one for each partitioning111 *						hierarchy that requires run-time pruning.112 */113typedef struct PartitionPruneState114{115	Bitmapset  *execparamids;116	Bitmapset  *other_subplans;117	MemoryContext prune_context;118	bool		do_initial_prune;119	bool		do_exec_prune;120	int			num_partprunedata;121	PartitionPruningData *partprunedata[FLEXIBLE_ARRAY_MEMBER];122} PartitionPruneState;123 124extern PartitionPruneState *ExecInitPartitionPruning(PlanState *planstate,125													 int n_total_subplans,126													 PartitionPruneInfo *pruneinfo,127													 Bitmapset **initially_valid_subplans);128extern Bitmapset *ExecFindMatchingSubPlans(PartitionPruneState *prunestate,129										   bool initial_prune);130 131#endif							/* EXECPARTITION_H */132 
codekingpro/portable-devtools · Team Ai