1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Minor code beautification in partition_bounds_equal.

Use get_greatest_modulus more consistently, instead of doing the
same thing in an ad-hoc manner in this one place.

Ashutosh Bapat

Discussion: http://postgr.es/m/CAFjFpReT9L4RCiJBKOyWC2=i02kv9uG2fx=4Fv7kFY2t0SPCgw@mail.gmail.com
This commit is contained in:
Robert Haas
2017-12-01 13:52:59 -05:00
parent 9502227805
commit 35438e5763

View File

@ -751,15 +751,13 @@ partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval,
if (b1->strategy == PARTITION_STRATEGY_HASH) if (b1->strategy == PARTITION_STRATEGY_HASH)
{ {
int greatest_modulus; int greatest_modulus = get_greatest_modulus(b1);
/* /*
* If two hash partitioned tables have different greatest moduli, * If two hash partitioned tables have different greatest moduli,
* their partition schemes don't match. For hash partitioned table, * their partition schemes don't match.
* the greatest modulus is given by the last datum and number of
* partitions is given by ndatums.
*/ */
if (b1->datums[b1->ndatums - 1][0] != b2->datums[b2->ndatums - 1][0]) if (greatest_modulus != get_greatest_modulus(b2))
return false; return false;
/* /*
@ -773,7 +771,6 @@ partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval,
* their indexes array will be same. So, it suffices to compare * their indexes array will be same. So, it suffices to compare
* indexes array. * indexes array.
*/ */
greatest_modulus = get_greatest_modulus(b1);
for (i = 0; i < greatest_modulus; i++) for (i = 0; i < greatest_modulus; i++)
if (b1->indexes[i] != b2->indexes[i]) if (b1->indexes[i] != b2->indexes[i])
return false; return false;