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

COALESCE with typeless NULL changes hex literal Boolean evaluation from true to false

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 13.0.2
    • None
    • None
    • None
    • Linux/amd64

    Description

      On MariaDB 13.0.2 on Linux/amd64, passing the nonzero hex literal 0x30 through COALESCE(NULL, ...) changes its Boolean numeric evaluation. The wrapped expression becomes false under XOR 0, while the unwrapped literal remains true and arithmetic coercion shows that the wrapped value is still 48.

      Minimal query

      -- Oracle: bare=1, wrapped=1, numeric_value=48, pass=1.
      -- 0x30 is nonzero integer 48; its bytes spell '0'. A retained hybrid
      -- must retain its numeric truth value through a NULL-only wrapper.
      SELECT (0x30 XOR 0) AS bare,
             (COALESCE(NULL,0x30) XOR 0) AS wrapped,
             COALESCE(NULL,0x30)+0 AS numeric_value,
             ((COALESCE(NULL,0x30) XOR 0) <=> (0x30 XOR 0)) AS pass;
      SELECT 1 AS cleanup_complete;

      Why the result is inconsistent

      The first row currently returned is:

      1	0	48	0

      The bare and wrapped expressions both resolve to the same nonzero value. The first row should therefore be:

      1	1	48	1

      0x30 has the numeric value 48, and a NULL-only conditional wrapper should preserve the surviving hex literal's numeric semantics. The discrepancy reproduced twice without errors or warnings; the completion query returned 1 and the server remained healthy. An explicit numeric cast or arithmetic coercion before Boolean use avoids the problem.

      Attachments

        Activity

          People

            Unassigned Unassigned
            faner fan
            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.