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

Commit7ecb714

Browse files
committed
Fix improper NULL handling in list partitioning code.
The previous logic was wrong when the value was NULL but there wasno partition for NULL.Amit Langote, reviewed by Jeevan LadheDiscussion:http://postgr.es/m/d64f8498-70eb-3c88-b56d-c54fd3b0500f@lab.ntt.co.jp
1 parent8355a01 commit7ecb714

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

‎src/backend/catalog/partition.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,10 +1729,14 @@ get_partition_for_tuple(PartitionDispatch *pd,
17291729
errmsg("range partition key of row contains null")));
17301730
}
17311731

1732-
if (partdesc->boundinfo->has_null&&isnull[0])
1733-
/* Tuple maps to the null-accepting list partition */
1732+
/*
1733+
* A null partition key is only acceptable if null-accepting list
1734+
* partition exists.
1735+
*/
1736+
cur_index=-1;
1737+
if (isnull[0]&&partdesc->boundinfo->has_null)
17341738
cur_index=partdesc->boundinfo->null_index;
1735-
else
1739+
elseif (!isnull[0])
17361740
{
17371741
/* Else bsearch in partdesc->boundinfo */
17381742
boolequal= false;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,13 @@ DETAIL: Failing row contains (1, 2).
365365
insert into mlparted1 (a, b) values (2, 3);
366366
ERROR: new row for relation "mlparted11" violates partition constraint
367367
DETAIL: Failing row contains (3, 2).
368+
-- check routing error through a list partitioned table when the key is null
369+
create table lparted_nonullpart (a int, b char) partition by list (b);
370+
create table lparted_nonullpart_a partition of lparted_nonullpart for values in ('a');
371+
insert into lparted_nonullpart values (1);
372+
ERROR: no partition of relation "lparted_nonullpart" found for row
373+
DETAIL: Partition key of the failing row contains (b) = (null).
374+
drop table lparted_nonullpart;
368375
-- check that RETURNING works correctly with tuple-routing
369376
alter table mlparted drop constraint check_b;
370377
create table mlparted12 partition of mlparted1 for values from (5) to (10);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ insert into mlparted values (1, 2);
226226
-- selected by tuple-routing
227227
insert into mlparted1 (a, b)values (2,3);
228228

229+
-- check routing error through a list partitioned table when the key is null
230+
createtablelparted_nonullpart (aint, bchar) partition by list (b);
231+
createtablelparted_nonullpart_a partition of lparted_nonullpart forvaluesin ('a');
232+
insert into lparted_nonullpartvalues (1);
233+
droptable lparted_nonullpart;
234+
229235
-- check that RETURNING works correctly with tuple-routing
230236
altertable mlparted dropconstraint check_b;
231237
createtablemlparted12 partition of mlparted1 forvaluesfrom (5) to (10);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp