mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
d2574b928e
sql/sql_parse.cc: already fixed in right way sql/udf_example.cc: not used function tests/udf_test.res: added test of AS tests/udf_test: added test of AS
33 lines
1.2 KiB
Text
33 lines
1.2 KiB
Text
#
|
|
# For this script to work, you need to compile and install the
|
|
# udf_example script !
|
|
#
|
|
|
|
CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
|
|
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
|
|
CREATE FUNCTION myfunc_int 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";
|
|
CREATE FUNCTION myfunc_argument_name RETURNS STRING SONAME "udf_example.so";
|
|
|
|
select metaphon("hello");
|
|
select myfunc_double("hello","world");
|
|
select myfunc_int(1,2,3),myfunc_int("1","11","111");
|
|
select lookup("localhost");
|
|
select reverse_lookup("127.0.0.1");
|
|
|
|
create temporary table t1 (a int,b double);
|
|
insert into t1 values (1,5),(1,4),(2,8),(3,9),(4,11);
|
|
select avgcost(a,b) from t1;
|
|
select avgcost(a,b) from t1 group by a;
|
|
select a, myfunc_argument_name(a), myfunc_argument_name(a as b) from t1;
|
|
drop table t1;
|
|
|
|
DROP FUNCTION metaphon;
|
|
DROP FUNCTION myfunc_double;
|
|
DROP FUNCTION myfunc_int;
|
|
DROP FUNCTION lookup;
|
|
DROP FUNCTION reverse_lookup;
|
|
DROP FUNCTION avgcost;
|
|
DROP FUNCTION myfunc_argument_name;
|