← Back to team overview

enterprise-support team mailing list archive

[Bug 1675256] [NEW] MySQL does not detect pattern when using UNHEX function

 

Public bug reported:

Hi,

When using rlike operator to detect characters with hex values between
80 and FF, it does not work when converting a binary string that starts
with hexadecimal '00' using unhex function. Here is an example:

-- First query returns 1 because expresion matches with pattern.

mysql> set @text := unhex('149D5554'); 
Query OK, 0 rows affected (0.00 sec)

mysql> select @text, hex(@text); 
+-------+------------+
| @text | hex(@text) |
+-------+------------+
| ?UT  | 149D5554   |
+-------+------------+
1 row in set (0.00 sec)

mysql> select ( CONVERT(@text USING BINARY) RLIKE CONCAT('[', UNHEX('80'), '-', UNHEX('FF'), ']')) "Match";
+-------+
| Match |
+-------+
|     1 |
+-------+
1 row in set (0.00 sec)

-- Second query expresion starts with 00 and does not return a match.

mysql> set @text := unhex('00149D5554'); 
Query OK, 0 rows affected (0.00 sec)

mysql> select @text, hex(@text); 
+-------+------------+
| @text | hex(@text) |
+-------+------------+
|  ?UT | 00149D5554 |
+-------+------------+
1 row in set (0.00 sec)

mysql> select ( CONVERT(@text USING BINARY) RLIKE CONCAT('[', UNHEX('80'), '-', UNHEX('FF'), ']')) "Match";
+-------+
| Match |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)

Although '00' hex string is out of range from pattern 80 and FF,
following strings of the expression should match with this pattern. For
example, It works well with '01' hex string:

mysql> set @text := unhex('01149D5554'); 
Query OK, 0 rows affected (0.00 sec)

mysql> select @text, hex(@text); 
+-------+------------+
| @text | hex(@text) |
+-------+------------+
| ?UT | 01149D5554 |
+-------+------------+
1 row in set (0.00 sec)

mysql> select ( CONVERT(@text USING BINARY) RLIKE CONCAT('[', UNHEX('80'), '-', UNHEX('FF'), ']')) "Match";
+-------+
| Match |
+-------+
|     1 |
+-------+
1 row in set (0.00 sec)

** Affects: mysql-server
     Importance: Unknown
         Status: Unknown

** Affects: percona-server
     Importance: Undecided
         Status: New

** Bug watch added: MySQL Bug System #85588
   http://bugs.mysql.com/bug.php?id=85588

** Also affects: mysql-server via
   http://bugs.mysql.com/bug.php?id=85588
   Importance: Unknown
       Status: Unknown

-- 
You received this bug notification because you are a member of Ubuntu
Server/Client Support Team, which is subscribed to MySQL.
Matching subscriptions: Ubuntu Server/Client Support Team
https://bugs.launchpad.net/bugs/1675256

Title:
  MySQL does not detect pattern when using UNHEX function

To manage notifications about this bug go to:
https://bugs.launchpad.net/mysql-server/+bug/1675256/+subscriptions


Follow ups