Bug #121730 Loadable function stays in use after a prepared statement's reprepare fails

Submitted: 10 Nov 10:19
Reporter: Tomas Ulin Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:any OS:Any
Assigned to: CPU Architecture:Any

[10 Nov 10:19] Tomas Ulin
Description:
A prepared statement that calls a loadable function is reprepared at every
EXECUTE. When that reprepare fails, the function's usage count is never
released. After DEALLOCATE PREPARE and DROP FUNCTION, the function is still
listed in performance_schema.user_defined_functions with udf_usage_count 1.
Without the failed EXECUTE, it is gone.

How to repeat:
MTR test, with -master.opt containing $UDF_EXAMPLE_LIB_OPT:

--source include/have_udf.inc

--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB";
CREATE TABLE t (id INT PRIMARY KEY, c INT);
INSERT INTO t VALUES (1, 1);
PREPARE s FROM 'SELECT myfunc_int(1) AS u FROM t WHERE c = 1';
EXECUTE s;
ALTER TABLE t DROP COLUMN c;
--error ER_BAD_FIELD_ERROR
EXECUTE s;
DEALLOCATE PREPARE s;
DROP FUNCTION myfunc_int;
SELECT udf_name, udf_usage_count FROM performance_schema.user_defined_functions
  WHERE udf_name = 'myfunc_int';
DROP TABLE t;

Result:
udf_name        udf_usage_count
myfunc_int      1

Expected: no row. MTR's check-testcase also reports myfunc_int as left behind.
[10 Nov 10:20] Tomas Ulin
test

Attachment: ps_udf_drop_after_failed_reprepare.test (application/octet-stream, text), 1.14 KiB.

[10 Nov 10:20] Tomas Ulin
master opt

Attachment: ps_udf_drop_after_failed_reprepare-master.opt (application/octet-stream, text), 21 bytes.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.