Skip to content

Commit 35438e5

Browse files
committed
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
1 parent 9502227 commit 35438e5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/backend/catalog/partition.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,15 +751,13 @@ partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval,
751751

752752
if (b1->strategy == PARTITION_STRATEGY_HASH)
753753
{
754-
int greatest_modulus;
754+
int greatest_modulus = get_greatest_modulus(b1);
755755

756756
/*
757757
* If two hash partitioned tables have different greatest moduli,
758-
* their partition schemes don't match. For hash partitioned table,
759-
* the greatest modulus is given by the last datum and number of
760-
* partitions is given by ndatums.
758+
* their partition schemes don't match.
761759
*/
762-
if (b1->datums[b1->ndatums - 1][0] != b2->datums[b2->ndatums - 1][0])
760+
if (greatest_modulus != get_greatest_modulus(b2))
763761
return false;
764762

765763
/*
@@ -773,7 +771,6 @@ partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval,
773771
* their indexes array will be same. So, it suffices to compare
774772
* indexes array.
775773
*/
776-
greatest_modulus = get_greatest_modulus(b1);
777774
for (i = 0; i < greatest_modulus; i++)
778775
if (b1->indexes[i] != b2->indexes[i])
779776
return false;

0 commit comments

Comments
 (0)