Bug #275 ORDER BY being discarded and results are returned un-sorted

Submitted: 11 Apr 2003 9:57 Modified: 11 Apr 2003 9:58
Reporter: SINISA MILIVOJEVIC Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0 OS:Any (ALL)
Assigned to: Sergei Glukhov CPU Architecture:Any

[11 Apr 2003 9:57] SINISA MILIVOJEVIC
Description:
Although ORDER BY is issued on a column in the select list, rows in result set are un-sorted.

How to repeat:
drop table if exists t1;
create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) type = innodb;
insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
select distinct  parent,child   from t1   order by parent;
drop table t1;

Suggested fix:
fix the optimiser
[11 Apr 2003 9:58] MySQL Verification Team
===== sql/sql_select.cc 1.228 vs edited =====
*** /tmp/sql_select.cc-1.228-3602       Thu Mar 13 13:42:44 2003
--- edited/sql/sql_select.cc    Fri Apr 11 19:33:39 2003
***************
*** 555,560 ****
--- 555,562 ----
        /*  Change DISTINCT to GROUP BY */
        select_distinct= 0;
        no_order= !order;
+       if (order && skip_sort_order)
+         join.tmp_table_param.quick_group=0;
        if (all_order_fields_used)
          order=0;
        join.group=1;                           // For end_write_group

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.