| 1 |
# Test that register and unregister of UDFs are in init of different components. |
| 2 |
|
| 3 |
# Register 3 UDFs in init of component. |
| 4 |
INSTALL COMPONENT "file://component_udf_reg_only_3_func"; |
| 5 |
|
| 6 |
# Check of performance_schema contents. |
| 7 |
SELECT * FROM performance_schema.user_defined_functions |
| 8 |
WHERE (udf_name LIKE 'myfunc%') or (udf_name LIKE 'avgcost%') |
| 9 |
ORDER BY udf_name; |
| 10 |
|
| 11 |
# Verify UDFs are usable. |
| 12 |
--error ER_CANT_INITIALIZE_UDF |
| 13 |
select myfunc_double(); |
| 14 |
select myfunc_double(1); |
| 15 |
select myfunc_double(78654); |
| 16 |
|
| 17 |
select myfunc_int(); |
| 18 |
select myfunc_int(5); |
| 19 |
select myfunc_int('MySQL V8.0'); |
| 20 |
|
| 21 |
CREATE TABLE t1(a INT, b INT); |
| 22 |
INSERT INTO t1 values (1,1),(2,2); |
| 23 |
SELECT myfunc_int(a AS attr_name) FROM t1; |
| 24 |
drop table t1; |
| 25 |
|
| 26 |
create table t1(sum int, price float(24)); |
| 27 |
insert into t1 values(100, 50.00), (100, 100.00); |
| 28 |
select avgcost(sum, price) from t1; |
| 29 |
delete from t1; |
| 30 |
insert into t1 values(100, 54.33), (200, 199.99); |
| 31 |
select avgcost(sum, price) from t1; |
| 32 |
drop table t1; |
| 33 |
|
| 34 |
# Unregister UDFs in init of the component. |
| 35 |
--echo # remove the plugin |
| 36 |
INSTALL COMPONENT "file://component_udf_unreg_3_func"; |
| 37 |
|
| 38 |
# Verify UDFs are not more usable. |
| 39 |
--error ER_SP_DOES_NOT_EXIST |
| 40 |
select myfunc_double(1); |
| 41 |
--error ER_SP_DOES_NOT_EXIST |
| 42 |
select myfunc_int(5); |
| 43 |
|
| 44 |
# Unload components (deinit is in both components empty. |
| 45 |
UNINSTALL COMPONENT "file://component_udf_reg_only_3_func"; |
| 46 |
UNINSTALL COMPONENT "file://component_udf_unreg_3_func"; |