Skip to content

Commit 6546ffb

Browse files
committed
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.
1 parent 50cf1c8 commit 6546ffb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/backend/catalog/partition.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -624,16 +624,28 @@ partition_bounds_equal(PartitionKey key,
624624
{
625625
int32 cmpval;
626626

627+
/* For range partitions, the bounds might not be finite. */
628+
if (b1->content != NULL)
629+
{
630+
/*
631+
* A finite bound always differs from an infinite bound, and
632+
* different kinds of infinities differ from each other.
633+
*/
634+
if (b1->content[i][j] != b2->content[i][j])
635+
return false;
636+
637+
/* Non-finite bounds are equal without further examination. */
638+
if (b1->content[i][j] != RANGE_DATUM_FINITE)
639+
continue;
640+
}
641+
642+
/* Compare the actual values */
627643
cmpval = DatumGetInt32(FunctionCall2Coll(&key->partsupfunc[j],
628644
key->partcollation[j],
629645
b1->datums[i][j],
630646
b2->datums[i][j]));
631647
if (cmpval != 0)
632648
return false;
633-
634-
/* Range partitions can have infinite datums */
635-
if (b1->content != NULL && b1->content[i][j] != b2->content[i][j])
636-
return false;
637649
}
638650

639651
if (b1->indexes[i] != b2->indexes[i])

0 commit comments

Comments
 (0)