| 1 |
CREATE USER test@localhost; |
| 2 |
CREATE USER test_2@localhost; |
| 3 |
GRANT CREATE,INSERT,DELETE,DROP,SELECT ON test.* TO test@localhost; |
| 4 |
GRANT CREATE,INSERT,DELETE,DROP,SELECT ON test.* TO test_2@localhost; |
| 5 |
INSTALL COMPONENT "file://component_udf_reg_avg_func"; |
| 6 |
SELECT component_urn from mysql.component; |
| 7 |
component_urn |
| 8 |
file://component_udf_reg_avg_func |
| 9 |
connect c1,localhost,test,,; |
| 10 |
SELECT * FROM performance_schema.user_defined_functions |
| 11 |
WHERE (udf_name LIKE 'myfunc%') or (udf_name LIKE 'avgcost%') |
| 12 |
ORDER BY udf_name; |
| 13 |
ERROR 42000: SELECT command denied to user 'test'@'localhost' for table 'user_defined_functions' |
| 14 |
create table t1(sum int, price float(24)); |
| 15 |
insert into t1 values(100, 50.00), (100, 100.00); |
| 16 |
select avgcost(sum, price) from t1; |
| 17 |
avgcost(sum, price) |
| 18 |
75.0000 |
| 19 |
delete from t1; |
| 20 |
insert into t1 values(100, 54.33), (200, 199.99); |
| 21 |
select avgcost(sum, price) from t1; |
| 22 |
avgcost(sum, price) |
| 23 |
151.4367 |
| 24 |
drop table t1; |
| 25 |
SELECT component_urn from mysql.component; |
| 26 |
ERROR 42000: SELECT command denied to user 'test'@'localhost' for table 'component' |
| 27 |
UNINSTALL COMPONENT "file://component_udf_reg_avg_func"; |
| 28 |
ERROR 42000: DELETE command denied to user 'test'@'localhost' for table 'component' |
| 29 |
connection default; |
| 30 |
GRANT CREATE,INSERT,DELETE,DROP,SELECT ON mysql.component TO test@localhost; |
| 31 |
connection c1; |
| 32 |
SELECT component_urn from mysql.component; |
| 33 |
component_urn |
| 34 |
file://component_udf_reg_avg_func |
| 35 |
UNINSTALL COMPONENT "file://component_udf_reg_avg_func"; |
| 36 |
connection default; |
| 37 |
disconnect c1; |
| 38 |
INSTALL COMPONENT "file://component_udf_reg_int_func"; |
| 39 |
connect c2,localhost,test_2,,; |
| 40 |
SELECT myfunc_int(23); |
| 41 |
connect c1,localhost,test,,; |
| 42 |
SELECT myfunc_int(23); |
| 43 |
connection default; |
| 44 |
SELECT udf_name,udf_return_type,udf_type,udf_library,udf_usage_count>0 |
| 45 |
FROM performance_schema.user_defined_functions |
| 46 |
WHERE (udf_name LIKE 'myfunc%') or (udf_name LIKE 'avgcost%') |
| 47 |
ORDER BY udf_name; |
| 48 |
udf_name udf_return_type udf_type udf_library udf_usage_count>0 |
| 49 |
myfunc_int integer function NULL 1 |
| 50 |
connection c1; |
| 51 |
myfunc_int(23) |
| 52 |
23 |
| 53 |
connection c2; |
| 54 |
myfunc_int(23) |
| 55 |
23 |
| 56 |
connection default; |
| 57 |
UNINSTALL COMPONENT "file://component_udf_reg_int_func"; |
| 58 |
disconnect c1; |
| 59 |
disconnect c2; |
| 60 |
DROP USER test@localhost; |
| 61 |
DROP USER test_2@localhost; |