File: udf_registration.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (72 lines) | stat: -rw-r--r-- 2,581 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
# Simple load test
INSTALL COMPONENT "file://component_test_udf_registration";
SELECT * FROM performance_schema.user_defined_functions
WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg')
ORDER BY UDF_NAME;
UDF_NAME	UDF_RETURN_TYPE	UDF_TYPE	UDF_LIBRARY	UDF_USAGE_COUNT
dynamic_agg	integer	aggregate	NULL	1
dynamic_udf	integer	function	NULL	1
# Must return 12
SELECT dynamic_udf();
dynamic_udf()
42
# aggregate function test
CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,4);
# aggregate all rows: expect 42
SELECT dynamic_agg(a) FROM t1;
dynamic_agg(a)
42
# aggregate with group by: expect 42
SELECT dynamic_agg(a) FROM t1 GROUP BY b;
dynamic_agg(a)
42
42
42
DROP TABLE t1;
# DROP should fail
DROP FUNCTION dynamic_udf;
ERROR HY000: DROP FUNCTION can't drop a dynamically registered user defined function
# Activating the sync point at udf reference count decrease
SET DEBUG_SYNC='udf_handler_destroy_sync SIGNAL pre_cleanup WAIT_FOR continue TIMEOUT 20';
# now emit a call to lock the UDF
SELECT dynamic_udf();
# switch to c1;
SET DEBUG_SYNC='now WAIT_FOR pre_cleanup';
# use counts should be 2 for dynamic_udf and 1 for dynamic_agg
SELECT UDF_NAME, UDF_USAGE_COUNT FROM performance_schema.user_defined_functions
WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg')
ORDER BY UDF_NAME;
UDF_NAME	UDF_USAGE_COUNT
dynamic_agg	1
dynamic_udf	2
# Uninstall should fail: dynamic_udf stil locked
UNINSTALL COMPONENT "file://component_test_udf_registration";
ERROR HY000: De-initialization method provided by component 'mysql:test_udf_registration' failed.
# release the reference count decrease
SET DEBUG_SYNC='now SIGNAL continue';
# switch back to default connection
# reaping the result from SELECT
dynamic_udf()
42
# should pass: because this udf is in use when the above Uninstall
# component is executed and the component deinit function failed as
# this udf is in use.
SELECT dynamic_udf();
dynamic_udf()
42
# Should fail: this one is unregistered, because this udf is not in use
# when the above Uninstall component is executed.
SELECT dynamic_agg(a);
ERROR 42000: FUNCTION test.dynamic_agg does not exist
# dynamic_udf should present and dynamic_agg should not.
SELECT * FROM performance_schema.user_defined_functions
WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg')
ORDER BY UDF_NAME;
UDF_NAME	UDF_RETURN_TYPE	UDF_TYPE	UDF_LIBRARY	UDF_USAGE_COUNT
dynamic_udf	integer	function	NULL	1
# remove the plugin
UNINSTALL COMPONENT "file://component_test_udf_registration";
# should fail: no UDF
SELECT dynamic_udf();
ERROR 42000: FUNCTION test.dynamic_udf does not exist