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

Qualifying rows disappear when a constant derived-table column drives both filtering and window MIN

    XMLWordPrintable

Details

    Description

      the derived table `(SELECT t0.c0 AS c1 FROM t0, t2)` contributes the single constant `10`, so the predicate `t1.c0 < subq0.c1` should keep both outer rows `1` and `3`. Each output row must therefore carry `MIN(subq0.c1) OVER () = 10`. MariaDB instead drops all qualifying rows and returns an empty result.

      CREATE TABLE t0(c0 BIGINT UNIQUE NOT NULL);
      CREATE TABLE t1(c0 BIGINT UNIQUE NOT NULL);
      CREATE TABLE t2(c0 BOOLEAN NOT NULL, PRIMARY KEY(c0));

      INSERT INTO t0 VALUES (10);
      INSERT INTO t1 VALUES (1), (3);
      INSERT INTO t2 VALUES (TRUE);

      SELECT MIN(subq0.c1) OVER (), t1.c0
      FROM t1,
      (SELECT t0.c0 AS c1 FROM t0, t2) AS subq0
      WHERE (t1.c0 < subq0.c1); – Expected correct result: 10 | 1 ; 10 | 3 – 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.