| 1 |
--source include/have_debug_sync.inc |
| 2 |
# Save the initial number of concurrent sessions |
| 3 |
--source include/count_sessions.inc |
| 4 |
|
| 5 |
--source ../inc/have_test_udf_registration_component.inc |
| 6 |
|
| 7 |
--echo # Simple load test |
| 8 |
INSTALL COMPONENT "file://component_test_udf_registration"; |
| 9 |
|
| 10 |
SELECT * FROM performance_schema.user_defined_functions |
| 11 |
WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg') |
| 12 |
ORDER BY UDF_NAME; |
| 13 |
|
| 14 |
--echo # Must return 12 |
| 15 |
SELECT dynamic_udf(); |
| 16 |
|
| 17 |
--echo # aggregate function test |
| 18 |
CREATE TABLE t1(a INT, b INT); |
| 19 |
INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,4); |
| 20 |
|
| 21 |
--echo # aggregate all rows: expect 42 |
| 22 |
SELECT dynamic_agg(a) FROM t1; |
| 23 |
|
| 24 |
--echo # aggregate with group by: expect 42 |
| 25 |
SELECT dynamic_agg(a) FROM t1 GROUP BY b; |
| 26 |
|
| 27 |
DROP TABLE t1; |
| 28 |
|
| 29 |
--echo # DROP should fail |
| 30 |
--error ER_UDF_DROP_DYNAMICALLY_REGISTERED |
| 31 |
DROP FUNCTION dynamic_udf; |
| 32 |
|
| 33 |
connect(c1,localhost,root,,mysql); |
| 34 |
connection default; |
| 35 |
|
| 36 |
--echo # Activating the sync point at udf reference count decrease |
| 37 |
SET DEBUG_SYNC='udf_handler_destroy_sync SIGNAL pre_cleanup WAIT_FOR continue TIMEOUT 20'; |
| 38 |
|
| 39 |
--echo # now emit a call to lock the UDF |
| 40 |
send SELECT dynamic_udf(); |
| 41 |
|
| 42 |
--echo # switch to c1; |
| 43 |
connection c1; |
| 44 |
|
| 45 |
SET DEBUG_SYNC='now WAIT_FOR pre_cleanup'; |
| 46 |
|
| 47 |
--echo # use counts should be 2 for dynamic_udf and 1 for dynamic_agg |
| 48 |
SELECT UDF_NAME, UDF_USAGE_COUNT FROM performance_schema.user_defined_functions |
| 49 |
WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg') |
| 50 |
ORDER BY UDF_NAME; |
| 51 |
|
| 52 |
--echo # Uninstall should fail: dynamic_udf stil locked |
| 53 |
--error ER_COMPONENTS_UNLOAD_CANT_DEINITIALIZE |
| 54 |
UNINSTALL COMPONENT "file://component_test_udf_registration"; |
| 55 |
|
| 56 |
--echo # release the reference count decrease |
| 57 |
SET DEBUG_SYNC='now SIGNAL continue'; |
| 58 |
|
| 59 |
--echo # switch back to default connection |
| 60 |
connection default; |
| 61 |
--echo # reaping the result from SELECT |
| 62 |
reap; |
| 63 |
|
| 64 |
--echo # should pass: because this udf is in use when the above Uninstall |
| 65 |
--echo # component is executed and the component deinit function failed as |
| 66 |
--echo # this udf is in use. |
| 67 |
SELECT dynamic_udf(); |
| 68 |
|
| 69 |
--echo # Should fail: this one is unregistered, because this udf is not in use |
| 70 |
--echo # when the above Uninstall component is executed. |
| 71 |
--error ER_SP_DOES_NOT_EXIST |
| 72 |
SELECT dynamic_agg(a); |
| 73 |
|
| 74 |
--echo # dynamic_udf should present and dynamic_agg should not. |
| 75 |
SELECT * FROM performance_schema.user_defined_functions |
| 76 |
WHERE UDF_NAME IN('dynamic_udf', 'dynamic_agg') |
| 77 |
ORDER BY UDF_NAME; |
| 78 |
|
| 79 |
--echo # remove the plugin |
| 80 |
UNINSTALL COMPONENT "file://component_test_udf_registration"; |
| 81 |
|
| 82 |
--echo # should fail: no UDF |
| 83 |
--error ER_SP_DOES_NOT_EXIST |
| 84 |
SELECT dynamic_udf(); |
| 85 |
|
| 86 |
disconnect c1; |
| 87 |
|
| 88 |
# Wait till all disconnects are completed |
| 89 |
--source include/wait_until_count_sessions.inc |