Commit 57107fc9 authored by pem@mysql.com's avatar pem@mysql.com
Browse files

Fixed BUG#18787: Server crashed when calling a stored procedure containing

                 a misnamed function
  ... in the presence of a continue handler. The problem was that with a
  handler, it continued to execute as if function existed and had set a
  useful return value (which it hadn't).
  The fix is to set a null return value and do an error return when a function
  wasn't found.
parent 739ee02c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -4837,4 +4837,14 @@ c 2
b	3
a	1
delete from t1|
drop procedure if exists bug18787|
create procedure bug18787()
begin
declare continue handler for sqlexception begin end;
select no_such_function();
end|
call bug18787()|
no_such_function()
NULL
drop procedure bug18787|
drop table t1,t2;
+18 −0
Original line number Diff line number Diff line
@@ -5683,6 +5683,24 @@ select * from t1 order by @x|
delete from t1|


#
# BUG#18787: Server crashed when calling a stored procedure containing
#            a misnamed function
#
--disable_warnings
drop procedure if exists bug18787|
--enable_warnings
create procedure bug18787()
begin
  declare continue handler for sqlexception begin end;

  select no_such_function();
end|

call bug18787()|
drop procedure bug18787|


#
# BUG#NNNN: New bug synopsis
#
+9 −3
Original line number Diff line number Diff line
@@ -4722,7 +4722,9 @@ Item_func_sp::sp_result_field(void) const
    share->table_cache_key = empty_name;
    share->table_name = empty_name;
  }
  field= m_sp->create_result_field(max_length, name, dummy_table);
  if (!(field= m_sp->create_result_field(max_length, name, dummy_table)))
    my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));

  DBUG_RETURN(field);
}

@@ -4750,8 +4752,9 @@ Item_func_sp::execute(Field **flp)
  {
    if (!(*flp= f= sp_result_field()))
    {
      my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
      return 0;
      /* Error set by sp_result_field() */
      null_value= 1;
      return TRUE;
    }

    f->move_field((f->pack_length() > sizeof(result_buf)) ?
@@ -4915,6 +4918,9 @@ Item_func_sp::tmp_table_field(TABLE *t_arg)
  if (!res) 
    res= Item_func::tmp_table_field(t_arg);

  if (!res)
    my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));

  DBUG_RETURN(res);
}