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

Wrong result with outer join, merged derived table and view

    XMLWordPrintable

Details

    Description

      Table Elimination works wrong for the view. Ex:
      (EDIT : Table Elimination doesn't have anything to do with this bug)

      Test:

      CREATE TABLE t1 (
        PostID int(10) unsigned NOT NULL
      ) DEFAULT CHARSET=utf8;
       
      INSERT INTO t1 (PostID) VALUES (1), (2);
       
      CREATE TABLE t2 (
        VoteID int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
        EntityID int(10) unsigned NOT NULL,
        UserID int(10) unsigned NOT NULL,
        UNIQUE KEY EntityID (EntityID,UserID)
      ) DEFAULT CHARSET=utf8;
        
      INSERT INTO t2 (EntityID, UserID) VALUES (1,  30), (2, 30);
       
      CREATE VIEW v1 as SELECT t1.*, T.Voted as Voted
      FROM 
      t1 LEFT JOIN (
        SELECT 1 AS Voted, EntityID 
        FROM t2 
        WHERE t2.UserID = '20' ) AS T 
        ON T.EntityID = t1.PostID
      WHERE t1.PostID='1'
      LIMIT 1;
      SELECT * FROM  v1;
       
      DROP VIEW v1;
      DROP TABLE t1,t2;
      

      Actual result:

      PostID	Voted
      1	1
      

      Expected result:

      PostID	Voted
      1	NULL
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              lstartseva Lena Startseva
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.