Skip to content

Commit

Permalink
Bug#36317795 Contribution: Unified behaviour when calling plugin->dei…
Browse files Browse the repository at this point in the history
…nit for all plugins

This patch unifies plugin's deinit function call to pass valid plugin pointer
instead of the nullptr for all types of plugin.

Change-Id: I482497bbaff28d5cd31d74d694056a4df6693152
  • Loading branch information
maras007 committed Mar 6, 2024
1 parent 98d8023 commit ce03671
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions plugin/audit_null/audit_null.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ static int audit_null_plugin_init(void *arg [[maybe_unused]]) {
*/

static int audit_null_plugin_deinit(void *arg [[maybe_unused]]) {
assert(arg);
if (g_plugin_installed == true) {
my_free((void *)(g_record_buffer));

Expand Down
4 changes: 2 additions & 2 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin) {
engine plugins.
*/
DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
if (plugin->plugin->deinit(nullptr)) {
if (plugin->plugin->deinit(plugin)) {
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
plugin->name.str));
}
Expand Down Expand Up @@ -887,7 +887,7 @@ int ha_initialize_handlerton(st_plugin_int *plugin) {
Let plugin do its inner deinitialization as plugin->init()
was successfully called before.
*/
if (plugin->plugin->deinit) (void)plugin->plugin->deinit(nullptr);
if (plugin->plugin->deinit) (void)plugin->plugin->deinit(plugin);

err:
my_free(hton);
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_audit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ static bool calc_class_mask(THD *, plugin_ref plugin, void *arg) {
int finalize_audit_plugin(st_plugin_int *plugin) {
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];

if (plugin->plugin->deinit && plugin->plugin->deinit(nullptr)) {
if (plugin->plugin->deinit && plugin->plugin->deinit(plugin)) {
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
plugin->name.str));
DBUG_EXECUTE("finalize_audit_plugin", return 1;);
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5186,7 +5186,7 @@ int finalize_schema_table(st_plugin_int *plugin) {
if (schema_table) {
if (plugin->plugin->deinit) {
DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
if (plugin->plugin->deinit(nullptr)) {
if (plugin->plugin->deinit(plugin)) {
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
plugin->name.str));
}
Expand Down
14 changes: 11 additions & 3 deletions storage/example/ha_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ static int example_init_func(void *p) {
return 0;
}

static int example_deinit_func(void *p [[maybe_unused]]) {
DBUG_TRACE;

assert(p);

return 0;
}

/**
@brief
Example of simple lock controls. The "share" it creates is a
Expand Down Expand Up @@ -892,9 +900,9 @@ mysql_declare_plugin(example){
PLUGIN_AUTHOR_ORACLE,
"Example storage engine",
PLUGIN_LICENSE_GPL,
example_init_func, /* Plugin Init */
nullptr, /* Plugin check uninstall */
nullptr, /* Plugin Deinit */
example_init_func, /* Plugin Init */
nullptr, /* Plugin check uninstall */
example_deinit_func, /* Plugin Deinit */
0x0001 /* 0.1 */,
func_status, /* status variables */
example_system_variables, /* system variables */
Expand Down

0 comments on commit ce03671

Please sign in to comment.