Commit 68517366 authored by unknown's avatar unknown

fix for Bug #12979 Stored procedures: crash if inout decimal parameter


mysql-test/r/sp.result:
  fix result
mysql-test/r/type_newdecimal.result:
  fix result
mysql-test/t/sp.test:
  add a test for the bug
mysql-test/t/type_newdecimal.test:
  add a test for the bug
sql/item_func.cc:
  call correct method of the item
parent f83297c8
...@@ -3331,4 +3331,20 @@ set @x=y; ...@@ -3331,4 +3331,20 @@ set @x=y;
end| end|
call bug13124()| call bug13124()|
drop procedure bug13124| drop procedure bug13124|
drop procedure if exists bug12979_1|
create procedure bug12979_1(inout d decimal(5)) set d = d / 2|
set @bug12979_user_var = NULL|
call bug12979_1(@bug12979_user_var)|
drop procedure bug12979_1|
drop procedure if exists bug12979_2|
create procedure bug12979_2()
begin
declare internal_var decimal(5);
set internal_var= internal_var / 2;
select internal_var;
end|
call bug12979_2()|
internal_var
NULL
drop procedure bug12979_2|
drop table t1,t2; drop table t1,t2;
...@@ -1016,3 +1016,6 @@ v tdec ...@@ -1016,3 +1016,6 @@ v tdec
v tdec v tdec
9 0 9 0
drop procedure wg2; drop procedure wg2;
select cast(@non_existing_user_var/2 as DECIMAL);
cast(@non_existing_user_var/2 as DECIMAL)
NULL
...@@ -4177,6 +4177,35 @@ end| ...@@ -4177,6 +4177,35 @@ end|
call bug13124()| call bug13124()|
drop procedure bug13124| drop procedure bug13124|
#
# Bug #12979 Stored procedures: crash if inout decimal parameter
#
# check NULL inout parameters processing
--disable_warnings
drop procedure if exists bug12979_1|
--enable_warnings
create procedure bug12979_1(inout d decimal(5)) set d = d / 2|
set @bug12979_user_var = NULL|
call bug12979_1(@bug12979_user_var)|
drop procedure bug12979_1|
# check NULL local variables processing
--disable_warnings
drop procedure if exists bug12979_2|
--enable_warnings
create procedure bug12979_2()
begin
declare internal_var decimal(5);
set internal_var= internal_var / 2;
select internal_var;
end|
call bug12979_2()|
drop procedure bug12979_2|
# #
# BUG#NNNN: New bug synopsis # BUG#NNNN: New bug synopsis
# #
......
...@@ -1037,3 +1037,10 @@ call wg2()// ...@@ -1037,3 +1037,10 @@ call wg2()//
delimiter ;// delimiter ;//
drop procedure wg2; drop procedure wg2;
#
# Bug #12979 Stored procedures: crash if inout decimal parameter
# (not a SP bug in fact)
#
select cast(@non_existing_user_var/2 as DECIMAL);
...@@ -765,7 +765,7 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value) ...@@ -765,7 +765,7 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
} }
case REAL_RESULT: case REAL_RESULT:
{ {
double result= (double)int_op(); double result= (double)real_op();
double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value); double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
break; break;
} }
......
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