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

LP:793589 - Wrong result with double ORDER BY

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      Reproducible on maria-5.2, maria-5.3.

      If a query containing a double ORDER BY is used in a VIEW, selecting from that view returns only some of the rows of the original query.

      test case:

      CREATE TABLE t1 ( f1 int NOT NULL , f10 int, f11 varchar(32), PRIMARY KEY (f1)) ;
      INSERT IGNORE INTO t1 VALUES (6,0,'j'),(7,0,'z'),(8,0,'c'),(9,0,'a'),(10,0,'q');

      CREATE TABLE t2 ( f11 int) ;
      INSERT IGNORE INTO t2 VALUES (0),(0);

      CREATE OR REPLACE VIEW v1 AS
      SELECT alias2.f11 AS field1
      FROM t2 STRAIGHT_JOIN
      ( t1 AS alias2
       RIGHT JOIN t1 AS alias3 ON alias3.f10 = alias2.f10 )
       ON alias3.f1 = alias2.f1
       GROUP BY field1
      ORDER BY alias3.f1 , alias2.f1 ;
      SELECT * FROM v1;

      should return 5 rows, returns only 1

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            philipstoev Philip Stoev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 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.