V6_ATON
Converts an IPv6 address represented as a character string to a binary string.
Behavior Type
Syntax
V6_ATON ( expression )
Parameters
expression |
(VARCHAR) is the string to convert. |
Notes
The following syntax converts an IPv6 address represented as the character string A to a binary string B.
V6_ATON trims any spaces from the right of A and calls the Linux function inet_pton.
=> V6_ATON(VARCHAR A) -> VARBINARY(16) B
If A has no colons it is prepended with '::ffff:'. If A is NULL, too long, or if inet_pton returns an error, the result is NULL.
Examples
=> SELECT V6_ATON('2001:DB8::8:800:200C:417A'); v6_aton ------------------------------------------------------ \001\015\270\000\000\000\000\000\010\010\000 \014Az (1 row) => SELECT V6_ATON('1.2.3.4'); v6_aton ------------------------------------------------------------------ \000\000\000\000\000\000\000\000\000\000\377\377\001\002\003\004 (1 row) SELECT TO_HEX(V6_ATON('2001:DB8::8:800:200C:417A')); to_hex ---------------------------------- 20010db80000000000080800200c417a (1 row) => SELECT V6_ATON('::1.2.3.4'); v6_aton ------------------------------------------------------------------ \000\000\000\000\000\000\000\000\000\000\000\000\001\002\003\004 (1 row)