V6_TYPE
Characterizes a binary or alphanumeric IPv6 address B as an integer type.
Behavior Type
Syntax
V6_TYPE ( expression )
Parameters
expression |
(VARBINARY or VARCHAR) is the type to convert. |
Notes
V6_TYPE(VARBINARY B)
returns INT8 T
.
=> V6_TYPE(VARCHAR A) -> V6_TYPE(V6_ATON(A)) -> INT8 T
The IPv6 types are defined in the Network Working Group's IP Version 6 Addressing Architecture memo.
GLOBAL = 0 Global unicast addresses LINKLOCAL = 1 Link-Local unicast (and Private-Use) addresses LOOPBACK = 2 Loopback UNSPECIFIED = 3 Unspecified MULTICAST = 4 Multicast
IPv4-mapped and IPv4-compatible IPv6 addresses are also interpreted, as specified in IPv4 Global Unicast Address Assignments.
- For IPv4, Private-Use is grouped with Link-Local.
- If B is
VARBINARY
, it is right-padded to 16 bytes with zeros, if necessary. - If B is NULL or longer than 16 bytes, the result is NULL.
Details
IPv4 (either kind):
0.0.0.0/8 UNSPECIFIED 10.0.0.0/8 LINKLOCAL 127.0.0.0/8 LOOPBACK 169.254.0.0/16 LINKLOCAL 172.16.0.0/12 LINKLOCAL 192.168.0.0/16 LINKLOCAL 224.0.0.0/4 MULTICAST others GLOBAL
IPv6:
::0/128 UNSPECIFIED ::1/128 LOOPBACK fe80::/10 LINKLOCAL ff00::/8 MULTICAST others GLOBAL
Examples
=> SELECT V6_TYPE(V6_ATON('192.168.2.10')); v6_type --------- 1 (1 row) => SELECT V6_TYPE(V6_ATON('2001:db8::8:800:200c:417a')); v6_type --------- 0 (1 row)