Bug #18386 SELECT with ORDER BY causes a crash
Submitted: 21 Mar 2006 11:27 Modified: 31 Mar 2006 7:50
Reporter: Horst Hunger Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Views Severity:S2 (Serious)
Version:5.0, 5.1 OS:Linux (Linux 9.3)
Assigned to: Igor Babaev CPU Architecture:Any

[21 Mar 2006 11:27] Horst Hunger
Description:
The MySQl server crashed after adding an ORDER BY to a SELECT on a VIEW as follows:

CREATE TABLE t1 (f2 BIGINT) ENGINE = myisam;
# without sqrt function successful select: CREATE VIEW v1 AS SELECT f1, f2 my_sqrt FROM t1;
CREATE VIEW v1 AS SELECT SQRT(f2) my_sqrt FROM t1;
SELECT my_sqrt FROM v1 order by my_sqrt;
# SELECT f1, my_sqrt FROM v1 order by my_sqrt;
# harmless, as successful: SELECT  f1, SQRT(f2) my_sqrt FROM t1 order by my_sqrt;

The crash occurs also with the engines memory, innodb and ndb.
No crash in 5.0 with these enines (ndb was not used).

How to repeat:
Put the code (without comments) above into a file and use mysql or mysql-test-run.
[28 Mar 2006 2:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4219
[28 Mar 2006 17:43] Igor Babaev
ChangeSet
  1.2098 06/03/27 18:28:55 igor@rurik.mysql.com +3 -0
  Fixed bug #18386.
  An invalid assertion in Item_direct_view_ref::eq caused 
  an assertion abort in the debug version.

Fix will appear in 5.0.20. It was merged into 5.1
[31 Mar 2006 7:50] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented bugfix in 5.0.20 and 5.1.8 changelogs. Closed.