]> granicus.if.org Git - postgresql/commitdiff
Minor code beautification in partition_bounds_equal.
authorRobert Haas <rhaas@postgresql.org>
Fri, 1 Dec 2017 18:52:59 +0000 (13:52 -0500)
committerRobert Haas <rhaas@postgresql.org>
Fri, 1 Dec 2017 18:52:59 +0000 (13:52 -0500)
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

src/backend/catalog/partition.c

index 2bf81177579121b6b37dcebe6d86ca2f53d443ce..dd4a8d3c02d3f07d56369674f158ee3959c7c65c 100644 (file)
@@ -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;