Show
added a comment - The error is generated here:
(gdb) wher
#0 my_error (nr=1136, MyFlags=0) at /home/psergey/dev2/10.0/mysys/my_error.c:113
#1 0x00000000006438ad in check_insert_fields (thd=0x31d1050, table_list=0x7fffa00068a0, fields=..., values=..., check_unique=true, fields_and_values_from_different_maps=true, map=0x7fffe0066300) at /home/psergey/dev2/10.0/sql/sql_insert.cc:215
#2 0x000000000064b548 in select_insert::prepare (this=0x7fffa0008288, values=..., u=0x7fffa00072a0) at /home/psergey/dev2/10.0/sql/sql_insert.cc:3377
#3 0x00000000006d5b2a in JOIN::change_result (this=0x7fffa00755a0, res=0x7fffa0008288) at /home/psergey/dev2/10.0/sql/sql_select.cc:24412
#4 0x00000000006a1590 in mysql_select (thd=0x31d1050, rref_pointer_array=0x7fffa00071a0, tables=0x7fffa0007ad8, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748612, result=0x7fffa0008288, unit=0x7fffa00072a0, select_lex=0x7fffa0006f28) at /home/psergey/dev2/10.0/sql/sql_select.cc:3248
#5 0x00000000006d4528 in mysql_explain_union (thd=0x31d1050, unit=0x7fffa00072a0, result=0x7fffa0008288) at /home/psergey/dev2/10.0/sql/sql_select.cc:23924
#6 0x00000000006d4287 in select_describe (join=0x7fffa0075068, need_tmp_table=false, need_order=false, distinct=false, message=0x103585c "No tables used") at /home/psergey/dev2/10.0/sql/sql_select.cc:23881
#7 0x000000000069e670 in JOIN::exec_inner (this=0x7fffa0075068) at /home/psergey/dev2/10.0/sql/sql_select.cc:2431
#8 0x000000000069e2aa in JOIN::exec (this=0x7fffa0075068) at /home/psergey/dev2/10.0/sql/sql_select.cc:2370
#9 0x00000000006a1869 in mysql_select (thd=0x31d1050, rref_pointer_array=0x31d56c0, tables=0x0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925892, result=0x7fffa0008288, unit=0x31d4d60, select_lex=0x31d5448) at /home/psergey/dev2/10.0/sql/sql_select.cc:3308
#10 0x0000000000697b7b in handle_select (thd=0x31d1050, lex=0x31d4c98, result=0x7fffa0008288, setup_tables_done_option=1073741824) at /home/psergey/dev2/10.0/sql/sql_select.cc:373
#11 0x0000000000665c9f in mysql_execute_command (thd=0x31d1050) at /home/psergey/dev2/10.0/sql/sql_parse.cc:3519
#12 0x000000000066dd51 in mysql_parse (thd=0x31d1050, rawbuf=0x7fffa0006788 "explain replace into t2 select 100, (select a from t1)", length=54, parser_state=0x7fffe00674f0) at /home/psergey/dev2/10.0/sql/sql_parse.cc:6407
select_describe(join, join->select_lex->select_number=1) calls
mysql_explain_union for the subquery.
mysql_explain_union calls mysql_select, which makes this call
//here is EXPLAIN of subselect or derived table
if (join->change_result(result))
{
DBUG_RETURN(TRUE);
}
where the result is select_insert object. The number of columns select_insert
expects is not (and doesn't have to be) equal to number of columns produced by
the subquery, and we get an error.
The error is generated here:
select_describe(join, join->select_lex->select_number=1) calls
mysql_explain_union for the subquery.
mysql_explain_union calls mysql_select, which makes this call
//here is EXPLAIN of subselect or derived table if (join->change_result(result)) { DBUG_RETURN(TRUE); }where the result is select_insert object. The number of columns select_insert
expects is not (and doesn't have to be) equal to number of columns produced by
the subquery, and we get an error.