Bug #55565 debug assertion when ordering by expressions with user variable assignments
Submitted: 26 Jul 2010 17:17 Modified: 15 Oct 2010 13:57
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S1 (Critical)
Version:5.1.49-debug OS:Any
Assigned to: Georgi Kodinov CPU Architecture:Any

[26 Jul 2010 17:17] Shane Bester
Description:
last saw this in bug #42778 ...

Version: '5.1.49-enterprise-gpl-advanced-debug'  socket: ''  port: 3306  MySQL Enterprise Server
Assertion failed: 0, file .\filesort.cc, line 799
mysqld-debug.exe!my_sigabrt_handler()[mysqld.cc:2083]
mysqld-debug.exe!raise()[winsig.c:597]
mysqld-debug.exe!abort()[abort.c:78]
mysqld-debug.exe!_wassert()[assert.c:212]
mysqld-debug.exe!make_sortkey()[filesort.cc:799]
mysqld-debug.exe!find_all_keys()[filesort.cc:620]
mysqld-debug.exe!filesort()[filesort.cc:247]
mysqld-debug.exe!create_sort_index()[sql_select.cc:13849]
mysqld-debug.exe!JOIN::exec()[sql_select.cc:2271]
mysqld-debug.exe!mysql_select()[sql_select.cc:2519]
mysqld-debug.exe!handle_select()[sql_select.cc:269]
mysqld-debug.exe!execute_sqlcom_select()[sql_parse.cc:5093]
mysqld-debug.exe!mysql_execute_command()[sql_parse.cc:2287]
mysqld-debug.exe!mysql_parse()[sql_parse.cc:6021]
mysqld-debug.exe!dispatch_command()[sql_parse.cc:1256]
mysqld-debug.exe!do_command()[sql_parse.cc:882]
mysqld-debug.exe!handle_one_connection()[sql_connect.cc:1136]
mysqld-debug.exe!pthread_start()[my_winthread.c:85]
mysqld-debug.exe!_callthreadstart()[thread.c:295]
mysqld-debug.exe!_threadstart()[thread.c:277]

How to repeat:
#on debug build:

drop table if exists `t1`;
create table `t1`(`a` double not null)engine=myisam;
insert into `t1` values (0),(9.216e-096);
select 1 from `t1` order by @`a`:=makedate(`a`,`a`);
[26 Jul 2010 17:26] MySQL Verification Team
Thank you for the bug report.

terribly wrong...
00000001400579E5    mysqld.exe!my_sigabrt_handler()[mysqld.cc:2049]
000000014000BB61    mysqld.exe!raise()[winsig.c:597]
0000000140014133    mysqld.exe!abort()[abort.c:78]
00000001405D4A1A    mysqld.exe!_wassert()[assert.c:395]
0000000140313C86    mysqld.exe!make_sortkey()[filesort.cc:799]
0000000140312E64    mysqld.exe!find_all_keys()[filesort.cc:620]
0000000140311A77    mysqld.exe!filesort()[filesort.cc:247]
00000001402D4CDD    mysqld.exe!create_sort_index()[sql_select.cc:13831]
00000001402B1169    mysqld.exe!JOIN::exec()[sql_select.cc:2263]
00000001402B1FFB    mysqld.exe!mysql_select()[sql_select.cc:2511]
00000001402A8868    mysqld.exe!handle_select()[sql_select.cc:269]
000000014021229A    mysqld.exe!execute_sqlcom_select()[sql_parse.cc:5075]
0000000140208515    mysqld.exe!mysql_execute_command()[sql_parse.cc:2271]
0000000140215005    mysqld.exe!mysql_parse()[sql_parse.cc:5998]
00000001402059EA    mysqld.exe!dispatch_command()[sql_parse.cc:1243]
0000000140204C8A    mysqld.exe!do_command()[sql_parse.cc:882]
00000001400C7EC5    mysqld.exe!handle_one_connection()[sql_connect.cc:1134]
00000001406075E5    mysqld.exe!pthread_start()[my_winthread.c:85]
00000001405DD805    mysqld.exe!_callthreadstart()[thread.c:295]
00000001405DD7D7    mysqld.exe!_threadstart()[thread.c:277]
000000007775BE3D    kernel32.dll!BaseThreadInitThunk()
0000000077966A51    ntdll.dll!RtlUserThreadStart()
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0000000000D00838=select 1 from `t1` order by @`a`:=makedate(`a`,`a`)
thd->thread_id=3
thd->killed=NOT_KILLED
[13 Aug 2010 13:06] 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/115676

3482 Georgi Kodinov	2010-08-13
      Bug #55565: debug assertion when ordering by expressions with user 
      variable assignments
      
      The assert() that is firing is checking if expressions that can't be
      null return a NULL when evaluated.
      MAKEDATE() function can return NULL if the second argument is 
      less then or equal to 0. Thus its nullability depends not only on 
      the nullability of its arguments but also on their values.
      Fixed by (overoptimistically) setting MAKEDATE() to be nullable 
      despite the nullability of its arguments.
      Test added.
      Had to update one test result to reflect the metadata change.
[21 Aug 2010 1:36] Paul DuBois
Noted in 5.1.51, 5.5.6 changelogs.

ORDER BY clauses that included user variable expressions could cause
a debug assertion to be raised. 

Setting report to Need Merge pending push to 5.6.x.
[25 Aug 2010 10:24] Bugs System
Pushed into mysql-5.5 5.5.6-m3 (revid:alik@ibmvm-20100825102234-a3q8x0l7voa13ts3) (version source revid:alik@ibmvm-20100825102234-a3q8x0l7voa13ts3) (merge vers: 5.5.6-m3) (pib:20)
[26 Aug 2010 2:23] Paul DuBois
Setting report to Need Merge pending push to 5.6.x.
[1 Sep 2010 13:13] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100901130501-4g2k86dub29auj8y) (version source revid:alik@sun.com-20100901130012-9bmmvzcnnw6n5rw6) (merge vers: 5.6.1-m4) (pib:21)
[1 Sep 2010 13:15] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100901130614-pgop3m80rmutewxn) (version source revid:alik@sun.com-20100901130033-8k19cjn6n2blm3py) (pib:21)
[2 Sep 2010 1:01] Paul DuBois
Noted in 5.6.1 changelog.
[28 Sep 2010 8:49] Bugs System
Pushed into mysql-5.1 5.1.52 (revid:sunanda.menon@sun.com-20100928083322-wangbv97uobu7g66) (version source revid:sunanda.menon@sun.com-20100928083322-wangbv97uobu7g66) (merge vers: 5.1.52) (pib:21)
[14 Oct 2010 8:39] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[14 Oct 2010 8:54] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[14 Oct 2010 9:11] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (merge vers: 5.1.51-ndb-6.2.19) (pib:21)
[15 Oct 2010 13:57] Jon Stephens
Already documented in the 5.1.51 changelog. Reverting to Closed state.