Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL)
-
None
Description
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 |
|
+-------------------------------------------+
|
Attachments
Issue Links
- is duplicated by
-
MDEV-13790 UNHEX() of a somewhat complicated CONCAT() returns NULL
- Closed
- relates to
-
MDEV-10306 Wrong results with combination of CONCAT, SUBSTR and CONVERT in subquery
- Closed