[MDEV-10207] DEFAULT udf(x) does not return an error when UDF is dropped Created: 2016-06-09  Updated: 2017-03-22  Resolved: 2017-03-22

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-10134 Add full support for DEFAULT Closed

 Description   

I'm testing the MDEV-10134 feature tree, branch bb-10.2-default.

I add this script to mysql-test/t/udf.test and run "./mtr udf"

--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO";
SELECT METAPHON('Hello');
CREATE TABLE t1 (a VARCHAR(10), b VARCHAR(10) DEFAULT METAPHON(a));
INSERT INTO t1 (a) VALUES ('Hello');
SELECT * FROM t1;
DROP FUNCTION METAPHON;
# QQ: this should return an error
INSERT INTO t1 (a) VALUES ('Hello');
SELECT * FROM t1;
DROP TABLE t1;

After the function METAPHON is dropped, INSERT still uses it.
It should return an error in the INSERT which goes after "DROP FUNCTION".



 Comments   
Comment by Elena Stepanova [ 2016-07-09 ]

MDEV-10134 has been closed, but the behavior described above still exists.

After running FLUSH TABLES server starts returning the error.

Comment by Sergei Golubchik [ 2017-03-22 ]

This is basically what plugins do in this case. If you UNINSTALL a plugin that is used (locked) at the moment, it will not be completely uninstalled, but only marked as "being uninstalled". You cannot start using it anymore (e.g. cannot open a table in this storage engine), but already opened tables will be able to continue using it. This status is visible in the INFORMATION_SCHEMA.PLUGINS table. When the last user of the plugin will release it, the plugin will be automatically uninstalled.

Same happens with UDFs — an open table with a DEFAULT (or a virtual column) using UDF keeps it loaded. When the table is closed, it releases the UDF and it is unloaded automatically.

But because UDF API is much simpler (and older) that Plugin API, there is no explicit server control over this process and the user has no visibility into it. This can only be fixed when we move UDFs to use the Plugin API.

Generated at Thu Feb 08 07:40:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.