mysql - Why does MariaDB-10.2.8 UNHEX() return NULL? -
i have sql script works on mysql (up current versions). built copy of mariadb-10.2.8 source on linux machine , got database , running. however, sql script fails, because mariadb returning null unhex() call, shouldn't.
the call producing 20-byte random binary string in particular format (it's bittorrent node id). concatenate required bytes random bytes, bytes being limited particular range of values. these constructed 40-character hex string, run through unhex().
the sql is:
unhex( concat( '414c2', hex( 8 + round( rand() * 7 ) ), substr( sha( uuid( ) ), 6, 33 ), hex( 2 + round( rand( ) ) * 8 ) ) )
if take off unhex() function, 40-character hex string:
mariadb [bt]> select concat('414c2', hex(8+round(rand()*7)),substr(sha(uuid()),6,33),hex(2+round(rand())*8)); +-----------------------------------------------------------------------------------------+ | concat('414c2', hex(8+round(rand()*7)),substr(sha(uuid()),6,33),hex(2+round(rand())*8)) | +-----------------------------------------------------------------------------------------+ | 414c29115056f1bd332d4e2e3eb5edd3fc90c0a2 | +-----------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
but if unhex() it:
mariadb [bt]> select unhex(concat('414c2', hex(8+round(rand()*7)),substr(sha(uuid()),6,33),hex(2+round(rand())*8))); +------------------------------------------------------------------------------------------------+ | unhex(concat('414c2', hex(8+round(rand()*7)),substr(sha(uuid()),6,33),hex(2+round(rand())*8))) | +------------------------------------------------------------------------------------------------+ | null | +------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
by contrast, same command on mysql instance:
mysql> select unhex(upper(concat('414c2', hex(8+round(rand()*7)),substr(sha(uuid()),6,33),hex(2+round(rand())*8)))); +-------------------------------------------------------------------------------------------------------+ | unhex(upper(concat('414c2', hex(8+round(rand()*7)),substr(sha(uuid()),6,33),hex(2+round(rand())*8)))) | +-------------------------------------------------------------------------------------------------------+ | al*w?? ???r?%?? | +-------------------------------------------------------------------------------------------------------+ 1 row in set (0.02 sec)
unhex() of 40-character hex string bytes printable works ok on mariadb:
mariadb [bt]> select unhex('4142434445464748494a4b4c4d4e4f5051525354'); +---------------------------------------------------+ | unhex('4142434445464748494a4b4c4d4e4f5051525354') | +---------------------------------------------------+ | abcdefghijklmnopqrst | +---------------------------------------------------+ 1 row in set (0.00 sec)
any idea why random hex string wouldn't work?
looks bug. we've filed report this: https://jira.mariadb.org/browse/mdev-13793
Comments
Post a Comment