Server crashes in do_select on ALL/ANY subquery from a view, with character_set_connection=utf8
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Oleksandr "Sanja" Byelkin |
Bug Description
#4 <signal handler called>
#5 0x0837465a in do_select (join=0x9477040, fields=0x947d54c, table=0x0, procedure=0x0)
at sql_select.cc:15037
#6 0x08358a69 in JOIN::exec (this=0x9477040) at sql_select.cc:2730
#7 0x0827fd04 in subselect_
#8 0x08279839 in Item_subselect:
#9 0x0827ac58 in Item_singlerow_
at item_subselect.
#10 0x08216066 in Item_func_
cache_
#11 0x081fcc21 in Item::safe_
#12 0x081ff071 in agg_item_
item_sep=1) at item.cc:1946
#13 0x081ff26d in agg_item_charsets (coll=..., fname=0x8897e2b "<=", args=0x947e218, nargs=2, flags=7,
item_sep=1) at item.cc:2026
#14 0x082386d1 in Item_func:
item_sep=1) at item_func.h:187
#15 0x0823d2ed in Item_bool_
#16 0x082259a2 in Item_func:
#17 0x0827c2a7 in Item_allany_
at item_subselect.
#18 0x0841e9a4 in JOIN::transform
#19 0x0835284b in JOIN::optimize (this=0x9477040) at sql_select.cc:930
#20 0x081e72a8 in st_select_
#21 0x08426def in JOIN::optimize_
#22 0x0835496b in JOIN::optimize (this=0x9470a48) at sql_select.cc:1542
#23 0x08359214 in mysql_select (thd=0x93efae0, rref_pointer_
fields=..., conds=0x945f9d0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0,
select_
#24 0x08350f17 in handle_select (thd=0x93efae0, lex=0x93f1204, result=0x9460668, setup_tables_
at sql_select.cc:284
#25 0x082ec071 in execute_
#26 0x082e344d in mysql_execute_
#27 0x082ee6ac in mysql_parse (thd=0x93efae0,
rawbuf=
found_
#28 0x082e108d in dispatch_command (command=COM_QUERY, thd=0x93efae0,
packet=
at sql_parse.cc:1228
#29 0x082e0537 in do_command (thd=0x93efae0) at sql_parse.cc:923
#30 0x082dd4bd in handle_
#31 0xb7766b25 in start_thread () from /lib/libpthread
bzr version-info
revision-id: <email address hidden>
date: 2012-02-29 23:28:16 -0800
build-date: 2012-03-02 05:33:16 +0400
revno: 3451
Reproducible on MariaDB 5.3, 5.5. Not reproducible on MariaDB 5.2, MySQL 5.1.60, 5.5.20, 5.6.4.
EXPLAIN:
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY <derived3> system NULL NULL NULL NULL 1 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <not>(<
Minimal optimizer_switch: in_to_exists=on
Full optimizer_switch (default):
index_merge=
Test case:
SET optimizer_switch = 'in_to_exists=on';
SET character_
CREATE TABLE t1 ( a VARCHAR(1) );
INSERT INTO t1 VALUES ('m'),('n');
CREATE VIEW v AS SELECT 'w' ;
SELECT * FROM t1 WHERE a < ALL ( SELECT * FROM v );
# End of test case
Changed in maria: | |
assignee: | nobody → Sergey Petrunia (sergefp) |
Changed in maria: | |
status: | Confirmed → In Progress |
Changed in maria: | |
assignee: | Michael Widenius (monty) → Oleksandr "Sanja" Byelkin (sanja-byelkin) |
Changed in maria: | |
status: | Confirmed → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
The crash itself happens on these lines:
15035 if (join->table_count) tab[join- >top_join_ tab_count - 1].next_select= end_select; join->join_ tab+join- >const_ tables;
15036 {
15037 join->join_
15038 join_tab=
15039 }
because
(gdb) p join->top_ join_tab_ count
$82 = 0
If one looks at the source of the problem, they will find that the execution is an odd state. Here is the stack trace of the crash, with unneeded details removed:
(gdb) wher single_ select_ engine: :exec () :exec () subselect: :val_str () conv_charset: :Item_func_ conv_charset () charset_ converter () set_converter () :agg_arg_ charsets () func2:: fix_length_ and_dec () :fix_fields () subselect: :transform_ into_max_ min (this=0x9f3a1f8, join=$JOIN1) _max_min_ subquery (this=$JOIN1) lex::optimize_ unflattened_ subqueries (this=0x9f30198) unflattened_ subqueries (this=$JOIN2)
#0 in do_select (join=$JOIN1, fields=0x9f68b14, table=0x0, procedure=0x0)
#1 in JOIN::exec (this=$JOIN1)
#2 in subselect_
#3 in Item_subselect:
#4 in Item_singlerow_
#5 in Item_func_
#6 in Item::safe_
#7 in agg_item_
#8 in agg_item_charsets ()
#9 in Item_func:
#10 in Item_bool_
#11 in Item_func:
#12 in Item_allany_
#13 in JOIN::transform
#14 in JOIN::optimize (this=$JOIN1)
#15 in st_select_
#16 in JOIN::optimize_
#17 in JOIN::optimize (this=$JOIN2)
#18 in mysql_select ()
Note that we're inside JOIN::optimize (this=$JOIN1) , #14. And what we're trying to do is to call JOIN::exec (this=$JOIN1) for the same join object. This is wrong: optimization of a join should not involve attempts to execute the join we're trying to optimize.
I think, something is wrong with type conversions and/or MIN/MAX transformations.