Skip to content

Commit 8d5718a

Browse files
maras007dahlerlend
authored andcommitted
Bug#36317795 Contribution: Unified behaviour when calling plugin->deinit 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
1 parent 27bedb8 commit 8d5718a

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

plugin/audit_null/audit_null.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ static int audit_null_plugin_init(void *arg [[maybe_unused]]) {
251251
*/
252252

253253
static int audit_null_plugin_deinit(void *arg [[maybe_unused]]) {
254+
assert(arg);
254255
if (g_plugin_installed == true) {
255256
my_free((void *)(g_record_buffer));
256257

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin) {
747747
engine plugins.
748748
*/
749749
DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
750-
if (plugin->plugin->deinit(nullptr)) {
750+
if (plugin->plugin->deinit(plugin)) {
751751
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
752752
plugin->name.str));
753753
}
@@ -889,7 +889,7 @@ int ha_initialize_handlerton(st_plugin_int *plugin) {
889889
Let plugin do its inner deinitialization as plugin->init()
890890
was successfully called before.
891891
*/
892-
if (plugin->plugin->deinit) (void)plugin->plugin->deinit(nullptr);
892+
if (plugin->plugin->deinit) (void)plugin->plugin->deinit(plugin);
893893

894894
err:
895895
my_free(hton);

sql/sql_audit.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ static bool calc_class_mask(THD *, plugin_ref plugin, void *arg) {
767767
int finalize_audit_plugin(st_plugin_int *plugin) {
768768
unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
769769

770-
if (plugin->plugin->deinit && plugin->plugin->deinit(nullptr)) {
770+
if (plugin->plugin->deinit && plugin->plugin->deinit(plugin)) {
771771
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
772772
plugin->name.str));
773773
DBUG_EXECUTE("finalize_audit_plugin", return 1;);

sql/sql_show.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5079,7 +5079,7 @@ int finalize_schema_table(st_plugin_int *plugin) {
50795079
if (schema_table) {
50805080
if (plugin->plugin->deinit) {
50815081
DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
5082-
if (plugin->plugin->deinit(nullptr)) {
5082+
if (plugin->plugin->deinit(plugin)) {
50835083
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
50845084
plugin->name.str));
50855085
}

storage/example/ha_example.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ static int example_init_func(void *p) {
126126
return 0;
127127
}
128128

129+
static int example_deinit_func(void *p [[maybe_unused]]) {
130+
DBUG_TRACE;
131+
132+
assert(p);
133+
134+
return 0;
135+
}
136+
129137
/**
130138
@brief
131139
Example of simple lock controls. The "share" it creates is a
@@ -893,9 +901,9 @@ mysql_declare_plugin(example){
893901
PLUGIN_AUTHOR_ORACLE,
894902
"Example storage engine",
895903
PLUGIN_LICENSE_GPL,
896-
example_init_func, /* Plugin Init */
897-
nullptr, /* Plugin check uninstall */
898-
nullptr, /* Plugin Deinit */
904+
example_init_func, /* Plugin Init */
905+
nullptr, /* Plugin check uninstall */
906+
example_deinit_func, /* Plugin Deinit */
899907
0x0001 /* 0.1 */,
900908
func_status, /* status variables */
901909
example_system_variables, /* system variables */

0 commit comments

Comments
 (0)