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

Commit59c8078

Browse files
committed
Fix uninitialized memory reference.
Without this, when partdesc->nparts == 0, we end up callingExecBuildSlotPartitionKeyDescription without initializing valuesand isnull.Reported by Coverity via Michael Paquier. Patch by Michael Paquier,reviewed and revised by Amit Langote.Discussion:http://postgr.es/m/CAB7nPqQ3mwkdMoPY-ocgTpPnjd8TKOadMxdTtMLvEzF8480Zfg@mail.gmail.com
1 parent86ab28f commit59c8078

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

‎src/backend/executor/execPartition.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
206206
slot=myslot;
207207
}
208208

209-
/* Quick exit */
210-
if (partdesc->nparts==0)
211-
{
212-
result=-1;
213-
break;
214-
}
215-
216209
/*
217210
* Extract partition key from tuple. Expression evaluation machinery
218211
* that FormPartitionKeyDatum() invokes expects ecxt_scantuple to
@@ -223,6 +216,17 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
223216
*/
224217
ecxt->ecxt_scantuple=slot;
225218
FormPartitionKeyDatum(parent,slot,estate,values,isnull);
219+
220+
/*
221+
* Nothing for get_partition_for_tuple() to do if there are no
222+
* partitions to begin with.
223+
*/
224+
if (partdesc->nparts==0)
225+
{
226+
result=-1;
227+
break;
228+
}
229+
226230
cur_index=get_partition_for_tuple(rel,values,isnull);
227231

228232
/*

‎src/test/regress/expected/insert.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ create table range_parted (
165165
a text,
166166
b int
167167
) partition by range (a, (b+0));
168+
-- no partitions, so fail
169+
insert into range_parted values ('a', 11);
170+
ERROR: no partition of relation "range_parted" found for row
171+
DETAIL: Partition key of the failing row contains (a, (b + 0)) = (a, 11).
168172
create table part1 partition of range_parted for values from ('a', 1) to ('a', 10);
169173
create table part2 partition of range_parted for values from ('a', 10) to ('a', 20);
170174
create table part3 partition of range_parted for values from ('b', 1) to ('b', 10);

‎src/test/regress/sql/insert.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ create table range_parted (
9090
atext,
9191
bint
9292
) partition by range (a, (b+0));
93+
94+
-- no partitions, so fail
95+
insert into range_partedvalues ('a',11);
96+
9397
createtablepart1 partition of range_parted forvaluesfrom ('a',1) to ('a',10);
9498
createtablepart2 partition of range_parted forvaluesfrom ('a',10) to ('a',20);
9599
createtablepart3 partition of range_parted forvaluesfrom ('b',1) to ('b',10);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp