Re: inet/cidr type comparisons

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alex Pilosov <alex(at)pilosoft(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: inet/cidr type comparisons
Date: 2001-06-11 16:03:54
Message-ID: 4991.992275434@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alex Pilosov <alex(at)pilosoft(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert E. Bruccoleri 2001-06-11 16:04:05 Re: Various silliness in heap_getnext and related routines
Previous Message mlw 2001-06-11 15:52:28 Re: REPLACE INTO table a la mySQL