Search Postgresql Archives

Re: Ipv6 address stored differently while using Inet type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2018-12-27 14:56:25 +0530, Sameer Thakur wrote:
> I am using Postgres 10.4
> I tried to insert ipv6 address '2001:db8:3333:4444:5555:6666:1.2.3.4'
> in Postgres (10.4) in an inet column. It is stored as
> 2001:db8:3333:4444:5555:6666:102:304.

No. It is *displayed* as "2001:db8:3333:4444:5555:6666:102:304". It is
stored as a 128 bit sequence. 

> Why is the IP stored differently?

It is displayed in the way IPv6 addresses are usually displayed (16 bit
groups in hex separated by colons). The form you used to insert the
address (first 96 bits in hex and last 32 bits in decimal) is normally
only used for the IPv4 compatibility range: You would write
0000:0000:0000:0000:0000:0000:C000:022A as ::192.0.2.42, not ::C000:22A,
but you would write 2001:db8:3333:4444:5555:6666:102:304, not
2001:db8:3333:4444:5555:6666:1.2.3.4.

> Does the stored IP represent the same one being inserted?

Yes.

>  Is this a known bug resolved in later versions of Postgres?

No.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@xxxxxx         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux