Details
Description
The following will execute subquery at prepare stage:
--source include/have_sequence.inc
|
create table t20 (a int, b int); |
insert into t20 select seq, seq from seq_1_to_10000; |
create table t21 as select * from t20; |
create table t22 as select * from t20; |
flush status;
|
explain select * from t20 where a<3 or (select max(a) from t21) in (select b from t22); |
show status like 'Handler_read%'; |
drop table t20,t21,t22; |
It will show :
Handler_read_rnd_next 10001
|
stack trace:
Stack trace:
|
$288 = 0x7fff28014af8 "t21"
|
(gdb) wher
|
#0 ha_innobase::rnd_next (this=0x7fff2807f6c0, buf=0x7fff2807b5a0 "\377") at /home/psergey/dev-git2/10.6-dbg/storage/innobase/handler/ha_innodb.cc:9502
|
#1 0x0000555556295c5d in handler::ha_rnd_next (this=0x7fff2807f6c0, buf=0x7fff2807b5a0 "\377") at /home/psergey/dev-git2/10.6-dbg/sql/handler.cc:3477
|
#2 0x0000555556468bff in rr_sequential (info=0x7fff28093188) at /home/psergey/dev-git2/10.6-dbg/sql/records.cc:519
|
#3 0x0000555555e1760b in READ_RECORD::read_record (this=0x7fff28093188) at /home/psergey/dev-git2/10.6-dbg/sql/records.h:81
|
#4 0x0000555555f65817 in join_init_read_record (tab=0x7fff280930b0) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:22919
|
#5 0x0000555555f63123 in sub_select (join=0x7fff280911a0, join_tab=0x7fff280930b0, end_of_records=false) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:21883
|
#6 0x0000555555f62454 in do_select (join=0x7fff280911a0, procedure=0x0) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:21409
|
#7 0x0000555555f33ada in JOIN::exec_inner (this=0x7fff280911a0) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:4898
|
#8 0x0000555555f32b55 in JOIN::exec (this=0x7fff280911a0) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:4676
|
#9 0x000055555638f19d in subselect_single_select_engine::exec (this=0x7fff2801d030) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:4116
|
#10 0x0000555556381a55 in Item_subselect::exec (this=0x7fff28023e30) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:812
|
#11 0x0000555556383b67 in Item_singlerow_subselect::val_int (this=0x7fff28023e30) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:1474
|
#12 0x0000555555d9d3f9 in Item::val_int_result (this=0x7fff28023e30) at /home/psergey/dev-git2/10.6-dbg/sql/item.h:1793
|
#13 0x00005555562cd572 in Item_cache_int::cache_value (this=0x7fff28092430) at /home/psergey/dev-git2/10.6-dbg/sql/item.cc:10260
|
#14 0x00005555562dfa8a in Item_in_optimizer::fix_left (this=0x7fff28092330, thd=0x7fff28000d08) at /home/psergey/dev-git2/10.6-dbg/sql/item_cmpfunc.cc:1417
|
#15 0x000055555638cccc in Item_in_subselect::select_in_like_transformer (this=0x7fff28007cf0, join=0x7fff28091bf0) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:3433
|
#16 0x0000555556389d73 in Item_in_subselect::select_transformer (this=0x7fff28007cf0, join=0x7fff28091bf0) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:2737
|
#17 0x000055555610c9cd in check_and_do_in_subquery_rewrites (join=0x7fff28091bf0) at /home/psergey/dev-git2/10.6-dbg/sql/opt_subselect.cc:768
|
#18 0x0000555555f26fd2 in JOIN::prepare (this=0x7fff28091bf0, tables_init=0x7fff2808ae50, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fff28083180, unit_arg=0x7fff2808b590) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:1585
|
#19 0x000055555638e58d in subselect_single_select_engine::prepare (this=0x7fff280161f0, thd=0x7fff28000d08) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:3900
|
#20 0x00005555563803b3 in Item_subselect::fix_fields (this=0x7fff28007cf0, thd_param=0x7fff28000d08, ref=0x7fff28031d08) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:296
|
#21 0x000055555638d42c in Item_in_subselect::fix_fields (this=0x7fff28007cf0, thd_arg=0x7fff28000d08, ref=0x7fff28031d08) at /home/psergey/dev-git2/10.6-dbg/sql/item_subselect.cc:3559
|
#22 0x0000555555daadf0 in Item::fix_fields_if_needed (this=0x7fff28007cf0, thd=0x7fff28000d08, ref=0x7fff28031d08) at /home/psergey/dev-git2/10.6-dbg/sql/item.h:1166
|
#23 0x0000555555daae1d in Item::fix_fields_if_needed_for_scalar (this=0x7fff28007cf0, thd=0x7fff28000d08, ref=0x7fff28031d08) at /home/psergey/dev-git2/10.6-dbg/sql/item.h:1175
|
#24 0x0000555555e3754f in Item::fix_fields_if_needed_for_bool (this=0x7fff28007cf0, thd=0x7fff28000d08, ref=0x7fff28031d08) at /home/psergey/dev-git2/10.6-dbg/sql/item.h:1179
|
#25 0x00005555562ec696 in Item_cond::fix_fields (this=0x7fff28029b20, thd=0x7fff28000d08, ref=0x7fff28090ea8) at /home/psergey/dev-git2/10.6-dbg/sql/item_cmpfunc.cc:5069
|
#26 0x0000555555daadf0 in Item::fix_fields_if_needed (this=0x7fff28029b20, thd=0x7fff28000d08, ref=0x7fff28090ea8) at /home/psergey/dev-git2/10.6-dbg/sql/item.h:1166
|
#27 0x0000555555daae1d in Item::fix_fields_if_needed_for_scalar (this=0x7fff28029b20, thd=0x7fff28000d08, ref=0x7fff28090ea8) at /home/psergey/dev-git2/10.6-dbg/sql/item.h:1175
|
#28 0x0000555555e3754f in Item::fix_fields_if_needed_for_bool (this=0x7fff28029b20, thd=0x7fff28000d08, ref=0x7fff28090ea8) at /home/psergey/dev-git2/10.6-dbg/sql/item.h:1179
|
#29 0x0000555555e33bac in setup_conds (thd=0x7fff28000d08, tables=0x7fff28017690, leaves=@0x7fff28015878: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7fff280840a0, last = 0x7fff280840a0, elements = 1}, <No data fields>}, conds=0x7fff28090ea8) at /home/psergey/dev-git2/10.6-dbg/sql/sql_base.cc:8596
|
#30 0x0000555555f23768 in setup_without_group (thd=0x7fff28000d08, ref_pointer_array={m_array = 0x7fff2808d8a0, m_size = 13}, tables=0x7fff28017690, leaves=@0x7fff28015878: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7fff280840a0, last = 0x7fff280840a0, elements = 1}, <No data fields>}, fields=@0x7fff28015918: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7fff2808d190, last = 0x7fff28082260, elements = 2}, <No data fields>}, all_fields=@0x7fff28090dc0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7fff2808d190, last = 0x7fff2808d190, elements = 2}, <No data fields>}, conds=0x7fff28090ea8, order=0x0, group=0x0, win_specs=@0x7fff28015ae0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x555557b24c60 <end_of_list>, last = 0x7fff28015ae0, elements = 0}, <No data fields>}, win_funcs=@0x7fff28015b00: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x555557b24c60 <end_of_list>, last = 0x7fff28015b00, elements = 0}, <No data fields>}, hidden_group_fields=0x7fff28090d7f) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:864
|
#31 0x0000555555f26959 in JOIN::prepare (this=0x7fff28090a60, tables_init=0x7fff28017690, conds_init=0x7fff28029b20, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fff28015660, unit_arg=0x7fff280050d8) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:1486
|
#32 0x0000555555f343b0 in mysql_select (thd=0x7fff28000d08, tables=0x7fff28017690, fields=@0x7fff28015918: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7fff2808d190, last = 0x7fff28082260, elements = 2}, <No data fields>}, conds=0x7fff28029b20, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748612, result=0x7fff2807d8a0, unit=0x7fff280050d8, select_lex=0x7fff28015660) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:5132
|
#33 0x0000555555f76653 in mysql_explain_union (thd=0x7fff28000d08, unit=0x7fff280050d8, result=0x7fff2807d8a0) at /home/psergey/dev-git2/10.6-dbg/sql/sql_select.cc:28927
|
#34 0x0000555555ee085b in execute_sqlcom_select (thd=0x7fff28000d08, all_tables=0x7fff28017690) at /home/psergey/dev-git2/10.6-dbg/sql/sql_parse.cc:6311
|
#35 0x0000555555ed7ba1 in mysql_execute_command (thd=0x7fff28000d08, is_called_from_prepared_stmt=false) at /home/psergey/dev-git2/10.6-dbg/sql/sql_parse.cc:3980
|
#36 0x0000555555ee5aba in mysql_parse (thd=0x7fff28000d08, rawbuf=0x7fff2801ab50 "explain select * from t20 where a<3 or (select max(a) from t21) in (select b from t22)", length=86, parser_state=0x7ffff4072360) at /home/psergey/dev-git2/10.6-dbg/sql/sql_parse.cc:8139
|
|