Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit945f71d

Browse files
committed
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
1 parentd6ab720 commit945f71d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

‎src/backend/executor/execPartition.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate,
8787
num_update_rri=list_length(node->plans);
8888
proute->subplan_partition_offsets=
8989
palloc(num_update_rri*sizeof(int));
90+
proute->num_subplan_partition_offsets=num_update_rri;
9091

9192
/*
9293
* We need an additional tuple slot for storing transient tuples that
@@ -481,6 +482,7 @@ ExecCleanupTupleRouting(PartitionTupleRouting *proute)
481482
* result rels are present in the UPDATE subplans.
482483
*/
483484
if (proute->subplan_partition_offsets&&
485+
subplan_index<proute->num_subplan_partition_offsets&&
484486
proute->subplan_partition_offsets[subplan_index]==i)
485487
{
486488
subplan_index++;

‎src/backend/executor/nodeModifyTable.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,8 @@ tupconv_map_for_subplan(ModifyTableState *mtstate, int whichplan)
18121812
* If subplan-indexed array is NULL, things should have been arranged
18131813
* to convert the subplan index to partition index.
18141814
*/
1815-
Assert(proute&&proute->subplan_partition_offsets!=NULL);
1815+
Assert(proute&&proute->subplan_partition_offsets!=NULL&&
1816+
whichplan<proute->num_subplan_partition_offsets);
18161817

18171818
leaf_index=proute->subplan_partition_offsets[whichplan];
18181819

‎src/include/executor/execPartition.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ typedef struct PartitionDispatchData *PartitionDispatch;
8080
* subplan_partition_offsetsInteger array ordered by UPDATE subplans. Each
8181
*element of this array has the index into the
8282
*corresponding partition in partitions array.
83+
* num_subplan_partition_offsets Length of 'subplan_partition_offsets' array
8384
* partition_tuple_slotTupleTableSlot to be used to manipulate any
8485
*given leaf partition's rowtype after that
8586
*partition is chosen for insertion by
@@ -96,6 +97,7 @@ typedef struct PartitionTupleRouting
9697
TupleConversionMap**child_parent_tupconv_maps;
9798
bool*child_parent_map_not_required;
9899
int*subplan_partition_offsets;
100+
intnum_subplan_partition_offsets;
99101
TupleTableSlot*partition_tuple_slot;
100102
TupleTableSlot*root_tuple_slot;
101103
}PartitionTupleRouting;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp