diff options
author | Robert Haas <rhaas@postgresql.org> | 2018-01-24 16:34:51 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2018-01-24 16:34:51 -0500 |
commit | 945f71db845262e7491b5fe4403b01147027576b (patch) | |
tree | 341d3e9391c0182f588718c66881aa680e71f46f /src/backend | |
parent | d6ab7203607a3f43fe41d384f46c15bdac68d745 (diff) | |
download | postgresql-945f71db845262e7491b5fe4403b01147027576b.tar.gz postgresql-945f71db845262e7491b5fe4403b01147027576b.zip |
Avoid referencing off the end of subplan_partition_offsets.
Report by buildfarm member skink and Tom Lane. Analysis by me.
Patch by Amit Khandekar.
Discussion: http://postgr.es/m/CAJ3gD9fVA1iXQYhfqHP5n_TEd4U9=V8TL_cc-oKRnRmxgdvJrQ@mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/executor/execPartition.c | 2 | ||||
-rw-r--r-- | src/backend/executor/nodeModifyTable.c | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 89b7bb4c608..106a96d9103 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -87,6 +87,7 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, num_update_rri = list_length(node->plans); proute->subplan_partition_offsets = palloc(num_update_rri * sizeof(int)); + proute->num_subplan_partition_offsets = num_update_rri; /* * We need an additional tuple slot for storing transient tuples that @@ -481,6 +482,7 @@ ExecCleanupTupleRouting(PartitionTupleRouting *proute) * result rels are present in the UPDATE subplans. */ if (proute->subplan_partition_offsets && + subplan_index < proute->num_subplan_partition_offsets && proute->subplan_partition_offsets[subplan_index] == i) { subplan_index++; diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 6c2f8d4ec03..828e1b0015b 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -1812,7 +1812,8 @@ tupconv_map_for_subplan(ModifyTableState *mtstate, int whichplan) * If subplan-indexed array is NULL, things should have been arranged * to convert the subplan index to partition index. */ - Assert(proute && proute->subplan_partition_offsets != NULL); + Assert(proute && proute->subplan_partition_offsets != NULL && + whichplan < proute->num_subplan_partition_offsets); leaf_index = proute->subplan_partition_offsets[whichplan]; |