Re: Q: inet operators for IPv4 encapsulated in IPv6

Поиск
Список
Период
Сортировка
От Albrecht Dreß
Тема Re: Q: inet operators for IPv4 encapsulated in IPv6
Дата
Msg-id CBW7ETXL.UER7NPLP.7MU74MRW@MWNEQWR2.VWOLWPVC.VMSVXW24
обсуждение исходный текст
Ответ на Re: Q: inet operators for IPv4 encapsulated in IPv6  (Erik Wienhold <ewie@ewie.name>)
Список pgsql-general
Am 06.09.23 19:41 schrieb(en) Erik Wienhold:
> The docs don't spell it out, but inet operators and functions expect values of the same inet family.  Comparing IPv4
andIPv6 always returns false, e.g. [1]. 
> The only hint in the docs that may imply this is [2]:
>
>     "When sorting inet or cidr data types, IPv4 addresses will always sort
>      before IPv6 addresses, including IPv4 addresses encapsulated or mapped
>      to IPv6 addresses, such as ::10.2.3.4 or ::ffff:10.4.3.2."

Ah, I missed that section in the docs.  Thanks a lot for your explanation and the pointers!

> You can write your own function that converts IPv4-mapped IPv6 addresses to IPv4 and then do the comparison:
>
>     postgres=# SELECT ltrim(host('::ffff:192.168.1.5'::inet & '::255.255.255.255'::inet), ':')::inet;
>         ltrim
>     -------------
>      192.168.1.5
>     (1 row)

That's a nice approach, will do that.

Thanks again, Albrecht.
Вложения

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

Предыдущее
От: Erik Wienhold
Дата:
Сообщение: Re: Q: inet operators for IPv4 encapsulated in IPv6
Следующее
От: Imre Samu
Дата:
Сообщение: Re: running ANALYZE results in => duplicate key value violates unique constraint "pg_statistic_relid_att_inh_index"