UUID, INET4 and INET6 types
The MariaDB types UUID, INET4 and INET6: accepted forms, the form they are kept in, errors, and the difference from MySQL.
Syntax#
UUID
INET4
INET6These are MariaDB types. Raft DB reads them in both dialects (MySQL has none of them).
Remarks#
UUIDreads 32 hexadecimal digits with or without dashes (up to four, in any place) in any case, and keeps one form: lower case with dashes (123e4567-e89b-12d3-a456-426614174000). Anything else is error 1292 (The uuid value 'nonsense' given for column 'id' (row 1) is not valid). The length is 36.INET4reads a dotted IPv4 address (192.168.1.5) and keeps it. Anything else is error 1292 ('1.2.3'is refused).INET6reads an IPv6 address (2001:db8::1) and keeps it in compressed form; an IPv4 address is kept as an IPv4-mapped IPv6 address (1.2.3.4becomes::ffff:1.2.3.4). Anything else is error 1292.- Comparison. The values are text in their one form, so
id = idis 1 andWHERE a = '10.0.0.1'finds the row. AUUID()function result can be stored, andDEFAULT UUID()is allowed (see Miscellaneous functions). - Not supported yet: the functions
UUID_TO_BIN,BIN_TO_UUID,IS_UUID,INET6_ATONandINET6_NTOA. SHOW CREATE TABLEandDESCRIBEshowuuid,inet4,inet6.
Examples#
CREATE TABLE u (id UUID, a INET4, b INET6);
INSERT INTO u VALUES ('123E4567-E89B-12D3-A456-426614174000', '192.168.1.5', '2001:db8::1');
INSERT INTO u VALUES ('123e4567e89b12d3a456426614174001', '10.0.0.1', '::ffff:1.2.3.4');
INSERT INTO u VALUES (UUID(), '1.1.1.1', '1.2.3.4');
INSERT INTO u (id) VALUES ('nonsense'); -- error 1292
SELECT a FROM u WHERE a = '10.0.0.1';The output is identical to MariaDB 11.4.13.