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

A single left-joined derived row disappears before downstream STRAIGHT_JOIN evaluation

    XMLWordPrintable

Details

    • Unexpected results

    Description

      the derived table contributes exactly one row `(47782700, 'child')`, which should first match the `LEFT JOIN` on `t2.c0 = subq0.c1`, then satisfy both downstream predicates `subq0.c0 > t3.c0` and `subq0.c1 != t0.c0`. Therefore the query must return `47782700 | root`. MariaDB instead drops that row before the downstream joins and returns an empty result.

      CREATE TABLE t0(c0 VARCHAR(100) PRIMARY KEY NOT NULL);
      CREATE TABLE t2(c0 VARCHAR(100) PRIMARY KEY NOT NULL);
      CREATE TABLE t3(c0 BOOLEAN, c1 REAL SIGNED UNIQUE NOT NULL, PRIMARY KEY(c0, c1)) ENGINE=Aria;

      INSERT INTO t0 VALUES ('root');
      INSERT INTO t2 VALUES ('child');
      INSERT INTO t3 VALUES (FALSE, 47782700);

      CREATE TEMPORARY TABLE temp_0(t3_c1 DOUBLE NOT NULL, t2_c0 VARCHAR(100) NOT NULL);
      INSERT INTO temp_0
      SELECT t3.c1, t2.c0
      FROM t2, t0, t3
      WHERE (t0.c0 != '#^');

      INSERT INTO temp_0
      SELECT t3.c1, t2.c0
      FROM t2, t0, t3
      WHERE ((NOT ((t0.c0 != '#^') IS TRUE)) AND (t2.c0 != t0.c0));

      SELECT DISTINCT AVG(subq0.c0) OVER (), t0.c0
      FROM t2
      LEFT JOIN (
      SELECT temp_0.t3_c1 AS c0, temp_0.t2_c0 AS c1
      FROM temp_0
      ) AS subq0
      ON (t2.c0 = subq0.c1)
      STRAIGHT_JOIN t3 ON (subq0.c0 > t3.c0)
      STRAIGHT_JOIN t0 ON (subq0.c1 != t0.c0); – Expected correct result: 47782700 | root – 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.