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

logical operators and hex syntax

    XMLWordPrintable

Details

    Description

      Please verify findings below:

      odbc syntax:

      select hex(0xff & 0xf0);
      +------------------+
      | hex(0xff & 0xf0) |
      +------------------+
      | F0               |
      +------------------+
      
      

      ... result is correct.

      SQL syntax:

      select hex(x'ff' & x'f0');
      +--------------------+
      | hex(x'ff' & x'f0') |
      +--------------------+
      | 0                  |
      +--------------------+
      

      result is wrong.

      ... and two warnings:

      +---------+------+-------------------------------------------+
      | Level   | Code | Message                                   |
      +---------+------+-------------------------------------------+
      | Warning | 1292 | Truncated incorrect DECIMAL value: '\xFF' |
      | Warning | 1292 | Truncated incorrect DECIMAL value: '\xF0' |
      +---------+------+-------------------------------------------+
      

      Output of bitwise operations remains rather unexpected when capitals get used with SQL style:

      select hex(X'FF' & X'F0');
      +--------------------+
      | hex(X'FF' & X'F0') |
      +--------------------+
      | 0                  |
      +--------------------+
      

      'incorrect decimal values' warnings get generated as well.

      at last:

      select hex((0xff+0) & (0x7f+0));
      +--------------------------+
      | hex((0xff+0) & (0x7f+0)) |
      +--------------------------+
      | 7F                       |
      +--------------------------+
      

      vs.

      select hex((x'ff'+0) & (x'7f'+0));
      +----------------------------+
      | hex((x'ff'+0) & (x'7f'+0)) |
      +----------------------------+
      | 0                          |
      +----------------------------+
      

      Last command: warnings gone, result remains wrong.

      Above findings were verified with bitwise operator '|' as well.

      Conclusions:

      • odbc syntax of hex operands causes maria to execute bitwise logical operations.
      • SQL syntax of hex operands causes maria to convert hex to integer in background, prior to request processing.

      Best Regards.

      Attachments

        Activity

          People

            Unassigned Unassigned
            grb357 Prefer To Stay Anonymous
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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