Description:
Some subselect queries crashes mysqld
(on both MyISAM and InnoDB table types).
Here is stack trace:
------------ MySQL 4.1.1 ----------------
0x8086bd3 handle_segfault + 423
0x82d03c8 pthread_sighandler + 184
0x80e96bd sortlength__FP13st_sort_fieldUiPb + 73
0x80e7cbc filesort__FP3THDP8st_tableP13st_sort_fieldUiP10SQL_SELECTUlPUl + 124
0x80bfe8a create_sort_index__FP3THDP4JOINP8st_orderUlUl + 338
0x80b44cb exec__4JOIN + 4111
0x80b4a3c mysql_select__FP3THDPPP4ItemP13st_table_listUiRt4List1Z4ItemP4ItemUiP8
st_orderT7T5T7UlP13select_resultP18st_select_lex_unitP13s + 832
0x811a76b mysql_derived__FP3THDP6st_lexP18st_select_lex_unitP13st_table_list + 6
99
0x8093bf9 mysql_execute_command__FP3THD + 309
0x80988d9 mysql_parse__FP3THDPcUi + 177
0x8092cdf dispatch_command__F19enum_server_commandP3THDPcUi + 1635
0x8092671 do_command__FP3THD + 161
0x8091df9 handle_one_connection + 549
0x82cdb7c pthread_start_thread + 220
0x830355a thread_start + 4
------------ MySQL 5.0.0 ----------------
0x80880d3 handle_segfault + 423
0x82df1d8 pthread_sighandler + 184
0x80b42f2 fill_record__FPP5FieldRt4List1Z4Itemb + 70
0x8121eec send_data__12select_unionRt4List1Z4Item + 60
0x80c44cf end_send_group__FP4JOINP13st_join_tableb + 355
0x80c3268 sub_select__FP4JOINP13st_join_tableb + 52
0x80c303b do_select__FP4JOINPt4List1Z4ItemP8st_tableP9Procedure + 451
0x80ba019 exec__4JOIN + 4237
0x80ba542 mysql_select__FP3THDPPP4ItemP13st_table_listUiRt4List1Z4ItemP4ItemUiP8
st_orderT7T5T7UlP13select_resultP18st_select_lex_unitP13s + 838
0x812353b mysql_derived__FP3THDP6st_lexP18st_select_lex_unitP13st_table_list + 6
99
0x809597e mysql_execute_command__FP3THD + 378
0x809afc9 mysql_parse__FP3THDPcUi + 185
0x8094a1f dispatch_command__F19enum_server_commandP3THDPcUi + 1659
0x809439a do_command__FP3THD + 218
0x8093aea handle_one_connection + 602
0x82dc98c pthread_start_thread + 220
0x83124ca thread_start + 4
How to repeat:
CREATE TABLE `itemprices` (
`itemid` int(11) NOT NULL default '0',
`grpid` varchar(15) NOT NULL default '',
`vendor` int(11) NOT NULL default '0',
`date_` date NOT NULL default '0000-00-00',
`price` decimal(12,2) NOT NULL default '0.00',
PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`),
KEY `itemid` (`itemid`,`vendor`),
KEY `itemid_2` (`itemid`,`date_`)
) ENGINE=InnoDB;
insert into itemprices values (128, 'rozn', 2, now(), 10);
insert into itemprices2 values (128, 'rozn', 1, now(), 10);
SELECT MIN(price) min, MAX(price) max, AVG(price) avg
FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price
FROM itemprices
WHERE itemid=128 AND grpid='rozn'
GROUP BY itemid, grpid, vendor) lastprices;