Re: inet/cidr type comparisons - Mailing list pgsql-hackers

From Tom Lane
Subject Re: inet/cidr type comparisons
Date
Msg-id 4991.992275434@sss.pgh.pa.us
Whole thread Raw
In response to inet/cidr type comparisons  (Alex Pilosov <alex@pilosoft.com>)
Responses Re: inet/cidr type comparisons  (Alex Pilosov <alex@pilosoft.com>)
List pgsql-hackers
Alex Pilosov <alex@pilosoft.com> writes:
> 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

And what's wrong with that?  Essentially this comes from the conclusion
that 10/8 is less than 10.0.0.0/32, which I have no problem with.

> 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).

That would break the rule that network part is major sort key and host
part is minor sort key, which I think is useful behavior.

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

It is?

regression=# select '10.1.2.0/24'::cidr < '10.0.0.0/8'::cidr;?column?
----------f
(1 row)

        regards, tom lane


pgsql-hackers by date:

Previous
From: "Mikheev, Vadim"
Date:
Subject: RE: Baby girl
Next
From: Bruce Momjian
Date:
Subject: Re: Baby girl