Debian Codegraph @

mysql-test/suite/service_udf_registration/r/udf_registration.result

raw
1 # Simple load test
2 INSTALL COMPONENT "file://component_test_udf_registration";
3 SELECT * FROM performance_schema.user_defined_functions
4 WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg')
5 ORDER BY UDF_NAME;
6 UDF_NAME UDF_RETURN_TYPE UDF_TYPE UDF_LIBRARY UDF_USAGE_COUNT
7 dynamic_agg integer aggregate NULL 1
8 dynamic_udf integer function NULL 1
9 # Must return 12
10 SELECT dynamic_udf();
11 dynamic_udf()
12 42
13 # aggregate function test
14 CREATE TABLE t1(a INT, b INT);
15 INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,4);
16 # aggregate all rows: expect 42
17 SELECT dynamic_agg(a) FROM t1;
18 dynamic_agg(a)
19 42
20 # aggregate with group by: expect 42
21 SELECT dynamic_agg(a) FROM t1 GROUP BY b;
22 dynamic_agg(a)
23 42
24 42
25 42
26 DROP TABLE t1;
27 # DROP should fail
28 DROP FUNCTION dynamic_udf;
29 ERROR HY000: DROP FUNCTION can't drop a dynamically registered user defined function
30 # Activating the sync point at udf reference count decrease
31 SET DEBUG_SYNC='udf_handler_destroy_sync SIGNAL pre_cleanup WAIT_FOR continue TIMEOUT 20';
32 # now emit a call to lock the UDF
33 SELECT dynamic_udf();
34 # switch to c1;
35 SET DEBUG_SYNC='now WAIT_FOR pre_cleanup';
36 # use counts should be 2 for dynamic_udf and 1 for dynamic_agg
37 SELECT UDF_NAME, UDF_USAGE_COUNT FROM performance_schema.user_defined_functions
38 WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg')
39 ORDER BY UDF_NAME;
40 UDF_NAME UDF_USAGE_COUNT
41 dynamic_agg 1
42 dynamic_udf 2
43 # Uninstall should fail: dynamic_udf stil locked
44 UNINSTALL COMPONENT "file://component_test_udf_registration";
45 ERROR HY000: De-initialization method provided by component 'mysql:test_udf_registration' failed.
46 # release the reference count decrease
47 SET DEBUG_SYNC='now SIGNAL continue';
48 # switch back to default connection
49 # reaping the result from SELECT
50 dynamic_udf()
51 42
52 # should pass: because this udf is in use when the above Uninstall
53 # component is executed and the component deinit function failed as
54 # this udf is in use.
55 SELECT dynamic_udf();
56 dynamic_udf()
57 42
58 # Should fail: this one is unregistered, because this udf is not in use
59 # when the above Uninstall component is executed.
60 SELECT dynamic_agg(a);
61 ERROR 42000: FUNCTION test.dynamic_agg does not exist
62 # dynamic_udf should present and dynamic_agg should not.
63 SELECT * FROM performance_schema.user_defined_functions
64 WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg')
65 ORDER BY UDF_NAME;
66 UDF_NAME UDF_RETURN_TYPE UDF_TYPE UDF_LIBRARY UDF_USAGE_COUNT
67 dynamic_udf integer function NULL 1
68 # remove the plugin
69 UNINSTALL COMPONENT "file://component_test_udf_registration";
70 # should fail: no UDF
71 SELECT dynamic_udf();
72 ERROR 42000: FUNCTION test.dynamic_udf does not exist