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

LP:993726 - Wrong result from a query with ALL subquery predicate in WHERE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      The following sequence of commands returns an incorrect result set in maridb-5.2:

      CREATE TABLE t1(a INT);
      INSERT INTO t1 VALUES (0);
      SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0);

      MariaDB [test]> SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0);
      Empty set (0.00 sec)

      (see also bug #12888306 for mysql code line)

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            sanja Oleksandr Byelkin added a comment -

            Re: Wrong result from a query with ALL subquery predicate in WHERE
            1) The problem is not repeatable on mysql-test run.
            2) it is repeatable om 5.1, 5.2, 5.3, 5.5

            Show
            sanja Oleksandr Byelkin added a comment - Re: Wrong result from a query with ALL subquery predicate in WHERE 1) The problem is not repeatable on mysql-test run. 2) it is repeatable om 5.1, 5.2, 5.3, 5.5
            Hide
            sanja Oleksandr Byelkin added a comment -

            Re: Wrong result from a query with ALL subquery predicate in WHERE
            In mysql-test and mysql execution looks same and return_zero_rows called in both cases, so we probably have some other bug in mysql-test so it returns 1

            Show
            sanja Oleksandr Byelkin added a comment - Re: Wrong result from a query with ALL subquery predicate in WHERE In mysql-test and mysql execution looks same and return_zero_rows called in both cases, so we probably have some other bug in mysql-test so it returns 1
            Hide
            elenst Elena Stepanova added a comment -

            Re: Wrong result from a query with ALL subquery predicate in WHERE
            If that's what you see in MTR output

            CREATE TABLE t1(a INT);
            INSERT INTO t1 VALUES (0);
            SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0);
            1

            it does not mean that mysqltest returns 1; '1' is the automatic column name here, while the result is empty. If it was returning a result, it would look like this:

            SELECT 1 FROM t1;
            1
            1

            Show
            elenst Elena Stepanova added a comment - Re: Wrong result from a query with ALL subquery predicate in WHERE If that's what you see in MTR output CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (0); SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0); 1 it does not mean that mysqltest returns 1; '1' is the automatic column name here, while the result is empty. If it was returning a result, it would look like this: SELECT 1 FROM t1; 1 1
            Hide
            sanja Oleksandr Byelkin added a comment -

            Re: Wrong result from a query with ALL subquery predicate in WHERE
            The problem is that constant WHERE condition (the subquery) evaluates incorrectly to 0 in optimize_cond (in the SELECT list the subquery returns correct result - TRUE).

            Show
            sanja Oleksandr Byelkin added a comment - Re: Wrong result from a query with ALL subquery predicate in WHERE The problem is that constant WHERE condition (the subquery) evaluates incorrectly to 0 in optimize_cond (in the SELECT list the subquery returns correct result - TRUE).
            Hide
            sanja Oleksandr Byelkin added a comment -

            Re: Wrong result from a query with ALL subquery predicate in WHERE
            The problem is that in the subquery set do_send_rows so it does not send empty set in case of FALSE WHERE clause...

            Show
            sanja Oleksandr Byelkin added a comment - Re: Wrong result from a query with ALL subquery predicate in WHERE The problem is that in the subquery set do_send_rows so it does not send empty set in case of FALSE WHERE clause...
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 993726

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 993726

              People

              • Assignee:
                sanja Oleksandr Byelkin
                Reporter:
                igor Igor Babaev
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: