summaryrefslogtreecommitdiff
path: root/src/include/partitioning
diff options
context:
space:
mode:
authorTom Lane2018-08-01 23:42:46 +0000
committerTom Lane2018-08-01 23:42:52 +0000
commit1c2cb2744bf3d8ad751cd5cf3b347f10f48492b3 (patch)
tree78cbab7db4dacbac9f47b4c78974ba3c8f6c9184 /src/include/partitioning
parentc40489e449ea08e154cd62fa055785873f7bdac8 (diff)
Fix run-time partition pruning for appends with multiple source rels.
The previous coding here supposed that if run-time partitioning applied to a particular Append/MergeAppend plan, then all child plans of that node must be members of a single partitioning hierarchy. This is totally wrong, since an Append could be formed from a UNION ALL: we could have multiple hierarchies sharing the same Append, or child plans that aren't part of any hierarchy. To fix, restructure the related plan-time and execution-time data structures so that we can have a separate list or array for each partitioning hierarchy. Also track subplans that are not part of any hierarchy, and make sure they don't get pruned. Per reports from Phil Florent and others. Back-patch to v11, since the bug originated there. David Rowley, with a lot of cosmetic adjustments by me; thanks also to Amit Langote for review. Discussion: https://postgr.es/m/HE1PR03MB17068BB27404C90B5B788BCABA7B0@HE1PR03MB1706.eurprd03.prod.outlook.com
Diffstat (limited to 'src/include/partitioning')
-rw-r--r--src/include/partitioning/partprune.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/include/partitioning/partprune.h b/src/include/partitioning/partprune.h
index 9944d2832f4..b95c346bab0 100644
--- a/src/include/partitioning/partprune.h
+++ b/src/include/partitioning/partprune.h
@@ -74,9 +74,11 @@ typedef struct PartitionPruneContext
#define PruneCxtStateIdx(partnatts, step_id, keyno) \
((partnatts) * (step_id) + (keyno))
-extern List *make_partition_pruneinfo(PlannerInfo *root,
+extern PartitionPruneInfo *make_partition_pruneinfo(PlannerInfo *root,
+ RelOptInfo *parentrel,
+ List *subpaths,
List *partitioned_rels,
- List *subpaths, List *prunequal);
+ List *prunequal);
extern Relids prune_append_rel_partitions(RelOptInfo *rel);
extern Bitmapset *get_matching_partitions(PartitionPruneContext *context,
List *pruning_steps);