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

A grouped query over an empty MyISAM LEFT JOIN returns empty because an unused window AVG corrupts MAX()

    XMLWordPrintable

Details

    Description

      the inner derived table is exactly `(NULL, 2)` and `(NULL, 9)`, so after `GROUP BY c1` the unique group's `MAX(c4)` must be `9`. MariaDB instead computes `MAX(c4)` as `2`, so the outer predicate `m = 9` wrongly filters the only row away.

      CREATE TABLE t1(c1 INT) ENGINE=MyISAM;
      CREATE TABLE t2(c0 INT UNIQUE);

      INSERT INTO t2 VALUES (9), (2);

      SELECT 1
      FROM (
      SELECT MAX(subq0.c4) AS m, AVG(subq0.c4) OVER () AS a
      FROM (
      SELECT t1.c1, t2.c0 AS c4
      FROM t2
      LEFT JOIN t1
      ON (FALSE)
      ) AS subq0
      GROUP BY subq0.c1
      ) AS q
      WHERE m = 9; – Expected correct result: 1 – actual Wrong result: <empty>

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              yx yx
              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.