tion. Before MariaDB 10.5.0, these functions understood only binary(16) representation. Prepared Statement Parameters ----------------------------- INET6 understands both text and binary(16) address representation in prepared statement parameters (PREPARE..EXECUTE and EXECUTE IMMEDIATE statements). Migration between BINARY(16) and INET6 --------------------------------------- Before MariaDB 10.5.0, you may have used BINARY(16) as a storage for IPv6 internet addresses, in combination with INET6_ATON and INET6_NTOA to respectively insert and retrieve data. From 10.5, you can ALTER BINARY(16) columns storing IPv6 addresses to INET6. After such an alter, there is no a need to use INET6_ATON() and INET6_NTOA(). Addresses can be inserted and retrieved directly. It is also possible to convert INET6 columns to BINARY(16) and continue using the data in combination with INET6_NTOA() and INET6_ATON(). Examples -------- CREATE TABLE t1 (a INET6); Inserting using short text address notation: INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329'); Long text address notation: INSERT INTO t1 VALUES ('2001:0db8:0000:0000:0000:ff00:0042:8329'); 16-byte binary string notation: INSERT INTO t1 VALUES (0x20010DB8000000000000FF0000428329); INSERT INTO t1 VALUES (UNHEX('20010DB8000000000000FF0000428329')); IPv4 addresses, using IPv4-mapped and IPv4-compatible notations: INSERT INTO t1 VALUES ('::ffff:192.0.2.128'); -- mapped INSERT INTO t1 VALUES ('::192.0.2.128'); -- compatible SELECT * FROM t1; +------------------------+ | a | +------------------------+ | 2001:db8::ff00:42:8329 | | 2001:db8::ff00:42:8329 | | 2001:db8::ff00:42:8329 | | 2001:db8::ff00:42:8329 | | ::ffff:192.0.2.128 | | ::192.0.2.128 | +------------------------+ IPv4 mapped (or compatible) values still occupy 16 bytes: CREATE OR REPLACE TABLE t1 (a INET6); INSERT INTO t1 VALUES ('::ffff:192.0.2.128'); SELECT * FROM t1; +--------------------+ | a | +--------------------+ | ::ffff:192.0.2.128 | +--------------------+ SELECT HEX(a) FROM t1; +----------------------------------+ | HEX(a) | +----------------------------------+ | 00000000000000000000FFFFC0000280 | +----------------------------------+ Casting from INET6 to anything other than CHAR returns an error: SELECT CAST(a AS DECIMAL) FROM t1; ERROR 4079 (HY000): Illegal parameter data type inet6 for operation 'decimal_typecast' Comparison Examples ------------------- Comparison with another INET6 expression: CREATE OR REPLACE TABLE t1 (a INET6); CREATE OR REPLACE TABLE t2 (a INET6); INSERT INTO t1 VALUES ('2001:db8::ff00:42:8328'),('2001:db8::ff00:42:8329'); INSERT INTO t2 VALUES ('2001:db8::ff00:42:832a'),('2001:db8::ff00:42:8329'); SELECT t1.* FROM t1,t2 WHERE t1.a=t2.a; +------------------------+ | a | +------------------------+ | 2001:db8::ff00:42:8329 | +------------------------+ With a character string expression with a text (short or long) address representation: CREATE OR REPLACE TABLE t1 (a INET6); INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329'); SELECT * FROM t1 WHERE a='2001:db8::ff00:42:8329'; +------------------------+ | a | +------------------------+ | 2001:db8::ff00:42:8329 | +------------------------+ With a 16-byte binary string expression: CREATE OR REPLACE TABLE t1 (a INET6); INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329'); SELECT * FROM t1 WHERE a=X'20010DB8000000000000FF0000428329'; +------------------------+ | a | +------------------------+ | 2001:db8::ff00:42:8329 | +------------------------+ With an expression of another data type: SELECT * FROM t1 WHERE a=1; ERROR 4078 (HY000): Illegal parameter data types inet6 and int for operation '=' Mixing for Result Examples -------------------------- Mixed with another INET6 expression, returning an INET6 data type: CREATE OR REPLACE TABLE t1 (a INET6, b INET6); INSERT INTO t1 VALUES (NULL,'2001:db8::ff00:42:8329'); SELECT a FROM t1 UNION SELECT b F