Commit bf8dac3b authored by unknown's avatar unknown
Browse files

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.


mysql-test/r/explain.result:
  Add result for bug#15463.
mysql-test/t/explain.test:
  Add test case for bug#15463.
sql/sql_parse.cc:
  Assert that if parsing error has occured then apropriate error message
  has been pushed into error stack.
sql/sql_yacc.yy:
  If there is no lex->result in select_var_ident rule, then we have
  to be in DESCRIBE mode.
parent 853f5413
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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
drop table ;
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
+9 −0
Original line number Diff line number Diff line
@@ -43,3 +43,12 @@ drop table
set names latin1;

# 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.
+1 −0
Original line number Diff line number Diff line
@@ -5709,6 +5709,7 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
    }
    else
    {
      DBUG_ASSERT(thd->net.report_error);
      DBUG_PRINT("info",("Command aborted. Fatal_error: %d",
			 thd->is_fatal_error));
      query_cache_abort(&thd->net);
+15 −5
Original line number Diff line number Diff line
@@ -5795,7 +5795,11 @@ select_var_ident:
	     if (lex->result) 
	       ((select_dumpvar *)lex->result)->var_list.push_back( new my_var($2,0,0,(enum_field_types)0));
	     else
	       YYABORT;
               /*
                 The parser won't create select_result instance only
	         if it's an EXPLAIN.
               */
               DBUG_ASSERT(lex->describe);
	   }
           | ident_or_text
           {
@@ -5807,9 +5811,7 @@ select_var_ident:
	       my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str);
	       YYABORT;
	     }
	     if (! lex->result)
	       YYABORT;
	     else
	     if (lex->result)
             {
               my_var *var;
	       ((select_dumpvar *)lex->result)->
@@ -5819,6 +5821,14 @@ select_var_ident:
		 var->sp= lex->sphead;
#endif
             }
	     else
	     {
               /*
                 The parser won't create select_result instance only
	         if it's an EXPLAIN.
               */
               DBUG_ASSERT(lex->describe);
	     }
	   }
           ;