gooderp18绿色标准版
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

157 rindas
5.9KB

  1. /*--------------------------------------------------------------------
  2. * execPartition.h
  3. * POSTGRES partitioning executor interface
  4. *
  5. * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  6. * Portions Copyright (c) 1994, Regents of the University of California
  7. *
  8. * IDENTIFICATION
  9. * src/include/executor/execPartition.h
  10. *--------------------------------------------------------------------
  11. */
  12. #ifndef EXECPARTITION_H
  13. #define EXECPARTITION_H
  14. #include "nodes/execnodes.h"
  15. #include "nodes/parsenodes.h"
  16. #include "nodes/plannodes.h"
  17. #include "partitioning/partprune.h"
  18. /* See execPartition.c for the definitions. */
  19. typedef struct PartitionDispatchData *PartitionDispatch;
  20. typedef struct PartitionTupleRouting PartitionTupleRouting;
  21. /*
  22. * PartitionRoutingInfo
  23. *
  24. * Additional result relation information specific to routing tuples to a
  25. * table partition.
  26. */
  27. typedef struct PartitionRoutingInfo
  28. {
  29. /*
  30. * Map for converting tuples in root partitioned table format into
  31. * partition format, or NULL if no conversion is required.
  32. */
  33. TupleConversionMap *pi_RootToPartitionMap;
  34. /*
  35. * Map for converting tuples in partition format into the root partitioned
  36. * table format, or NULL if no conversion is required.
  37. */
  38. TupleConversionMap *pi_PartitionToRootMap;
  39. /*
  40. * Slot to store tuples in partition format, or NULL when no translation
  41. * is required between root and partition.
  42. */
  43. TupleTableSlot *pi_PartitionTupleSlot;
  44. } PartitionRoutingInfo;
  45. /*
  46. * PartitionedRelPruningData - Per-partitioned-table data for run-time pruning
  47. * of partitions. For a multilevel partitioned table, we have one of these
  48. * for the topmost partition plus one for each non-leaf child partition.
  49. *
  50. * subplan_map[] and subpart_map[] have the same definitions as in
  51. * PartitionedRelPruneInfo (see plannodes.h); though note that here,
  52. * subpart_map contains indexes into PartitionPruningData.partrelprunedata[].
  53. *
  54. * nparts Length of subplan_map[] and subpart_map[].
  55. * subplan_map Subplan index by partition index, or -1.
  56. * subpart_map Subpart index by partition index, or -1.
  57. * present_parts A Bitmapset of the partition indexes that we
  58. * have subplans or subparts for.
  59. * initial_pruning_steps List of PartitionPruneSteps used to
  60. * perform executor startup pruning.
  61. * exec_pruning_steps List of PartitionPruneSteps used to
  62. * perform per-scan pruning.
  63. * initial_context If initial_pruning_steps isn't NIL, contains
  64. * the details needed to execute those steps.
  65. * exec_context If exec_pruning_steps isn't NIL, contains
  66. * the details needed to execute those steps.
  67. */
  68. typedef struct PartitionedRelPruningData
  69. {
  70. int nparts;
  71. int *subplan_map;
  72. int *subpart_map;
  73. Bitmapset *present_parts;
  74. List *initial_pruning_steps;
  75. List *exec_pruning_steps;
  76. PartitionPruneContext initial_context;
  77. PartitionPruneContext exec_context;
  78. } PartitionedRelPruningData;
  79. /*
  80. * PartitionPruningData - Holds all the run-time pruning information for
  81. * a single partitioning hierarchy containing one or more partitions.
  82. * partrelprunedata[] is an array ordered such that parents appear before
  83. * their children; in particular, the first entry is the topmost partition,
  84. * which was actually named in the SQL query.
  85. */
  86. typedef struct PartitionPruningData
  87. {
  88. int num_partrelprunedata; /* number of array entries */
  89. PartitionedRelPruningData partrelprunedata[FLEXIBLE_ARRAY_MEMBER];
  90. } PartitionPruningData;
  91. /*
  92. * PartitionPruneState - State object required for plan nodes to perform
  93. * run-time partition pruning.
  94. *
  95. * This struct can be attached to plan types which support arbitrary Lists of
  96. * subplans containing partitions, to allow subplans to be eliminated due to
  97. * the clauses being unable to match to any tuple that the subplan could
  98. * possibly produce.
  99. *
  100. * execparamids Contains paramids of PARAM_EXEC Params found within
  101. * any of the partprunedata structs. Pruning must be
  102. * done again each time the value of one of these
  103. * parameters changes.
  104. * other_subplans Contains indexes of subplans that don't belong to any
  105. * "partprunedata", e.g UNION ALL children that are not
  106. * partitioned tables, or a partitioned table that the
  107. * planner deemed run-time pruning to be useless for.
  108. * These must not be pruned.
  109. * prune_context A short-lived memory context in which to execute the
  110. * partition pruning functions.
  111. * do_initial_prune true if pruning should be performed during executor
  112. * startup (at any hierarchy level).
  113. * do_exec_prune true if pruning should be performed during
  114. * executor run (at any hierarchy level).
  115. * num_partprunedata Number of items in "partprunedata" array.
  116. * partprunedata Array of PartitionPruningData pointers for the plan's
  117. * partitioned relation(s), one for each partitioning
  118. * hierarchy that requires run-time pruning.
  119. */
  120. typedef struct PartitionPruneState
  121. {
  122. Bitmapset *execparamids;
  123. Bitmapset *other_subplans;
  124. MemoryContext prune_context;
  125. bool do_initial_prune;
  126. bool do_exec_prune;
  127. int num_partprunedata;
  128. PartitionPruningData *partprunedata[FLEXIBLE_ARRAY_MEMBER];
  129. } PartitionPruneState;
  130. extern PartitionTupleRouting *ExecSetupPartitionTupleRouting(EState *estate,
  131. ModifyTableState *mtstate,
  132. Relation rel);
  133. extern ResultRelInfo *ExecFindPartition(ModifyTableState *mtstate,
  134. ResultRelInfo *rootResultRelInfo,
  135. PartitionTupleRouting *proute,
  136. TupleTableSlot *slot,
  137. EState *estate);
  138. extern void ExecCleanupTupleRouting(ModifyTableState *mtstate,
  139. PartitionTupleRouting *proute);
  140. extern PartitionPruneState *ExecCreatePartitionPruneState(PlanState *planstate,
  141. PartitionPruneInfo *partitionpruneinfo);
  142. extern Bitmapset *ExecFindMatchingSubPlans(PartitionPruneState *prunestate);
  143. extern Bitmapset *ExecFindInitialMatchingSubPlans(PartitionPruneState *prunestate,
  144. int nsubplans);
  145. #endif /* EXECPARTITION_H */
上海开阖软件有限公司 沪ICP备12045867号-1