Bug #35569 SELECT ... WHERE datetime NOT IN (0, ...) crashes server
Submitted: 26 Mar 2008 11:22 Modified: 26 Mar 2008 11:48
Reporter: Jean-Hervé Quillien Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: General Severity:S1 (Critical)
Version:5.0.26 OS:Linux (OVH build)
Assigned to: CPU Architecture:Any
Tags: crash, datetime, SELECT

[26 Mar 2008 11:22] Jean-Hervé Quillien
Description:
Description:
A query crashes the server; has been reproducted after clean mysqld restart, each time it crashes the same way. This has not been tested on other servers.

Error log:
mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=1342177280
read_buffer_size=8384512
max_used_connections=23
max_connections=350
threads_connected=8
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 38582917 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0xe11390
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0x2b53b5acbda8, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x6c2d36322e302e35
New value of fp=0xe11390 failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/Using_stack_trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0xc6f3c0 = SELECT r.id, r.datetime
                        FROM cc_emitted_reports r
                        WHERE datetime NOT IN ('0','2008-04-10 00:00:00')
                        ORDER BY datetime DESC
                        LIMIT 1
thd->thread_id=2164
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.

NB : If you take out the '0', in the WHERE, it doesn't crash anymore

How to repeat:
CREATE TABLE `cc_emitted_reports` (
 `id` int(11) unsigned NOT NULL auto_increment,
 `datetime` datetime NOT NULL,
 `captured` smallint(5) unsigned NOT NULL,
 `captured_eur` float NOT NULL,
 `explanation` varchar(255) NOT NULL,
 PRIMARY KEY  (`id`),
 KEY `datetime` (`datetime`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `cc_emitted_reports` (`id`, `datetime`, `captured`, `captured_eur`, `explanation`) VALUES
(1, '2008-03-10 00:00:00', 12, 3385.84, 'Remis en banque (d''après banque)'),
(2, '2008-04-10 00:00:00', 5, 1166.79, 'Pas encore remis en banque');

THE SQL SELECT which makes the server crash (has been executed through PHP or phpmyadmin, it crashes the same way):

SELECT r.id, r.datetime
                       FROM cc_emitted_reports r
                       WHERE datetime NOT IN ('0','2008-04-10 00:00:00')
                       ORDER BY datetime DESC
                       LIMIT 1
[26 Mar 2008 11:48] MySQL Verification Team
Thank you for the bug report. I could not repeat with current source server,
the server you have reported is quite older, please upgrade to latest released
version.

[miguel@amanhecer dbs]$ 5.0/bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.60-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SELECT r.id, r.datetime
    ->                        FROM cc_emitted_reports r
    ->                        WHERE datetime NOT IN ('0','2008-04-10 00:00:00')
    ->                        ORDER BY datetime DESC
    ->                        LIMIT 1;
+----+---------------------+
| id | datetime            |
+----+---------------------+
|  1 | 2008-03-10 00:00:00 | 
+----+---------------------+
1 row in set, 1 warning (0.01 sec)

mysql>