The INET and CIDR types mistakenly compared 198.68.123.0/24 and
authorBruce Momjian <[email protected]>
Wed, 2 Jun 1999 03:37:15 +0000 (03:37 +0000)
committerBruce Momjian <[email protected]>
Wed, 2 Jun 1999 03:37:15 +0000 (03:37 +0000)
198.68.123.0/27 the same when indexing them.

D'Arcy

src/backend/utils/adt/network.c

index 95d84ed0b02d29448d10ada31775a06971f48660..a3ad62a46fdd70017d52dceaf319475c7a319c6d 100644 (file)
@@ -306,8 +306,16 @@ network_cmp(inet *a1, inet *a2)
 {
        if (ntohl(ip_v4addr(a1)) < ntohl(ip_v4addr(a2)))
                return (-1);
-       else if (ntohl(ip_v4addr(a1)) > ntohl(ip_v4addr(a2)))
+
+       if (ntohl(ip_v4addr(a1)) > ntohl(ip_v4addr(a2)))
+               return (1);
+
+       if (ip_bits(a1) < ip_bits(a2))
+               return (-1);
+
+       if (ip_bits(a1) > ip_bits(a2))
                return (1);
+
        return 0;
 }