inet/cidr type comparisons

Поиск
Список
Период
Сортировка
От Alex Pilosov
Тема inet/cidr type comparisons
Дата
Msg-id Pine.BSO.4.10.10106110938370.17529-100000@spider.pilosoft.com
обсуждение исходный текст
Ответы Re: inet/cidr type comparisons  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "earthlink"
Дата:
Сообщение: Implicit order-by in Postgresql?
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: PostgreSQL and replication