| 1 |
INSTALL COMPONENT "file://component_udf_reg_only_3_func"; |
| 2 |
select myfunc_double(); |
| 3 |
ERROR HY000: Can't initialize function 'myfunc_double'; myfunc_double must have at least one argument |
| 4 |
select myfunc_double(1); |
| 5 |
myfunc_double(1) |
| 6 |
49.00 |
| 7 |
select myfunc_double(78654); |
| 8 |
myfunc_double(78654) |
| 9 |
54.00 |
| 10 |
DROP FUNCTION myfunc_double; |
| 11 |
ERROR HY000: DROP FUNCTION can't drop a dynamically registered user defined function |
| 12 |
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB"; |
| 13 |
ERROR HY000: Function 'myfunc_double' already exists |
| 14 |
select myfunc_int(); |
| 15 |
myfunc_int() |
| 16 |
0 |
| 17 |
select myfunc_int(5); |
| 18 |
myfunc_int(5) |
| 19 |
5 |
| 20 |
select myfunc_int('MySQL V8.0'); |
| 21 |
myfunc_int('MySQL V8.0') |
| 22 |
10 |
| 23 |
DROP FUNCTION myfunc_int; |
| 24 |
ERROR HY000: DROP FUNCTION can't drop a dynamically registered user defined function |
| 25 |
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; |
| 26 |
ERROR HY000: Function 'myfunc_int' already exists |
| 27 |
CREATE TABLE t1(a INT, b INT); |
| 28 |
INSERT INTO t1 values (1,1),(2,2); |
| 29 |
SELECT myfunc_int(a AS attr_name) FROM t1; |
| 30 |
myfunc_int(a AS attr_name) |
| 31 |
1 |
| 32 |
2 |
| 33 |
drop table t1; |
| 34 |
create table t1(sum int, price float(24)); |
| 35 |
insert into t1 values(100, 50.00), (100, 100.00); |
| 36 |
select avgcost(sum, price) from t1; |
| 37 |
avgcost(sum, price) |
| 38 |
75.0000 |
| 39 |
delete from t1; |
| 40 |
insert into t1 values(100, 54.33), (200, 199.99); |
| 41 |
select avgcost(sum, price) from t1; |
| 42 |
avgcost(sum, price) |
| 43 |
151.4367 |
| 44 |
drop table t1; |
| 45 |
DROP FUNCTION avgcost; |
| 46 |
ERROR HY000: DROP FUNCTION can't drop a dynamically registered user defined function |
| 47 |
# remove the plugin |
| 48 |
INSTALL COMPONENT "file://component_udf_unreg_3_func"; |
| 49 |
select myfunc_double(1); |
| 50 |
ERROR 42000: FUNCTION test.myfunc_double does not exist |
| 51 |
select myfunc_int(5); |
| 52 |
ERROR 42000: FUNCTION test.myfunc_int does not exist |
| 53 |
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB"; |
| 54 |
select myfunc_double(1); |
| 55 |
myfunc_double(1) |
| 56 |
49.00 |
| 57 |
DROP FUNCTION myfunc_double; |
| 58 |
UNINSTALL COMPONENT "file://component_udf_reg_only_3_func"; |
| 59 |
UNINSTALL COMPONENT "file://component_udf_unreg_3_func"; |