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

ORDER BY not working correctly in subquery

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Not a Bug
    • Affects Version/s: 10.0.17, 10.1.3
    • Fix Version/s: N/A
    • Labels:
      None
    • Environment:
      10.1.3 - CentOS 6
      10.0.17 - Windows 7

      Description

      This test case

      SELECT
      	*
      FROM
      	(
      		SELECT
      			*
      		FROM
      			(
      					SELECT
      						1 AS agency_id,
      						15 AS employee_id
      				UNION ALL 
      					SELECT
      						1 AS agency_id,
      						200 AS employee_id
      				UNION ALL
      					SELECT
      						1 AS agency_id,
      						688 AS employee_id
      				UNION ALL
      					SELECT
      						2 AS agency_id,
      						1 AS employee_id
      				UNION ALL 
      					SELECT
      						2 AS agency_id,
      						2 AS employee_id
      			) MN
      		ORDER BY
      			MN.agency_id ASC,
      			MN.employee_id DESC
      	) T
      GROUP BY
      	T.agency_id
      

      ...produce diffrent results comparing to standard MySQL 5.6 edition.

      MySQL 5.6 standard result:
      "1" "688"
      "2" "2"

      MariaDB 10.1.3 / 10.0.17 result:
      "1" "15"
      "2" "1"

      As u can see - data is re-ordered again after leaving subquery, this is potentially very serious bug.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -
            Show
            serg Sergei Golubchik added a comment - It's not a bug, see Why is ORDER BY in a FROM Subquery Ignored?

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                m.rygiel m.rygiel
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: