From: Robert Haas Date: Fri, 1 Dec 2017 18:52:59 +0000 (-0500) Subject: Minor code beautification in partition_bounds_equal. X-Git-Tag: REL_11_BETA1~1126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35438e5763c3021e579472e4b0c4a4d6038570b4;p=postgresql 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 --- diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index 2bf8117757..dd4a8d3c02 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -751,15 +751,13 @@ partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval, 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, - * their partition schemes don't match. For hash partitioned table, - * the greatest modulus is given by the last datum and number of - * partitions is given by ndatums. + * their partition schemes don't match. */ - if (b1->datums[b1->ndatums - 1][0] != b2->datums[b2->ndatums - 1][0]) + if (greatest_modulus != get_greatest_modulus(b2)) 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 * indexes array. */ - greatest_modulus = get_greatest_modulus(b1); for (i = 0; i < greatest_modulus; i++) if (b1->indexes[i] != b2->indexes[i]) return false;