File tree 3 files changed +20
-3
lines changed
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,
1729
1729
errmsg ("range partition key of row contains null" )));
1730
1730
}
1731
1731
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 )
1734
1738
cur_index = partdesc -> boundinfo -> null_index ;
1735
- else
1739
+ else if (! isnull [ 0 ])
1736
1740
{
1737
1741
/* Else bsearch in partdesc->boundinfo */
1738
1742
bool equal = false;
Original file line number Diff line number Diff line change @@ -365,6 +365,13 @@ DETAIL: Failing row contains (1, 2).
365
365
insert into mlparted1 (a, b) values (2, 3);
366
366
ERROR: new row for relation "mlparted11" violates partition constraint
367
367
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;
368
375
-- check that RETURNING works correctly with tuple-routing
369
376
alter table mlparted drop constraint check_b;
370
377
create 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);
226
226
-- selected by tuple-routing
227
227
insert into mlparted1 (a, b) values (2 , 3 );
228
228
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
+
229
235
-- check that RETURNING works correctly with tuple-routing
230
236
alter table mlparted drop constraint check_b;
231
237
create table mlparted12 partition of mlparted1 for values from (5 ) to (10 );
You can’t perform that action at this time.
0 commit comments