Bug #967 Invalid sorting with ENUM fields
Submitted: 31 Jul 2003 11:12 Modified: 14 Feb 2005 12:08
Reporter: [ name withheld ]
Status: No Feedback
Category:Server Severity:S2 (Serious)
Version:4.0.14, 3.23.x OS:FreeBSD (FreeBSD 4.6)
Assigned to: Target Version:

[31 Jul 2003 11:12] [ name withheld ]
Description:
When sorting table by enum field and next with some integer field, table is wrongly
sorted. Enum field is sorted ok, but sorting by integer within same enum value is wrong.

How to repeat:
I simplified my situation:

CREATE TABLE Test(
  Type enum('a','b') NOT NULL,
  Length tinyint unsigned NOT NULL
);

INSERT INTO Test VALUES ('a', 1);
INSERT INTO Test VALUES ('a', 2);
INSERT INTO Test VALUES ('a', 3);
INSERT INTO Test VALUES ('b', 3);
INSERT INTO Test VALUES ('b', 2);
INSERT INTO Test VALUES ('b', 1);

SELECT * FROM Test ORDER BY Type, Length;

give results:

+------+--------+
| Type | Length |
+------+--------+
| a    |      1 |
| a    |      2 |
| a    |      3 |
| b    |      2 |
| b    |      3 |
| b    |      1 |
+------+--------+

Suggested fix:
sory, dunno
[31 Jul 2003 13:31] Indrek Siitan
Does the provided simplified test case behave as described for you?
Are you using our binary or did you compile MySQL yourself (either
manually or from the ports tree)?

I just tried 4.0.13 and 4.0.13 on FreeBSD 4.6 and 4.1.0 on Mac OS X
and all of them returned the correct result.
[5 Aug 2004 19:06] Jakub Vrana
I reproduced this bug with 4.0.18 on Linux.
[14 Feb 2005 12:08] Sergei Golubchik
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.