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