aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/outfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-08-01 19:42:46 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-08-01 19:42:52 -0400
commit1c2cb2744bf3d8ad751cd5cf3b347f10f48492b3 (patch)
tree78cbab7db4dacbac9f47b4c78974ba3c8f6c9184 /src/backend/nodes/outfuncs.c
parentc40489e449ea08e154cd62fa055785873f7bdac8 (diff)
downloadpostgresql-1c2cb2744bf3d8ad751cd5cf3b347f10f48492b3.tar.gz
postgresql-1c2cb2744bf3d8ad751cd5cf3b347f10f48492b3.zip
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/backend/nodes/outfuncs.c')
-rw-r--r--src/backend/nodes/outfuncs.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index a6454ce28b3..6269f474d2c 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -402,7 +402,7 @@ _outAppend(StringInfo str, const Append *node)
WRITE_NODE_FIELD(appendplans);
WRITE_INT_FIELD(first_partial_plan);
WRITE_NODE_FIELD(partitioned_rels);
- WRITE_NODE_FIELD(part_prune_infos);
+ WRITE_NODE_FIELD(part_prune_info);
}
static void
@@ -435,7 +435,7 @@ _outMergeAppend(StringInfo str, const MergeAppend *node)
for (i = 0; i < node->numCols; i++)
appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
- WRITE_NODE_FIELD(part_prune_infos);
+ WRITE_NODE_FIELD(part_prune_info);
}
static void
@@ -1015,9 +1015,18 @@ _outPlanRowMark(StringInfo str, const PlanRowMark *node)
static void
_outPartitionPruneInfo(StringInfo str, const PartitionPruneInfo *node)
{
+ WRITE_NODE_TYPE("PARTITIONPRUNEINFO");
+
+ WRITE_NODE_FIELD(prune_infos);
+ WRITE_BITMAPSET_FIELD(other_subplans);
+}
+
+static void
+_outPartitionedRelPruneInfo(StringInfo str, const PartitionedRelPruneInfo *node)
+{
int i;
- WRITE_NODE_TYPE("PARTITIONPRUNEINFO");
+ WRITE_NODE_TYPE("PARTITIONEDRELPRUNEINFO");
WRITE_OID_FIELD(reloid);
WRITE_NODE_FIELD(pruning_steps);
@@ -3831,6 +3840,9 @@ outNode(StringInfo str, const void *obj)
case T_PartitionPruneInfo:
_outPartitionPruneInfo(str, obj);
break;
+ case T_PartitionedRelPruneInfo:
+ _outPartitionedRelPruneInfo(str, obj);
+ break;
case T_PartitionPruneStepOp:
_outPartitionPruneStepOp(str, obj);
break;