File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff 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+ else if (! isnull [ 0 ])
17361740 {
17371741 /* Else bsearch in partdesc->boundinfo */
17381742 bool equal = false;
Original file line number Diff line number Diff line change @@ -365,6 +365,13 @@ DETAIL: Failing row contains (1, 2).
365365insert into mlparted1 (a, b) values (2, 3);
366366ERROR: new row for relation "mlparted11" violates partition constraint
367367DETAIL: 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
369376alter table mlparted drop constraint check_b;
370377create table mlparted12 partition of mlparted1 for values from (5) to (10);
Original file line number Diff line number Diff line change @@ -226,6 +226,12 @@ insert into mlparted values (1, 2);
226226-- selected by tuple-routing
227227insert into mlparted1 (a, b) values (2 , 3 );
228228
229+ -- check routing error through a list partitioned table when the key is null
230+ create table lparted_nonullpart (a int , b char ) partition by list (b);
231+ create table lparted_nonullpart_a partition of lparted_nonullpart for values in (' a' );
232+ insert into lparted_nonullpart values (1 );
233+ drop table lparted_nonullpart;
234+
229235-- check that RETURNING works correctly with tuple-routing
230236alter table mlparted drop constraint check_b;
231237create table mlparted12 partition of mlparted1 for values from (5 ) to (10 );
You can’t perform that action at this time.
0 commit comments