inet/cidr type comparisons

From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: inet/cidr type comparisons
Date: 2001-06-11 13:47:20
Message-ID: Pine.BSO.4.10.10106110938370.17529-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I noticed current wierd behaviour of a less/greater than comparisons of
things involving inet/cidr:

10.1.2.3/8 is considered to be less than 10.0.0.0/32

The current logic does the following:
a) compare the network part of each (this will be 10.0.0.0), identical in
this case.

b) compare the netmask length. If a value has shorter netmask, its
considered to be less than a value with longer netmask.

c) the host part is compared.

To me, this makes no sense. I think b and c should be transposed, and
netmask comparison must be only used as a tiebreaker when the values are
the same otherwise (such as, when comparing 10.1.2.3/8 and 10.1.2.3/32).

For type cidr, same thing applies: currently, 10.1.2.0/24 is considered to
be less than 10.0.0.0/8.

If someone can tell me a good reason why the comparisons are the way they
are now, I'd much appreciate it :)

-alex

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-06-11 14:56:36 Re: dlopen() of libpgsqlodbc.so >= release 7.1 fails on sparc solaris 2.8
Previous Message Jan Wieck 2001-06-11 13:24:22 Re: Baby girl