Commit 96f0aa3c authored by kroki@mysql.com's avatar kroki@mysql.com

Bug#15463: EXPLAIN SELECT..INTO hangs the client (QB, command line)

There were two distict bugs: parse error was returned for valid
statement and that error wasn't reported to the client.

The fix ensures that EXPLAIN SELECT..INTO is accepted by parser and any
other parse error will be reported to the client.
parent c40f8557
...@@ -53,3 +53,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -53,3 +53,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE ref 0,01 0 5 const 1 Using where; Using index 1 SIMPLE ref 0,01 0 5 const 1 Using where; Using index
drop table ; drop table ;
set names latin1; set names latin1;
select 3 into @v1;
explain select 3 into @v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -43,3 +43,12 @@ drop table ...@@ -43,3 +43,12 @@ drop table
set names latin1; set names latin1;
# End of 4.1 tests # End of 4.1 tests
#
# Bug#15463: EXPLAIN SELECT..INTO hangs the client (QB, command line)
#
select 3 into @v1;
explain select 3 into @v1;
# End of 5.0 tests.
...@@ -5709,6 +5709,7 @@ void mysql_parse(THD *thd, char *inBuf, uint length) ...@@ -5709,6 +5709,7 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
} }
else else
{ {
DBUG_ASSERT(thd->net.report_error);
DBUG_PRINT("info",("Command aborted. Fatal_error: %d", DBUG_PRINT("info",("Command aborted. Fatal_error: %d",
thd->is_fatal_error)); thd->is_fatal_error));
query_cache_abort(&thd->net); query_cache_abort(&thd->net);
......
...@@ -5795,7 +5795,11 @@ select_var_ident: ...@@ -5795,7 +5795,11 @@ select_var_ident:
if (lex->result) if (lex->result)
((select_dumpvar *)lex->result)->var_list.push_back( new my_var($2,0,0,(enum_field_types)0)); ((select_dumpvar *)lex->result)->var_list.push_back( new my_var($2,0,0,(enum_field_types)0));
else else
YYABORT; /*
The parser won't create select_result instance only
if it's an EXPLAIN.
*/
DBUG_ASSERT(lex->describe);
} }
| ident_or_text | ident_or_text
{ {
...@@ -5807,10 +5811,8 @@ select_var_ident: ...@@ -5807,10 +5811,8 @@ select_var_ident:
my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str); my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str);
YYABORT; YYABORT;
} }
if (! lex->result) if (lex->result)
YYABORT; {
else
{
my_var *var; my_var *var;
((select_dumpvar *)lex->result)-> ((select_dumpvar *)lex->result)->
var_list.push_back(var= new my_var($1,1,t->offset,t->type)); var_list.push_back(var= new my_var($1,1,t->offset,t->type));
...@@ -5818,6 +5820,14 @@ select_var_ident: ...@@ -5818,6 +5820,14 @@ select_var_ident:
if (var) if (var)
var->sp= lex->sphead; var->sp= lex->sphead;
#endif #endif
}
else
{
/*
The parser won't create select_result instance only
if it's an EXPLAIN.
*/
DBUG_ASSERT(lex->describe);
} }
} }
; ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment