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

Inconsistent Results When Using IFNULL

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 10.6.9
    • N/A
    • N/A
    • None

    Description

      There is an inconsistency in the results when using the IFNULL function.

      1. Set up table t0:

      CREATE TABLE t0 (c0 BIT, c1 BIT);
      INSERT INTO t0 VALUES (0, 1);
      

      2. Use IFNULL in a SELECT query:

      SELECT (IFNULL(t0.c0, t0.c1)) FROM t0;
      --Result: 48
      

      3. Store the result of COALESCE in another table t1 and SELECT FROM t1:

      CREATE TABLE t1 AS (SELECT (IFNULL(t0.c0, t0.c1)) AS c0 FROM t0);
      SELECT * FROM t1;
      --Result: 0
      

      See: https://dbfiddle.uk/Mf6xPcJK
      The result should be consistent regardless of whether the result is directly selected or stored in another table.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dwenking Wenqian Deng
            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.