| Bug #102379 | UNHEX() function not giving the right output in latest MySQL versions | ||
|---|---|---|---|
| Submitted: | 26 Jan 2021 15:22 | Modified: | 26 Jan 2021 15:59 |
| Reporter: | Sri Sakthivel Durai Pandian | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: User-defined functions ( UDF ) | Severity: | S3 (Non-critical) |
| Version: | > MySQL 8.0.18 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | #mysql #functions | ||
[26 Jan 2021 15:42]
Frederic Descamps
Hello,
This is not an issue of the UDF, you can check with MySQL Shell for example:
SQL select hex('string') , unhex('string'), unhex(hex("string")) \G
*************************** 1. row ***************************
hex('string'): 737472696E67
unhex('string'): NULL
unhex(hex("string")): string
1 row in set, 1 warning (0.0009 sec)
Warning (code 1411): Incorrect string value: ''string'' for function unhex
SQL select version();
+-----------+
| version() |
+-----------+
| 8.0.23 |
+-----------+
And of course with the classic old mysql client, you can also try with this time using --skip-binary-as-hex:
$ mysql --skip-binary-as-hex
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.23 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select hex('string') , unhex('string'), unhex(hex("string")) \G
*************************** 1. row ***************************
hex('string'): 737472696E67
unhex('string'): NULL
unhex(hex("string")): string
1 row in set, 1 warning (0.00 sec)
See https://bugs.mysql.com/bug.php?id=84391
This is part of the release note: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html and the documentation about this parameter is here: https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-...
Regards,
[26 Jan 2021 15:59]
MySQL Verification Team
Thank you for the bug report. Not a bug as Frederic pointed.

Description: When I am using the function "UNHEX('<valid_hex_string>')", it does't giving the correct results on the MySQL newer versions. MySQL 8.0.18, and the prior versions are giving the correct results. Affected versions: -- MySQL 8.0.23 -- MySQL 8.0.22 -- MySQL 8.0.21 -- MySQL 8.0.20 -- MySQL 8.0.19 logs : mysql> select @@version, @@version_comment\G *************************** 1. row *************************** @@version: 8.0.19 @@version_comment: MySQL Community Server - GPL 1 row in set (0.00 sec) mysql> select hex('string') , unhex('string'), unhex(hex("string")) \G *************************** 1. row *************************** hex('string'): 737472696E67 unhex('string'): NULL unhex(hex("string")): 0x737472696E67 1 row in set, 1 warning (0.00 sec) mysql> select @@version, @@version_comment\G *************************** 1. row *************************** @@version: 8.0.18 @@version_comment: MySQL Community Server - GPL 1 row in set (0.00 sec) mysql> select hex('string') , unhex('string'), unhex(hex("string")) \G *************************** 1. row *************************** hex('string'): 737472696E67 unhex('string'): NULL unhex(hex("string")): string 1 row in set, 1 warning (0.00 sec) How to repeat: Install the each MySQL versions, and execute the command "select hex('string') , unhex('string'), unhex(hex("string")) \G" Suggested fix: -