Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-13790

UNHEX() of a somewhat complicated CONCAT() returns NULL

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2.8, 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • 10.0.34, 10.1.31, 10.2.13, 10.3.5
    • OTHER
    • None
    • Debian 9, compiled-from-source MariaDB
    • 10.1.29, 10.1.31

    Description

      I have a SQL script that works on MySQL (up to current versions). I built a copy of MariaDB-10.2.8 from source on a Linux machine and got the database up and running. However, my SQL script fails, because MariaDB is returning NULL from an UNHEX() call, where it shouldn't.

      The call is producing a 20-byte random binary string in a particular format (it's a BitTorrent node ID). I concatenate some required bytes with some random bytes, with certain bytes being limited to a particular range of values. These are constructed as a 40-character hex string, which I then run through UNHEX().

      The SQL is:

      unhex( concat( '414C2',
                              hex( 8 + round( rand() * 7 ) ),
                              substr( sha( uuid( ) ), 6, 33 ),
                              hex( 2 + round( rand( ) * 8 ) ) ) )
      

      Running this (with select) returns NULL. Running just the concat() returns a hex string, and running unhex() on the hex string presented as a literal returns the expected binary gobbeldygook.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              mersenne dave madden
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.