mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
If a range-partitioned table has no default partition, reject null keys.
Commit 4e5fe9ad19
introduced this
problem. Also add a test so it doesn't get broken again.
Report by Rushabh Lathia. Fix by Amit Langote. Reviewed by Rushabh
Lathia and Amul Sul. Tweaked by me.
Discussion: http://postgr.es/m/CAGPqQf0Y1iJyk4QJBdMf=pS9i6Q0JUMM_h5-qkR3OMJ-e04PyA@mail.gmail.com
This commit is contained in:
parent
62546b4357
commit
2d7950f222
@ -2553,11 +2553,10 @@ get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
|
||||
*/
|
||||
for (i = 0; i < key->partnatts; i++)
|
||||
{
|
||||
if (isnull[i] &&
|
||||
partition_bound_has_default(partdesc->boundinfo))
|
||||
if (isnull[i])
|
||||
{
|
||||
range_partkey_has_null = true;
|
||||
part_index = partdesc->boundinfo->default_index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,6 +659,10 @@ create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue)
|
||||
create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10);
|
||||
create table mcrparted4 partition of mcrparted for values from (21, minvalue, minvalue) to (30, 20, maxvalue);
|
||||
create table mcrparted5 partition of mcrparted for values from (30, 21, 20) to (maxvalue, maxvalue, maxvalue);
|
||||
-- null not allowed in range partition
|
||||
insert into mcrparted values (null, null, null);
|
||||
ERROR: no partition of relation "mcrparted" found for row
|
||||
DETAIL: Partition key of the failing row contains (a, abs(b), c) = (null, null, null).
|
||||
-- routed to mcrparted0
|
||||
insert into mcrparted values (0, 1, 1);
|
||||
insert into mcrparted0 values (0, 1, 1);
|
||||
|
@ -421,6 +421,9 @@ create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20
|
||||
create table mcrparted4 partition of mcrparted for values from (21, minvalue, minvalue) to (30, 20, maxvalue);
|
||||
create table mcrparted5 partition of mcrparted for values from (30, 21, 20) to (maxvalue, maxvalue, maxvalue);
|
||||
|
||||
-- null not allowed in range partition
|
||||
insert into mcrparted values (null, null, null);
|
||||
|
||||
-- routed to mcrparted0
|
||||
insert into mcrparted values (0, 1, 1);
|
||||
insert into mcrparted0 values (0, 1, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user