[MDEV-26616] uuid data type - convert from text with binary data based on length Created: 2021-09-16  Updated: 2021-09-21  Resolved: 2021-09-21

Status: Closed
Project: MariaDB Server
Component/s: Data types
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Daniel Black Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-4958 Adding datatype UUID Closed

 Description   

text conversion to uuid data type is based on hex characters.

binary data conversion is base on raw bytes.

The case of a 16 byte string in a text data type is unambiguous and could be converted as raw bytes rather than the failed conversion below.

MariaDB [(none)]> select cast(cast(x'00000000000000000000000000000001' as varchar(36)) as uuid);
+------------------------------------------------------------------------+
| cast(cast(x'00000000000000000000000000000001' as varchar(36)) as uuid) |
+------------------------------------------------------------------------+
| NULL                                                                   |
+------------------------------------------------------------------------+
1 row in set, 1 warning (0.000 sec)
 
MariaDB [(none)]> show warnings;
+---------+------+----------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                  |
+---------+------+----------------------------------------------------------------------------------------------------------+
| Warning | 1292 | Incorrect uuid value: '\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0001' |
+---------+------+----------------------------------------------------------------------------------------------------------+



 Comments   
Comment by Sergei Golubchik [ 2021-09-20 ]

I don't think content-based auto-detection is a good idea, it almost always backfires in some cases

Generated at Thu Feb 08 09:46:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.