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

WHERE x > ALL returns rows for which the identical projected predicate is false

    XMLWordPrintable

Details

    Description

      Description

      MariaDB Server 12.3.2 returns an extra row for `x > ALL` over a UNION of an integer column and an empty BLOB operand. With integer values 9 and 86 in the subquery, the WHERE form incorrectly accepts x=50. Projecting the identical predicate returns false for 50 and true for 90.

      Casting the empty BLOB operand to a numeric type, or removing that operand, returns only the correct row. The observations suggest an interaction between set-operation output coercion and the WHERE evaluation path; no source debugging has established the internal cause.

      How to repeat

      CREATE TEMPORARY TABLE all_nums (v INT);
      INSERT INTO all_nums VALUES (9),(86);
      CREATE TEMPORARY TABLE all_binary (b BLOB);
      INSERT INTO all_binary VALUES ('0');
      CREATE TEMPORARY TABLE all_outer (x INT);
      INSERT INTO all_outer VALUES (50),(90);
       
      SELECT x FROM all_outer WHERE x>ALL(
          SELECT v FROM all_nums UNION SELECT b FROM all_binary WHERE FALSE
      );
      

      Expected result

      Only x=90. The second UNION operand contributes no rows. 50 is not greater than 86, while 90 is greater than both 9 and 86.

      Actual result

      Two rows: x=50 and x=90.

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            chen7897 cl hl
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.