Crash in Item_func::fix_fields with partial_match_rowid_merge and unrealistic double subqueries on the left side
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
Low
|
Oleksandr "Sanja" Byelkin |
Bug Description
The following unrealisic query:
SELECT * FROM t1
WHERE (
( SELECT a FROM t2 WHERE a = 9 ) ,
( SELECT a FROM t2 WHERE a = 3 )
) NOT IN (
SELECT b , a
FROM t3
);
crashes as follows when run wtih partial_
#4 <signal handler called>
#5 0x00000000 in ?? ()
#6 0x081f32d8 in Item_func:
#7 0x0824ec76 in Ordered_key::init (this=0xae534120, col_idx=1) at item_subselect.
#8 0x0824fc32 in subselect_
#9 0x0824e494 in subselect_
#10 0x08245287 in Item_subselect:
#11 0x0824572a in Item_in_
#12 0x0824724e in Item_in_
#13 0x081e12e6 in Item::val_
#14 0x0820d65a in Item_in_
#15 0x081c9650 in Item::val_bool (this=0xae529cb0) at item.cc:197
#16 0x0820a260 in Item_func_
#17 0x0831d373 in JOIN::exec (this=0xae52c270) at sql_select.cc:2111
#18 0x0831fbd2 in mysql_select (thd=0xb1456a8, rref_pointer_
order=0x0, group=0x0, having=0x0, proc_param=0x0, select_
at sql_select.cc:2891
#19 0x08317a67 in handle_select (thd=0xb1456a8, lex=0xb146db0, result=0xae5284b0, setup_tables_
#20 0x082b2e4e in execute_
#21 0x082a9c52 in mysql_execute_
#22 0x082b548a in mysql_parse (thd=0xb1456a8,
rawbuf=
#23 0x082a78cf in dispatch_command (command=COM_QUERY, thd=0xb1456a8,
packet=
#24 0x082a6d55 in do_command (thd=0xb1456a8) at sql_parse.cc:906
#25 0x082a3dbc in handle_
#26 0x00821919 in start_thread () from /lib/libpthread
#27 0x0076acce in clone () from /lib/libc.so.6
minimal optimizer_switch: ,materializatio
full optimizer_switch:
index_merge=
test case:
CREATE TABLE t1 ( a int) ;
INSERT INTO t1 VALUES (20),(30);
CREATE TABLE t2 (a int) ;
INSERT INTO t2 VALUES (3),(9);
CREATE TABLE t3 ( a int, b int) ;
INSERT INTO t3 VALUES (20,5),(30,6);
SET SESSION optimizer_
SELECT * FROM t1
WHERE (
( SELECT a FROM t2 WHERE a = 9 ) ,
( SELECT a FROM t2 WHERE a = 3 )
) NOT IN (
SELECT b , a
FROM t3
);
bzr version-info
revision-id: <email address hidden>
date: 2011-08-09 18:34:26 +0300
build-date: 2011-08-11 13:09:22 +0300
revno: 3148
branch-nick: maria-5.3
Changed in maria: | |
milestone: | none → 5.3 |
Changed in maria: | |
assignee: | nobody → Timour Katchaounov (timour) |
Changed in maria: | |
assignee: | Timour Katchaounov (timour) → Oleksandr "Sanja" Byelkin (sanja-byelkin) |
Changed in maria: | |
status: | Confirmed → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
There is a known architectural deficiency in the way the optimizer
processes the left operand of IN. The problem is related to the fact
that if the left operand is treated always as a single subquery
that may return multiple columns, and the operand is treated
as a sequence. However, if the left operand contains several
subqueries, each returning several columns, then the current
code cannot handle it, because it is a sequence of sequences.
For instance PostgreSQL forbids this construct. In our case
the most reasonable solution is to forbid this construct as
well, because it has very unclear semantics.
Need to check what ANSI SQL says.