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

Derived table truncates HEX(CAST(ABS(bit_literal) AS BINARY)) result from 3432 to 34

    XMLWordPrintable

Details

    Description

      SELECT
        HEX(CAST(ABS(b'101010') AS BINARY)) AS direct,
        (
          SELECT x
          FROM (
            SELECT HEX(CAST(ABS(b'101010') AS BINARY)) AS x
          ) q
        ) AS derived;
       
      +--------+---------+
      | direct | derived |
      +--------+---------+
      | 3432   | 34      |
      +--------+---------+
      1 row in set (0.001 sec)
      

      The same deterministic expression returns different results depending on whether it is evaluated directly or through a derived table.
      HEX(CAST(ABS(b'101010') AS BINARY)) evaluates to 3432 directly, but the same expression is truncated to 34 when passed through a derived table.

      This appears to be a wrong-result issue caused by incorrect expression length/type metadata propagation in the derived-table path.

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            ammmkilo ammmkilo
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.