1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#17261 Passing a variable from a stored procedure to UDF crashes mysqld

- Update of test toolsand Makefiles to make it possible to test always test udf's as part 
of the mysql test suite


mysql-test/mysql-test-run.pl:
  Add the path where mysqld will udf_example.so used by the udf test
mysql-test/r/udf.result:
  Update test results
mysql-test/t/udf.test:
  Update tests
  The "--error 0" directives should actually be changed to the correct error number returned but that error  number is lost. W e do however get the right error message and that is checked in 
  the .result file.
sql/Makefile.am:
  Build shared library udf_example.so
sql/share/errmsg.txt:
  Update the max length of %s string from 64 to 128
sql/sql_udf.cc:
  Add DBUG_PRINT just before dl_open
sql/udf_example.cc:
  Use isalpha instade of my_isalpha
This commit is contained in:
unknown
2006-03-10 10:41:04 +01:00
parent 79258e4480
commit e52ff5557c
7 changed files with 83 additions and 62 deletions

View File

@ -1104,6 +1104,14 @@ sub environment_setup () {
($ENV{'DYLD_LIBRARY_PATH'} ? ":$ENV{'DYLD_LIBRARY_PATH'}" : "");
}
# --------------------------------------------------------------------------
# Add the path where mysqld will find udf_example.so
# --------------------------------------------------------------------------
$ENV{'LD_LIBRARY_PATH'}=
"$glob_basedir/sql/.libs" .
($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : "");
# --------------------------------------------------------------------------
# Also command lines in .opt files may contain env vars
# --------------------------------------------------------------------------

View File

@ -10,7 +10,7 @@ RETURNS STRING SONAME 'udf_example.so';
CREATE AGGREGATE FUNCTION avgcost
RETURNS REAL SONAME 'udf_example.so';
select myfunc_double();
ERROR HY000: myfunc_double must have at least on argument
ERROR HY000: myfunc_double must have at least one argument
select myfunc_double(1);
myfunc_double(1)
49.00
@ -59,18 +59,18 @@ select metaphon('hello');
metaphon('hello')
HL
CREATE PROCEDURE `XXX1`(in testval varchar(10))
begin
select metaphon(testval);
begin
select metaphon(testval);
end//
call XXX1('hello');
metaphon(testval)
HL
drop procedure xxx1;
CREATE PROCEDURE `XXX2`()
begin
begin
declare testval varchar(10);
set testval = 'hello';
select metaphon(testval);
select metaphon(testval);
end//
call XXX2();
metaphon(testval)

View File

@ -1,7 +1,7 @@
--source include/have_udf.inc
#
# To run this tests you need to compile "sql/udf_example.cc" into
# udf_example.so and setup LD_LIBRARY_PATH to point out where
# To run this tests the "sql/udf_example.cc" need to be compiled into
# udf_example.so and LD_LIBRARY_PATH should be setup to point out where
# the library are.
#
@ -10,7 +10,7 @@
drop table if exists t1;
--enable_warnings
#
#
# Create the example functions from udf_example
#
@ -19,7 +19,7 @@ CREATE FUNCTION myfunc_double RETURNS REAL SONAME 'udf_example.so';
# myfunc_int does not have a myfunc_int_init function and can
# not be loaded unless server is started with --allow-suspicious-udfs
--error 1127
--error ER_CANT_FIND_DL_ENTRY
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME 'udf_example.so';
CREATE FUNCTION sequence RETURNS INTEGER SONAME "udf_example.so";
CREATE FUNCTION lookup RETURNS STRING SONAME 'udf_example.so';
@ -28,19 +28,27 @@ CREATE FUNCTION reverse_lookup
CREATE AGGREGATE FUNCTION avgcost
RETURNS REAL SONAME 'udf_example.so';
--error 0
select myfunc_double();
select myfunc_double(1);
select myfunc_double(78654);
--error 1305
select myfunc_int();
--error 0
select lookup();
select lookup("127.0.0.1");
--error 0
select lookup(127,0,0,1);
select lookup("localhost");
--error 0
select reverse_lookup();
select reverse_lookup("127.0.0.1");
--error 0
select reverse_lookup(127,0,0,1);
select reverse_lookup("localhost");
--error 0
select avgcost();
--error 0
select avgcost(100,23.76);
create table t1(sum int, price float(24));
insert into t1 values(100, 50.00), (100, 100.00);
@ -54,12 +62,12 @@ drop table t1;
# BUG#17261 Passing a variable from a stored procedure to UDF crashes mysqld
#------------------------------------------------------------------------
select metaphon('hello');
select metaphon('hello');
delimiter //;
CREATE PROCEDURE `XXX1`(in testval varchar(10))
begin
select metaphon(testval);
begin
select metaphon(testval);
end//
delimiter ;//
@ -68,10 +76,10 @@ drop procedure xxx1;
delimiter //;
CREATE PROCEDURE `XXX2`()
begin
begin
declare testval varchar(10);
set testval = 'hello';
select metaphon(testval);
select metaphon(testval);
end//
delimiter ;//
@ -79,13 +87,13 @@ call XXX2();
drop procedure xxx2;
#
#
# Drop the example functions from udf_example
#
DROP FUNCTION metaphon;
DROP FUNCTION myfunc_double;
--error 1305
--error ER_SP_DOES_NOT_EXIST
DROP FUNCTION myfunc_int;
DROP FUNCTION sequence;
DROP FUNCTION lookup;