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

Wrong result upon executing query with HAVING as a SELECT item

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11
    • 10.5, 10.6, 10.11
    • Optimizer

    Description

      CREATE TABLE t (pk int PRIMARY KEY);
      INSERT INTO t (pk) VALUES (1),(2),(3);
       
      SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1;
      SELECT (SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1) s;
       
      # Cleanup
      DROP TABLE t;
      

      10.3 7a98d232

      SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1;
      pk
      3
      SELECT (SELECT pk FROM t GROUP BY pk HAVING pk != 0 ORDER BY pk DESC LIMIT 1) s;
      s
      1
      

      3 is the expected result.
      Reproducible with at least MyISAM, InnoDB, Aria.

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.