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

LP:938518 - HAVING does not reject the result of aggregation

    Details

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

      Description

      Using mariadb-5.2 create and populate table 1 with the following commands:

      CREATE TABLE t1 (pk INT PRIMARY KEY, a INT);
      INSERT INTO t1 VALUES (2,7), (4,7), (6,2), (17,0);

      Execute the following queries:
      SELECT MIN(t.pk) FROM t1, t1 as t WHERE t1.pk = 1;
      SELECT MIN(t.pk) FROM t1, t1 as t WHERE t1.pk = 1 HAVING MIN(t.pk) < 10;

      The first query return the right result while the second query returns a wrong result:

      MariaDB [test]> SELECT MIN(t.pk) FROM t1, t1 as t WHERE t1.pk = 1;
      -----------

      MIN(t.pk)

      -----------

      NULL

      -----------

      MariaDB [test]> SELECT MIN(t.pk) FROM t1, t1 as t WHERE t1.pk = 1 HAVING MIN(t.pk) < 10;
      -----------

      MIN(t.pk)

      -----------

      NULL

      -----------

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 938518

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

              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: