From: Bruce Momjian Date: Wed, 2 Jun 1999 03:37:15 +0000 (+0000) Subject: The INET and CIDR types mistakenly compared 198.68.123.0/24 and X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=96e982c31d0f8e25c0f27a1a1942ab34ff8cfed3;p=users%2Fbernd%2Fpostgres.git The INET and CIDR types mistakenly compared 198.68.123.0/24 and 198.68.123.0/27 the same when indexing them. D'Arcy --- diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 95d84ed0b0..a3ad62a46f 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -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; }