diff options
author | Bruce Momjian <bruce@momjian.us> | 1999-06-02 03:37:15 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1999-06-02 03:37:15 +0000 |
commit | e47b93d333d0741628727dec9d5ff58d2956a8da (patch) | |
tree | a3f7f58edbdf9c801d4198e4cf4aa51589410391 /src | |
parent | 8593e1ff0904422e75b88165343afba0153606e7 (diff) | |
download | postgresql-e47b93d333d0741628727dec9d5ff58d2956a8da.tar.gz postgresql-e47b93d333d0741628727dec9d5ff58d2956a8da.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/network.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index cd86ec6f3d5..7c1aa24dbcf 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -3,7 +3,7 @@ * is for IP V4 CIDR notation, but prepared for V6: just * add the necessary bits where the comments indicate. * - * $Id: network.c,v 1.9 1999/05/25 16:12:11 momjian Exp $ + * $Id: network.c,v 1.10 1999/06/02 03:37:15 momjian Exp $ * Jon Postel RIP 16 Oct 1998 */ @@ -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; } |