[MDEV-7853] ORDER BY not working correctly in subquery Created: 2015-03-27  Updated: 2015-03-27  Resolved: 2015-03-27

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Subquery
Affects Version/s: 10.0.17, 10.1.3
Fix Version/s: N/A

Type: Bug Priority: Blocker
Reporter: m.rygiel Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
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.



 Comments   
Comment by Sergei Golubchik [ 2015-03-27 ]

It's not a bug, see Why is ORDER BY in a FROM Subquery Ignored?

Generated at Thu Feb 08 07:22:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.