Commit 35438e57 authored by Robert Haas's avatar Robert Haas

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
parent 95022278
...@@ -751,15 +751,13 @@ partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval, ...@@ -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, ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment