summaryrefslogtreecommitdiff
path: root/mysql-test/t/udf.test
diff options
context:
space:
mode:
authormsvensson@devsrv-b.mysql.com <>2006-02-15 17:11:24 +0100
committermsvensson@devsrv-b.mysql.com <>2006-02-15 17:11:24 +0100
commitfa1f8a9c80be4599c4bf6e45145cf72f7d139b6a (patch)
treeecb3d7a4c5fccfa3a7864020bfd8137d609c0dde /mysql-test/t/udf.test
parent42cc473df324e17907db29f9a85ecd0e32100f9a (diff)
downloadmariadb-git-fa1f8a9c80be4599c4bf6e45145cf72f7d139b6a.tar.gz
Bug#17261 Passing a variable from a stored procedure to UDF crashes mysqld
- Pass "buffers[i]" to val_str() in udf_handler::fix_fields insteead of NULL. - Add testcase for UDF that will load and run the udf_example functions if available
Diffstat (limited to 'mysql-test/t/udf.test')
-rw-r--r--mysql-test/t/udf.test94
1 files changed, 94 insertions, 0 deletions
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
new file mode 100644
index 00000000000..98eecd3a737
--- /dev/null
+++ b/mysql-test/t/udf.test
@@ -0,0 +1,94 @@
+--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
+# the library are.
+#
+
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Create the example functions from udf_example
+#
+
+CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
+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
+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';
+CREATE FUNCTION reverse_lookup
+ RETURNS STRING SONAME 'udf_example.so';
+CREATE AGGREGATE FUNCTION avgcost
+ RETURNS REAL SONAME 'udf_example.so';
+
+select myfunc_double();
+select myfunc_double(1);
+select myfunc_double(78654);
+select myfunc_int();
+select lookup();
+select lookup("127.0.0.1");
+select lookup(127,0,0,1);
+select lookup("localhost");
+select reverse_lookup();
+select reverse_lookup("127.0.0.1");
+select reverse_lookup(127,0,0,1);
+select reverse_lookup("localhost");
+select avgcost();
+select avgcost(100,23.76);
+create table t1(sum int, price float(24));
+insert into t1 values(100, 50.00), (100, 100.00);
+select avgcost(sum, price) from t1;
+delete from t1;
+insert into t1 values(100, 54.33), (200, 199.99);
+select avgcost(sum, price) from t1;
+drop table t1;
+
+#------------------------------------------------------------------------
+# BUG#17261 Passing a variable from a stored procedure to UDF crashes mysqld
+#------------------------------------------------------------------------
+
+select metaphon('hello');
+
+delimiter //;
+CREATE PROCEDURE `XXX1`(in testval varchar(10))
+begin
+select metaphon(testval);
+end//
+delimiter ;//
+
+call XXX1('hello');
+drop procedure xxx1;
+
+delimiter //;
+CREATE PROCEDURE `XXX2`()
+begin
+declare testval varchar(10);
+set testval = 'hello';
+select metaphon(testval);
+end//
+delimiter ;//
+
+call XXX2();
+drop procedure xxx2;
+
+
+#
+# Drop the example functions from udf_example
+#
+
+DROP FUNCTION metaphon;
+DROP FUNCTION myfunc_double;
+--error 1305
+DROP FUNCTION myfunc_int;
+DROP FUNCTION sequence;
+DROP FUNCTION lookup;
+DROP FUNCTION reverse_lookup;
+DROP FUNCTION avgcost;
+