mirror of
https://github.com/postgres/postgres.git
synced 2025-05-15 19:15:29 +03:00
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.
This commit is contained in:
parent
50cf1c80e6
commit
6546ffb35d
@ -624,16 +624,28 @@ partition_bounds_equal(PartitionKey key,
|
|||||||
{
|
{
|
||||||
int32 cmpval;
|
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],
|
cmpval = DatumGetInt32(FunctionCall2Coll(&key->partsupfunc[j],
|
||||||
key->partcollation[j],
|
key->partcollation[j],
|
||||||
b1->datums[i][j],
|
b1->datums[i][j],
|
||||||
b2->datums[i][j]));
|
b2->datums[i][j]));
|
||||||
if (cmpval != 0)
|
if (cmpval != 0)
|
||||||
return false;
|
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])
|
if (b1->indexes[i] != b2->indexes[i])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user