Bug #73802 Easier loading of plugins
Submitted: 4 Sep 2014 8:38 Modified: 8 Mar 2018 11:59
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S4 (Feature request)
Version:8.0 OS:Any
Assigned to: Georgi Kodinov CPU Architecture:Any
Tags: plugin, usability

[4 Sep 2014 8:38] Daniël van Eeden
Description:

- Many plugins have more than one function. Loading all functions takes one statement per function. This is errorprone.
- Loading plugins on Windows or Linux/UNIX is different (.so vs. .dll)

See also: Bug #71263

How to repeat:
Try to load the plugins for
- enterprise thread pool
- json functions
- enterprise encryption
- enterprise audit
- additional storage engines
- InnoDB memcached plugin

Suggested fix:
myplugin.json:
{
  "Name": "My Plugin",
  "Version": "0.1",
  "URL": "https://example.com/foo_func/",
  "License": "GPL",
  "install":
    "Windows": { 
      "foo_func": "foo_func.dll",
      "bar_func": "bar_func.dll"
    }, 
    "Generic": { 
      "foo_func": "foo_func.so",
      "bar_func": "bar_func.so"
    }
  },
  "after_install": "myfunc_tables.sql"
}

INSTALL PLUGIN FROM myplugin.json;

Maybe also use the DOAP standard in addition.
[4 Sep 2014 8:42] Daniël van Eeden
The json should also have return types and supported mysql versions. (Maybe load a different plugin for a different version (e.g. for common_schema or the sys schema)

The json could be read by workbench and then load the plugins in older versions of mysql which do not yet have support for the json plugin loading.
[4 Sep 2014 8:43] Daniël van Eeden
maybe show plugins could read the json files and show not-yet-loaded plugins.
[25 Nov 2014 15:18] Sveta Smirnova
Thank you for the reasonable feature request.
[9 Mar 2016 12:54] Daniël van Eeden
This also could make enabling semisync and group_replication easier.
[29 May 2017 20:05] Daniël van Eeden
added tags and changed version
[16 Nov 2017 17:36] Georgi Kodinov
Would a combination of making an daemon plugin (https://dev.mysql.com/doc/refman/8.0/en/writing-daemon-plugins.html) holding the UDFs and the UDF registration API (https://dev.mysql.com/doc/dev/mysql-server/latest/udf__registration_8h.html) as accessible through the registry plugin service (https://dev.mysql.com/doc/refman/8.0/en/component-plugin-services.html) will fit the bill ? 

The idea is not just have the UDFs in a shared object, but instead also have a daemon plugin (for the init/deinit functions) and have these functions register/unregister all of the UDFs in the shared object.

In this way you will need a single command INSTALL PLUGUIN to install all of your UDFs.

If you think this is a good enough work-around please close the bug as fixed.
[17 Nov 2017 16:01] Daniël van Eeden
That sounds nice, but it wouldn't work for pure-sql extensions like mysql-sys (ps_helper) or common_schema (by Shlomi Noach).

And how would that work for plugins which need to run some sql? (rewriter plugin and memcached plugin)
[17 Nov 2017 16:02] Daniël van Eeden
Also this would still need a different command on Windows (.dll) and BSD (.so).
[7 Dec 2017 9:36] Georgi Kodinov
True, if you do it as a plugin. 
But if you do it as a component, INSTALL COMPONENT does not need the shared object extension.
[27 Feb 2018 15:12] Georgi Kodinov
Daniël,

Would a component registering/unregistering a bunch of UDFs via the service work for you ?
[8 Mar 2018 11:59] Daniël van Eeden
It might.