|
|||||||||||
|
bk commit into 5.1 tree (kostja:1.2608) BUG#32007
From: <konstantin(at)mysql.com>
Date: Wed Oct 31 2007 - 17:32:02 EDT
ChangeSet@1.2608, 2007-11-01 00:31:57+03:00, kostja@bodhi.(none) +3 -0 A fix for Bug#32007 select udf_function() doesn't return an error if error during udf initialization. The bug is spotted while working on Bug 12713. If a user-defined function was used in a SELECT statement, and an error would occur during UDF initialization, this error would not terminate execution of the SELECT, but rather would be converted to a warning. The fix is to use a stack buffer to store the message from udf_init instead of private my_error() buffer. mysql-test/r/udf.result@1.27, 2007-11-01 00:31:54+03:00, kostja@bodhi.(none) +6 -6 Update the result to reflect the fix for Bug#32007 select udf_function() doesn't return an error if error during udf initialization mysql-test/t/udf.test@1.25, 2007-11-01 00:31:54+03:00, kostja@bodhi.(none) +6 -6 Update the test to reflect the fix for Bug #32007 select udf_function() doesn't return an error if error during udf initialization sql/item_func.cc@1.426, 2007-11-01 00:31:54+03:00, kostja@bodhi.(none) +3 -2 A fix for Bug#32007.
net.last_error buffer was used to store the temporary message from udf_init.
Then, when my_error() was called, net.last_error was not empty so
my_error() would conclude that there is already an error in the error stack,
and not "overwrite" it.
The fix is to use a stack buffer instead of thd->net.last_error to store the message from udf_init. The message will end up in thd->net.last_error anyway after a call to my_error.
diff -Nrup a/mysql-test/r/udf.result b/mysql-test/r/udf.result
select reverse_lookup("127.0.0.1");
select reverse_lookup(127,0,0,1);
select reverse_lookup("localhost");
reverse_lookup("localhost") NULL select avgcost(); -ERROR HY000: wrong number of arguments: AVGCOST() requires two arguments +ERROR HY000: Can't initialize function 'avgcost'; wrong number of arguments: AVGCOST() requires two arguments select avgcost(100,23.76); -ERROR HY000: wrong argument type: AVGCOST() requires an INT and a REAL +ERROR HY000: Can't initialize function 'avgcost'; wrong argument type: AVGCOST() requires an INT and a REAL create table t1(sum int, price float(24)); insert into t1 values(100, 50.00), (100, 100.00); select avgcost(sum, price) from t1; diff -Nrup a/mysql-test/t/udf.test b/mysql-test/t/udf.test --- a/mysql-test/t/udf.test 2007-10-29 17:01:33 +03:00 +++ b/mysql-test/t/udf.test 2007-11-01 00:31:54 +03:00 @@ -35,20 +35,20 @@ eval CREATE FUNCTION reverse_lookup eval CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "$UDF_EXAMPLE_LIB";
select myfunc_double(); select myfunc_double(1); select myfunc_double(78654); --error 1305 select myfunc_nonexist(); select myfunc_int(); ---error 0 +--error ER_CANT_INITIALIZE_UDF select lookup(); select lookup("127.0.0.1"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select lookup(127,0,0,1); select lookup("localhost"); ---error 0 +--error ER_CANT_INITIALIZE_UDF select reverse_lookup(); # These two functions should return "localhost", but it's @@ -59,9 +59,9 @@ select reverse_lookup(127,0,0,1); --enable_result_log
select reverse_lookup("localhost");
if (u_d->func_init)
char *to=num_buffer;
for (uint i=0; i < arg_count; i++)
{
@@ -2949,10 +2950,10 @@ udf_handler::fix_fields(THD *thd, Item_r
}
thd->net.last_error[0]=0;
Udf_func_init init= u_d->func_init;
- if ((error=(uchar) init(&initid, &f_args, thd->net.last_error))) + if ((error=(uchar) init(&initid, &f_args, init_msg_buff)))
{
my_error(ER_CANT_INITIALIZE_UDF, MYF(0),
-- This archive was generated by hypermail 2.1.8 : Thu Jul 03 2008 - 11:15:06 EDT |
||||||||||
|
|||||||||||