Crash in JOIN::optimize called from subselect_hash_sj_engine::exec with semijoin=off
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Timour Katchaounov |
Bug Description
With semijoin=off, the following query:
PREPARE st1 FROM "SELECT table1 .`col_varchar_key`
FROM (
SELECT *
FROM BB ) table1 RIGHT JOIN BB ON ( 8 , 4 ) IN (
SELECT `pk` , `pk`
FROM C ) ";
crashes as follows (note the presence of subselect_
#3 0x0827e9e0 in handle_segfault (sig=11) at mysqld.cc:2703
#4 <signal handler called>
#5 0x082fd446 in JOIN::optimize (this=0xb5f8c7c8) at sql_select.cc:745
#6 0x08237a39 in subselect_
#7 0x0822facb in Item_subselect:
#8 0x0822fcc4 in Item_in_
#9 0x0823152c in Item_in_
#10 0x081cf442 in Item::val_
#11 0x081faab7 in Item_in_
#12 0x0831e5fe in join_read_
#13 0x08304fb2 in make_join_
#14 0x082fddc9 in JOIN::optimize (this=0xb5f87958) at sql_select.cc:939
#15 0x08303865 in mysql_select (thd=0xa81efd0, rref_pointer_
group=0x0, having=0x0, proc_param=0x0, select_
#16 0x082fbfb7 in handle_select (thd=0xa81efd0, lex=0xb5f5c3f0, result=0xb5f5ec98, setup_tables_
#17 0x0829a6d8 in execute_
#18 0x082910b8 in mysql_execute_
#19 0x08342d81 in Prepared_
#20 0x08342280 in Prepared_
at sql_prepare.cc:3263
#21 0x08340c6c in mysql_sql_
#22 0x082910e2 in mysql_execute_
#23 0x0829c8b9 in mysql_parse (thd=0xa81efd0, inBuf=0xb5f31900 "EXECUTE st1", length=11, found_semicolon
#24 0x0828eaea in dispatch_command (command=COM_QUERY, thd=0xa81efd0, packet=0xa837329 "EXECUTE st1", packet_length=11) at sql_parse.cc:1184
#25 0x0828df90 in do_command (thd=0xa81efd0) at sql_parse.cc:890
#26 0x0828b0f0 in handle_
#27 0x00a08919 in start_thread () from /lib/libpthread
#28 0x00951e5e in clone () from /lib/libc.so.6
EXPLAIN:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY BB system NULL NULL NULL NULL 1
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
3 SUBQUERY C index NULL PRIMARY 4 NULL 20 Using index
2 DERIVED BB system NULL NULL NULL NULL 1
Changed in maria: | |
assignee: | nobody → Timour Katchaounov (timour) |
Changed in maria: | |
status: | In Progress → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
Test case:
SET @@optimizer_switch = 'semijoin=off';
CREATE TABLE `C` ( key`,`col_ int_key` ) key`,`col_ int_key` )
`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_
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
INSERT INTO `C` VALUES (1,2,'w');
INSERT INTO `C` VALUES (2,9,'m');
INSERT INTO `C` VALUES (3,3,'m');
INSERT INTO `C` VALUES (4,9,'k');
INSERT INTO `C` VALUES (5,NULL,'r');
INSERT INTO `C` VALUES (6,9,'t');
INSERT INTO `C` VALUES (7,3,'j');
INSERT INTO `C` VALUES (8,8,'u');
INSERT INTO `C` VALUES (9,8,'h');
INSERT INTO `C` VALUES (10,53,'o');
INSERT INTO `C` VALUES (11,0,NULL);
INSERT INTO `C` VALUES (12,5,'k');
INSERT INTO `C` VALUES (13,166,'e');
INSERT INTO `C` VALUES (14,3,'n');
INSERT INTO `C` VALUES (15,0,'t');
INSERT INTO `C` VALUES (16,1,'c');
INSERT INTO `C` VALUES (17,9,'m');
INSERT INTO `C` VALUES (18,5,'y');
INSERT INTO `C` VALUES (19,6,'f');
INSERT INTO `C` VALUES (20,2,'d');
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_
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
INSERT INTO `BB` VALUES (10,8,NULL);
PREPARE st1 FROM "SELECT table1 .`col_varchar_key`
FROM (
SELECT *
FROM BB ) table1 RIGHT JOIN BB ON ( 8 , 4 ) IN (
SELECT `pk` , `pk`
FROM C ) ";
EXECUTE st1;
EXECUTE st1;