Debian Codegraph @

mysql-test/suite/service_udf_registration/t/udf_mix_old_new.test

raw
1 # Register the UDS. The component is only registering UDFs.
2 # To unregister call another component.
3 INSTALL COMPONENT "file://component_udf_reg_only_3_func";
4
5 # Usage of registered UDFs.
6 --error ER_CANT_INITIALIZE_UDF
7 select myfunc_double();
8 select myfunc_double(1);
9 select myfunc_double(78654);
10
11 # Registered UDFs must not be touched by old UDF statements.
12 --error ER_UDF_DROP_DYNAMICALLY_REGISTERED
13 DROP FUNCTION myfunc_double;
14
15 # A registered UDF cannot be created by old SQL statement.
16 --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
17 --error ER_UDF_EXISTS
18 eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB";
19
20 select myfunc_int();
21 select myfunc_int(5);
22 select myfunc_int('MySQL V8.0');
23
24 # Registered UDFs must not be touched by old UDF statements.
25 --error ER_UDF_DROP_DYNAMICALLY_REGISTERED
26 DROP FUNCTION myfunc_int;
27
28 # A registered UDF cannot be created by old SQL statement.
29 --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
30 --error ER_UDF_EXISTS
31 eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB";
32
33 CREATE TABLE t1(a INT, b INT);
34 INSERT INTO t1 values (1,1),(2,2);
35 SELECT myfunc_int(a AS attr_name) FROM t1;
36 drop table t1;
37
38 create table t1(sum int, price float(24));
39 insert into t1 values(100, 50.00), (100, 100.00);
40 select avgcost(sum, price) from t1;
41 delete from t1;
42 insert into t1 values(100, 54.33), (200, 199.99);
43 select avgcost(sum, price) from t1;
44 drop table t1;
45 # Registered UDFs must not be touched by old UDF statements.
46 --error ER_UDF_DROP_DYNAMICALLY_REGISTERED
47 DROP FUNCTION avgcost;
48
49 # Unregister UDFs and unload component.
50 --echo # remove the plugin
51 INSTALL COMPONENT "file://component_udf_unreg_3_func";
52
53 --error ER_SP_DOES_NOT_EXIST
54 select myfunc_double(1);
55 --error ER_SP_DOES_NOT_EXIST
56 select myfunc_int(5);
57
58 # A old style UDF can be uses in parallel to register/unregister.
59 --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
60 eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB";
61 select myfunc_double(1);
62 DROP FUNCTION myfunc_double;
63
64 # Register UDFs again.
65 UNINSTALL COMPONENT "file://component_udf_reg_only_3_func";
66 # Unregister UDFs.
67 UNINSTALL COMPONENT "file://component_udf_unreg_3_func";