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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
--source include/have_debug_sync.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
--source ../inc/have_test_udf_registration_component.inc
--echo # 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;
--echo # Must return 12
SELECT dynamic_udf();
--echo # aggregate function test
CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,4);
--echo # aggregate all rows: expect 42
SELECT dynamic_agg(a) FROM t1;
--echo # aggregate with group by: expect 42
SELECT dynamic_agg(a) FROM t1 GROUP BY b;
DROP TABLE t1;
--echo # DROP should fail
--error ER_UDF_DROP_DYNAMICALLY_REGISTERED
DROP FUNCTION dynamic_udf;
connect(c1,localhost,root,,mysql);
connection default;
--echo # Activating the sync point at udf reference count decrease
SET DEBUG_SYNC='udf_handler_destroy_sync SIGNAL pre_cleanup WAIT_FOR continue TIMEOUT 20';
--echo # now emit a call to lock the UDF
send SELECT dynamic_udf();
--echo # switch to c1;
connection c1;
SET DEBUG_SYNC='now WAIT_FOR pre_cleanup';
--echo # 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;
--echo # Uninstall should fail: dynamic_udf stil locked
--error ER_COMPONENTS_UNLOAD_CANT_DEINITIALIZE
UNINSTALL COMPONENT "file://component_test_udf_registration";
--echo # release the reference count decrease
SET DEBUG_SYNC='now SIGNAL continue';
--echo # switch back to default connection
connection default;
--echo # reaping the result from SELECT
reap;
--echo # should pass: because this udf is in use when the above Uninstall
--echo # component is executed and the component deinit function failed as
--echo # this udf is in use.
SELECT dynamic_udf();
--echo # Should fail: this one is unregistered, because this udf is not in use
--echo # when the above Uninstall component is executed.
--error ER_SP_DOES_NOT_EXIST
SELECT dynamic_agg(a);
--echo # 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;
--echo # remove the plugin
UNINSTALL COMPONENT "file://component_test_udf_registration";
--echo # should fail: no UDF
--error ER_SP_DOES_NOT_EXIST
SELECT dynamic_udf();
disconnect c1;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
|