From d2b9085df812f03dd4cdc2854fc27b1e830c735a Mon Sep 17 00:00:00 2001 From: "petr@mysql.com" <> Date: Tue, 13 Sep 2005 15:15:38 +0400 Subject: [PATCH] Fix for Bug #13124 Stored Procedure using SELECT INTO crashes server --- mysql-test/r/sp.result | 8 ++++++++ mysql-test/t/sp.test | 15 +++++++++++++++ sql/item.cc | 7 ++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index cb696f93f79..d0a63e82999 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3225,4 +3225,12 @@ select @var| @var abcdabcd drop procedure bug12849_2| +drop procedure if exists bug13124| +create procedure bug13124() +begin +declare y integer; +set @x=y; +end| +call bug13124()| +drop procedure bug13124| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 3d315fa12df..15554801c9c 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -4063,6 +4063,21 @@ call bug12849_2(@var)| select @var| drop procedure bug12849_2| +# +# Bug #13124 Stored Procedure using SELECT INTO crashes server +# + +--disable_warnings +drop procedure if exists bug13124| +--enable_warnings +create procedure bug13124() +begin + declare y integer; + set @x=y; +end| +call bug13124()| +drop procedure bug13124| + # # BUG#NNNN: New bug synopsis # diff --git a/sql/item.cc b/sql/item.cc index e7da646ae73..d18d0143d2c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -818,6 +818,8 @@ String *Item_splocal::val_str(String *sp) DBUG_ASSERT(fixed); Item *it= this_item(); String *ret= it->val_str(sp); + + null_value= it->null_value; /* This way we mark returned value of val_str as const, so that various functions (e.g. CONCAT) won't try to @@ -833,9 +835,12 @@ String *Item_splocal::val_str(String *sp) This is intended behaviour of Item_func_concat. Comments to Item_param class contain some more details on the topic. */ + + if (!ret) + return NULL; + str_value_ptr.set(ret->ptr(), ret->length(), ret->charset()); - null_value= it->null_value; return &str_value_ptr; }