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

Commit2d7950f

Browse files
committed
If a range-partitioned table has no default partition, reject null keys.
Commit4e5fe9a introduced thisproblem. Also add a test so it doesn't get broken again.Report by Rushabh Lathia. Fix by Amit Langote. Reviewed by RushabhLathia and Amul Sul. Tweaked by me.Discussion:http://postgr.es/m/CAGPqQf0Y1iJyk4QJBdMf=pS9i6Q0JUMM_h5-qkR3OMJ-e04PyA@mail.gmail.com
1 parent62546b4 commit2d7950f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

‎src/backend/catalog/partition.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,11 +2553,10 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
25532553
*/
25542554
for (i=0;i<key->partnatts;i++)
25552555
{
2556-
if (isnull[i]&&
2557-
partition_bound_has_default(partdesc->boundinfo))
2556+
if (isnull[i])
25582557
{
25592558
range_partkey_has_null= true;
2560-
part_index=partdesc->boundinfo->default_index;
2559+
break;
25612560
}
25622561
}
25632562

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,10 @@ create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue)
659659
create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10);
660660
create table mcrparted4 partition of mcrparted for values from (21, minvalue, minvalue) to (30, 20, maxvalue);
661661
create table mcrparted5 partition of mcrparted for values from (30, 21, 20) to (maxvalue, maxvalue, maxvalue);
662+
-- null not allowed in range partition
663+
insert into mcrparted values (null, null, null);
664+
ERROR: no partition of relation "mcrparted" found for row
665+
DETAIL: Partition key of the failing row contains (a, abs(b), c) = (null, null, null).
662666
-- routed to mcrparted0
663667
insert into mcrparted values (0, 1, 1);
664668
insert into mcrparted0 values (0, 1, 1);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20
421421
createtablemcrparted4 partition of mcrparted forvaluesfrom (21, minvalue, minvalue) to (30,20, maxvalue);
422422
createtablemcrparted5 partition of mcrparted forvaluesfrom (30,21,20) to (maxvalue, maxvalue, maxvalue);
423423

424+
-- null not allowed in range partition
425+
insert into mcrpartedvalues (null,null,null);
426+
424427
-- routed to mcrparted0
425428
insert into mcrpartedvalues (0,1,1);
426429
insert into mcrparted0values (0,1,1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp