Re: CIDR output format

Поиск
Список
Период
Сортировка
От Larry Rosenman
Тема Re: CIDR output format
Дата
Msg-id 20001221101602.A17239@lerami.lerctr.org
обсуждение исходный текст
Ответ на Re: CIDR output format  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
* Tom Lane <tgl@sss.pgh.pa.us> [001221 09:49]:
> Larry Rosenman <ler@lerctr.org> writes:
> >> It would seem that the appropriate behavior would be to make the default
> >> display format for CIDR be like "10.0.0.0/8".  Now the text() conversion
> >> function already produces this same format.  I'd be inclined to leave
> >> text() as-is and add a new conversion function with some other name
> >> (suggestions anyone?) that produces the shorthand form "10/8" as text,
> >> for those who prefer it.
> 
> > I would call it cidrshort(). 
> 
> I was thinking something like abbrev().  There is no need to put the
> type name in the function; that's what function overloading is for.
> 
> > I assume this also is true for INET? 
> 
> INET doesn't use abbreviation of the address part anyway.  The only
> display shortcut it has is to suppress "/32" when the netmask is 32.
> I figured that text() could produce an un-abbreviated result for an
> INET input (as it does now), and abbrev() could produce one with
> /32 suppression.  In short:
> 
> Value            Default output    text()        abbrev()
> 
> '127.0.0.1/32'::inet    127.0.0.1    127.0.0.1/32    127.0.0.1
> '127.0.0.1/32'::cidr    127.0.0.1/32    127.0.0.1/32    127.0.0.1/32
> '127/8'::cidr        127.0.0.0/8    127.0.0.0/8    127/8
> 
> This would be a little bit inconsistent, because the default output
> format would match text() for CIDR values but abbrev() for INET values.
> But that seems like the most useful behavior to me.  Possibly others
> will disagree ;-)
I'm fine with it.  IIRC, you fixed it so we can cast from INET to CIDR
and back?  

Thanks!

> 
>             regards, tom lane
-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


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

Предыдущее
От: Michael Fork
Дата:
Сообщение: Re: AW: Three types of functions, ala function redux.
Следующее
От: Oleg Bartunov
Дата:
Сообщение: equal operator for _int4 (array of int4)