Description:
Crash segfault in 5.1-bugteam tree. Very likely related to Bug#52336, but the patch / fix for this bug does not correct this crash.
Not present in the main tree
Query:
SELECT COUNT( `col_varchar_key` )
FROM B
HAVING ( 7 , 9 ) IN (
SELECT `pk` , MIN( `col_int_key` )
FROM BB ) ;
Crash output (full output attached separately):
Thread 1 (Thread 15177):
#0 0x00564422 in __kernel_vsyscall ()
#1 0x0089ee93 in __pthread_kill (threadid=3067972464, signo=11) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:64
#2 0x085e7041 in my_write_core (sig=11) at stacktrace.c:329
#3 0x08277693 in handle_segfault (sig=11) at mysqld.cc:2570
#4 <signal handler called>
#5 0x08312d64 in copy_fields (param=0xa053df8) at sql_select.cc:15366
#6 0x0830b61e in end_send_group (join=0xa052d98, join_tab=0x0, end_of_records=false) at sql_select.cc:12393
#7 0x08308728 in do_select (join=0xa052d98, fields=0xa053f00, table=0x0, procedure=0x0) at sql_select.cc:11055
#8 0x082f32b8 in JOIN::exec (this=0xa052d98) at sql_select.cc:2315
#9 0x0822ef54 in subselect_single_select_engine::exec (this=0xa068a90) at item_subselect.cc:1972
#10 0x08229725 in Item_subselect::exec (this=0xa0689e0) at item_subselect.cc:265
#11 0x0822b426 in Item_in_subselect::val_bool (this=0xa0689e0) at item_subselect.cc:865
#12 0x081c422a in Item::val_bool_result (this=0xa0689e0) at item.h:745
#13 0x081f1d1b in Item_in_optimizer::val_int (this=0xa068d98) at item_cmpfunc.cc:1833
#14 0x082ff9f3 in return_zero_rows (join=0xa050db0, result=0xa068b20, tables=0xa067e18, fields=..., send_row=true,
select_options=2147764736, info=0x871d3c8 "Impossible HAVING noticed after reading const tables", having=0xa068d98) at sql_select.cc:7274
#15 0x082f15dc in JOIN::exec (this=0xa050db0) at sql_select.cc:1834
#16 0x082f3a18 in mysql_select (thd=0x9fee6d8, rref_pointer_array=0x9fefb78, tables=0xa067e18, wild_num=0, fields=..., conds=0x0, og_num=0,
order=0x0, group=0x0, having=0xa0689e0, proc_param=0x0, select_options=2147764736, result=0xa068b20, unit=0x9fef810,
select_lex=0x9fefa80) at sql_select.cc:2510
#17 0x082ec5e7 in handle_select (thd=0x9fee6d8, lex=0x9fef7b4, result=0xa068b20, setup_tables_done_option=0) at sql_select.cc:269
#18 0x0829291e in execute_sqlcom_select (thd=0x9fee6d8, all_tables=0xa067e18) at sql_parse.cc:5052
#19 0x08289186 in mysql_execute_command (thd=0x9fee6d8) at sql_parse.cc:2248
#20 0x08294b76 in mysql_parse (thd=0x9fee6d8,
inBuf=0xa067ad0 "SELECT COUNT( `col_varchar_key` ) \nFROM B \nHAVING ( 7 , 9 ) IN ( \nSELECT `pk` , MIN( `col_int_key` ) \nFROM BB )", length=126, found_semicolon=0xb6dd8058) at sql_parse.cc:5971
#21 0x08286b27 in dispatch_command (command=COM_QUERY, thd=0x9fee6d8,
packet=0xa03a849 "SELECT COUNT( `col_varchar_key` ) \nFROM B \nHAVING ( 7 , 9 ) IN ( \nSELECT `pk` , MIN( `col_int_key` ) \nFROM BB ) ", packet_length=129) at sql_parse.cc:1233
#22 0x08285c1b in do_command (thd=0x9fee6d8) at sql_parse.cc:874
#23 0x08283fc1 in handle_one_connection (arg=0x9fee6d8) at sql_connect.cc:1127
#24 0x0089980e in start_thread (arg=0xb6dd8b70) at pthread_create.c:300
#25 0x003118de in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
How to repeat:
Simplified query:
Full test case with original and unsimplified queries attached separately):
#/* Server0: MySQL 5.1.46-gcov-debug-log */
#/* Begin test case for query 0 */
--disable_warnings
DROP TABLE /*! IF EXISTS */ BB;
DROP TABLE /*! IF EXISTS */ B;
--enable_warnings
CREATE TABLE `BB` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`col_int_key` int(11) DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `col_int_key` (`col_int_key`),
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
INSERT INTO `BB` VALUES (10,8,NULL);
CREATE TABLE `B` (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`col_int_key` int(11) DEFAULT NULL,
`col_varchar_key` varchar(1) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `col_int_key` (`col_int_key`),
KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
INSERT INTO `B` VALUES (1,7,'f');
SELECT COUNT( `col_varchar_key` )
FROM B
HAVING ( 7 , 9 ) IN (
SELECT `pk` , MIN( `col_int_key` )
FROM BB ) ;
DROP TABLE BB;
DROP TABLE B;
#/* End of test case for query 0 */