Re: [GENERAL] Bug? Netmask of CIDR as TEXT has trailing masklen

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [GENERAL] Bug? Netmask of CIDR as TEXT has trailing masklen
Дата
Msg-id 24584.1482506121@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: [GENERAL] Bug? Netmask of CIDR as TEXT has trailing masklen  (nomad@null.net)
Список pgsql-general
nomad@null.net writes:
> The following displays as I would expect:
>     mark=# select netmask('1.1.1.0/24');
>         netmask
>     ---------------
>      255.255.255.0
>     (1 row)

> However the following does not look right:

>     mark=# select netmask('1.1.1.0/24')::text;
>          netmask
>     ------------------
>      255.255.255.0/32
>     (1 row)

> The trailing "/32" should not be there.

Yes, it should be: that is the same as "text(netmask('1.1.1.0/24'))",
and the table of network functions specifically describes text(inet)
as "extract IP address and netmask length as text".  If you only want
the IP address, use host(), or possibly abbrev() which I think follows the
output function's rule of suppressing the netmask when it is full-width.

From a system-wide consistency standpoint, it's rather unfortunate that
inet's default conversion to text type does not behave the same as the
inet output function.  But it's been like that for umpteen years and
the costs of breaking backwards compatibility would outweigh any benefit
of changing it.

            regards, tom lane


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

Предыдущее
От: Rakesh Kumar
Дата:
Сообщение: [GENERAL] Querying dead rows
Следующее
От: Alessandro Baggi
Дата:
Сообщение: [GENERAL] [OT] Postgresql and PHP