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

MIN over an empty Aria-backed derived table leaks the inner COALESCE fallback value'

    XMLWordPrintable

Details

    Description

      the inner derived table `FROM t2, t0` is empty because `t2` is empty, so after the outer `LEFT JOIN` the only group's `MIN(subq0.c0)` must be NULL. MariaDB instead leaks the inner expression fallback `COALESCE(t0.c0, 857903360)` and returns `857903360`.

      CREATE TABLE t0(c0 SMALLINT UNIQUE NOT NULL, PRIMARY KEY(c0)) ENGINE=Aria;
      CREATE TABLE t1(c0 INT PRIMARY KEY);
      CREATE TABLE t2(c0 INT);

      INSERT INTO t1 VALUES (9292167);

      SELECT MIN(subq0.c0)
      FROM t1
      LEFT JOIN (
      SELECT COALESCE(t0.c0, 857903360) AS c0, t0.c0 AS c1
      FROM t2, t0
      ) AS subq0
      ON ((t1.c0 < subq0.c0) AND (subq0.c1 < -524306258) AND (subq0.c0 IS NULL))
      GROUP BY COALESCE(subq0.c0, 1172511830); – Expected correct result: NULL – actual Wrong result: 857903360

      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.