diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-03-27 10:51:46 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-03-27 10:51:46 -0400 |
commit | 7ecb7143589f38d679bb566311dfa9be1a650fd5 (patch) | |
tree | 36df1817e21e8319094dfd02312998d695d3cbb4 /src/backend | |
parent | 8355a011a0124bdf7ccbada206a967d427039553 (diff) | |
download | postgresql-7ecb7143589f38d679bb566311dfa9be1a650fd5.tar.gz postgresql-7ecb7143589f38d679bb566311dfa9be1a650fd5.zip |
Fix improper NULL handling in list partitioning code.
The previous logic was wrong when the value was NULL but there was
no partition for NULL.
Amit Langote, reviewed by Jeevan Ladhe
Discussion: http://postgr.es/m/d64f8498-70eb-3c88-b56d-c54fd3b0500f@lab.ntt.co.jp
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/catalog/partition.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index b434c384c97..f9fd1366e26 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -1729,10 +1729,14 @@ get_partition_for_tuple(PartitionDispatch *pd, errmsg("range partition key of row contains null"))); } - if (partdesc->boundinfo->has_null && isnull[0]) - /* Tuple maps to the null-accepting list partition */ + /* + * A null partition key is only acceptable if null-accepting list + * partition exists. + */ + cur_index = -1; + if (isnull[0] && partdesc->boundinfo->has_null) cur_index = partdesc->boundinfo->null_index; - else + else if (!isnull[0]) { /* Else bsearch in partdesc->boundinfo */ bool equal = false; |