This query erroneously returns NULL:
SELECT UNHEX(CONCAT('414c2', HEX(8+ROUND(RAND()*7)),SUBSTR(SHA(''),6,7),HEX(2+ROUND(RAND())*8)));
|
If I remove HEX, it correctly returns a string in hexadecimal format:
SELECT CONCAT('414c2', HEX(8+ROUND(RAND()*7)),SUBSTR(SHA(''),6,7),HEX(2+ROUND(RAND())*8));
|
+------------------------------------------------------------------------------------+
|
| CONCAT('414c2', HEX(8+ROUND(RAND()*7)),SUBSTR(SHA(''),6,7),HEX(2+ROUND(RAND())*8)) |
|
+------------------------------------------------------------------------------------+
|
| 414c2B3ee5e6bA |
|
+------------------------------------------------------------------------------------+
|
If I now add a user variable assignment, it erroneously returns a broken hexadecimal string:
SELECT @a:=CONCAT('414c2', HEX(8+ROUND(RAND()*7)),SUBSTR(SHA(''),6,7),HEX(2+ROUND(RAND())*8));
|
+----------------------------------------------------------------------------------------+
|
| @a:=CONCAT('414c2', HEX(8+ROUND(RAND()*7)),SUBSTR(SHA(''),6,7),HEX(2+ROUND(RAND())*8)) |
|
+----------------------------------------------------------------------------------------+
|
| 414c299 ee56b2 |
|
+----------------------------------------------------------------------------------------+
|
The same problem is reproducible in a simplified query:
SELECT @a:=CONCAT('2', '2', SUBSTR(SHA(''),6,7));
|
+-------------------------------------------+
|
| @a:=CONCAT('2', '2', SUBSTR(SHA(''),6,7)) |
|
+-------------------------------------------+
|
| 223ee5 6b |
|
+-------------------------------------------+
|