Bug #6082 Selecting data from HEAP tables with NOT NULL condition kills the server
Submitted: 14 Oct 2004 6:39 Modified: 22 Oct 2004 23:10
Reporter: Dmitry L Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.3 OS:Windows (w2k)
Assigned to: Michael Widenius CPU Architecture:Any

[14 Oct 2004 6:39] Dmitry L
Selecting data from HEAP tables with NOT NULL condition kills the server

How to repeat:
                    id INT(10) NOT NULL,
                    pid INT(10) NOT NULL,
                    map SMALLINT(6),
                    proto INT(10),
                    KEY `id` (`id`),
                    KEY `pid` (`pid`),
                    KEY `map` (`map`)
                  ) ENGINE=HEAP;

INSERT INTO tmp VALUES(1,1, NULL, 1), (1,1,1,1);
SELECT * FROM `tmp` WHERE map is not null;
[14 Oct 2004 10:39] MySQL Verification Team
Verified with BK 4.1 and 5.0 trees.
OC: Windows, Linux
With 4.0 it works fine.

Back trace:
(gdb) bt
#0  0x081da7fa in ha_heap::records_in_range (this=0x8cee8d8, inx=2, min_key=0xbdbfde20, max_key=0x0)
    at ha_heap.cc:384
#1  0x081d05b1 in check_quick_keys (param=0xbdbfdef4, idx=0, key_tree=0x8d04998, min_key=0xbdbfe130 "\001",
    min_key_flag=0, max_key=0xbdbfe82e "", max_key_flag=0) at opt_range.cc:2348
#2  0x081cffa0 in check_quick_select (param=0xbdbfdef4, idx=0, tree=0x8d04998) at opt_range.cc:2243
#3  0x081cc73e in SQL_SELECT::test_quick_select (this=0x8cf8590, thd=0x8ce86a0, keys_to_use={map = 4},
    prev_tables=0, limit=4294967295, force_quick_range=false) at opt_range.cc:727
#4  0x08192284 in get_quick_record_count (thd=0x8ce86a0, select=0x8cf8590, table=0x8d03858, keys=0x8cf836c,
    limit=4294967295) at sql_select.cc:1621
#5  0x08193068 in make_join_statistics (join=0x8cf7668, tables=0x0, conds=0x8cf75e8, keyuse_array=0x8cf7f98)
    at sql_select.cc:1910
#6  0x0818f396 in JOIN::optimize (this=0x8cf7668) at sql_select.cc:543
#7  0x08192117 in mysql_select (thd=0x8ce86a0, rref_pointer_array=0x8ce88cc, tables=0x8cf7518, wild_num=1,
    fields=@0x8ce8830, conds=0x8cf75e8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0,
    select_options=42224128, result=0x8cf7658, unit=0x8ce86e4, select_lex=0x8ce87c8) at sql_select.cc:1570
#8  0x0818e84c in handle_select (thd=0x8ce86a0, lex=0x8ce86d8, result=0x8cf7658) at sql_select.cc:193
#9  0x0816c3fc in mysql_execute_command (thd=0x8ce86a0) at sql_parse.cc:1991
#10 0x08171121 in mysql_parse (thd=0x8ce86a0, inBuf=0x8cf7410 "SELECT * FROM `tmp` WHERE map is not null",
    length=41) at sql_parse.cc:4046
#11 0x0816b106 in dispatch_command (command=COM_QUERY, thd=0x8ce86a0,
    packet=0x8cea2d9 "SELECT * FROM `tmp` WHERE map is not null", packet_length=42) at sql_parse.cc:1485
#12 0x0816aa32 in do_command (thd=0x8ce86a0) at sql_parse.cc:1272
#13 0x0816a007 in handle_one_connection (arg=0x8ce86a0) at sql_parse.cc:1016
#14 0x4017414b in pthread_start_thread () from /lib/libpthread.so.0
#15 0x401741df in pthread_start_thread_event () from /lib/libpthread.so.0
#16 0x402df50a in clone () from /lib/libc.so.6
[22 Oct 2004 23:10] Michael Widenius
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

Additional info:

Fix will be in 4.1.7 or 4.1.8