diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-01-20 15:47:31 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-01-20 15:49:38 -0500 |
commit | 6546ffb35db78365d9f0011d75d16625e6040437 (patch) | |
tree | 1838f1d18bc83b64c1c89f70398a16d9177cacc3 /src | |
parent | 50cf1c80e6be80cc620749824fe9e3cd7f6c118e (diff) | |
download | postgresql-6546ffb35db78365d9f0011d75d16625e6040437.tar.gz postgresql-6546ffb35db78365d9f0011d75d16625e6040437.zip |
Fix comparison logic in partition_bounds_equal for non-finite bounds.
If either bound is infinite, then we shouldn't even try to perform a
comparison of the values themselves. Rearrange the logic so that
we don't.
Per buildfarm member skink and Tom Lane.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/catalog/partition.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index 3f8a950f37d..ad95b1bc55d 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -624,16 +624,28 @@ partition_bounds_equal(PartitionKey key, { int32 cmpval; + /* For range partitions, the bounds might not be finite. */ + if (b1->content != NULL) + { + /* + * A finite bound always differs from an infinite bound, and + * different kinds of infinities differ from each other. + */ + if (b1->content[i][j] != b2->content[i][j]) + return false; + + /* Non-finite bounds are equal without further examination. */ + if (b1->content[i][j] != RANGE_DATUM_FINITE) + continue; + } + + /* Compare the actual values */ cmpval = DatumGetInt32(FunctionCall2Coll(&key->partsupfunc[j], key->partcollation[j], b1->datums[i][j], b2->datums[i][j])); if (cmpval != 0) return false; - - /* Range partitions can have infinite datums */ - if (b1->content != NULL && b1->content[i][j] != b2->content[i][j]) - return false; } if (b1->indexes[i] != b2->indexes[i]) |