MySQL 5.6 の時点で、いくつかの IPv6 関連の機能が追加されています。
新しい関数IS_IPV4_COMPAT(expr)
が廃止された RFC-4291 を使用して、指定されたbinary
アドレスが有効な IPv4 互換の IPv6 アドレスであるかどうかを確認する理由が不思議です。
この関数は、INET6_ATON() によって返されるバイナリ文字列として数値形式で表された IPv6 アドレスを取ります。引数が有効な IPv4 互換 IPv6 アドレスの場合は 1 を返し、それ以外の場合は 0 を返します。IPv4 互換アドレスの形式は ::ipv4_address です。
mysql> SELECT IS_IPV4_COMPAT(INET6_ATON('::10.0.5.9'));
-> 1
mysql> SELECT IS_IPV4_COMPAT(INET6_ATON('::ffff:10.0.5.9'));
-> 0
But the [RFC-4291](https://www.rfc-editor.org/rfc/rfc4291#section-2.5.5) says:
+--------------------------------------+--------------------------+
| 80 bits | 16 | 32 bits |
+--------------------------------------+--------------------------+
|0000..............................0000|0000| IPv4 address |
+--------------------------------------+----+---------------------+
> The "IPv4-Compatible IPv6 address" is now deprecated because the current IPv6 transition mechanisms no longer use these addresses. New or updated implementations are not required to support this address type.
+--------------------------------------+----+---------------------+
| 80 bits | 16 | 32 bits |
+--------------------------------------+--------------------------+
|0000..............................0000|FFFF| IPv4 address |
+--------------------------------------+----+---------------------+
> See [RFC4038](https://www.rfc-editor.org/rfc/rfc4038) for background on the usage of the "IPv4-mapped IPv6 address".
**Which format should I use to store IPv4 addresses within a IPv6 context?**