Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11
Description
The UUID() function correctly returns a value of type UUID. We can easily verify this with CREATE TABLE x SELECT UUID(); and SHOW CREATE TABLE x;.
However, the value becomes VARCHAR if we try to assign it to a user variable:
MariaDB [(none)]> SET @uuid := UUID(); |
Query OK, 0 rows affected (0.000 sec) |
|
MariaDB [(none)]> SELECT VARIABLE_TYPE FROM information_schema.user_variables WHERE VARIABLE_NAME = 'uuid' |
;
|
+---------------+ |
| VARIABLE_TYPE |
|
+---------------+ |
| VARCHAR | |
+---------------+ |
1 row in set (0.000 sec) |
The same happens if we try to cast the type explicitly:
MariaDB [(none)]> SET @uuid := CAST(UUID() AS UUID); |
Query OK, 0 rows affected (0.000 sec) |
|
MariaDB [(none)]> SELECT VARIABLE_TYPE FROM information_schema.user_variables WHERE VARIABLE_NAME = 'uuid'; |
+---------------+ |
| VARIABLE_TYPE |
|
+---------------+ |
| VARCHAR | |
+---------------+ |
1 row in set (0.000 sec) |
This can lead to incorrect results:
-- with dashes:
|
MariaDB [(none)]> SELECT @uuid = 'fb025246-e48d-11ed-b010-56000464509c'; |
+------------------------------------------------+ |
| @uuid = 'fb025246-e48d-11ed-b010-56000464509c' | |
+------------------------------------------------+ |
| 1 |
|
+------------------------------------------------+ |
1 row in set (0.000 sec) |
|
-- with no dashes:
|
MariaDB [(none)]> SELECT @uuid = 'fb025246e48d11edb01056000464509c'; |
+--------------------------------------------+ |
| @uuid = 'fb025246e48d11edb01056000464509c' | |
+--------------------------------------------+ |
| 0 |
|
+--------------------------------------------+ |
1 row in set (0.000 sec) |
Attachments
Issue Links
- relates to
-
MDEV-4958 Adding datatype UUID
- Closed