Commit 23e09062 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-20842 Crash using versioning plugin functions after plugin was removed from server

Remove plugin functions via item_create_remove() at deinit time.
parent 6d73282b
......@@ -506,3 +506,9 @@ add period for system_time(`row_start`,`row_end`),
modify x int after row_start,
with system versioning;
create or replace database test;
#
# MDEV-20842 Crash using versioning plugin functions after plugin was removed from server
#
uninstall plugin test_versioning;
select trt_begin_ts(0);
ERROR 42000: FUNCTION trt_begin_ts does not exist
......@@ -529,5 +529,11 @@ alter table t add `row_start` bigint unsigned as row start,
modify x int after row_start,
with system versioning;
create or replace database test;
--echo #
--echo # MDEV-20842 Crash using versioning plugin functions after plugin was removed from server
--echo #
uninstall plugin test_versioning;
--error ER_SP_DOES_NOT_EXIST
select trt_begin_ts(0);
......@@ -175,6 +175,7 @@ static int versioning_plugin_init(void *p __attribute__ ((unused)))
static int versioning_plugin_deinit(void *p __attribute__ ((unused)))
{
DBUG_ENTER("versioning_plugin_deinit");
(void) item_create_remove(func_array);
DBUG_RETURN(0);
}
......
......@@ -7465,6 +7465,21 @@ int item_create_append(Native_func_registry array[])
DBUG_RETURN(0);
}
int item_create_remove(Native_func_registry array[])
{
Native_func_registry *func;
DBUG_ENTER("item_create_remove");
for (func= array; func->builder != NULL; func++)
{
if (my_hash_delete(& native_functions_hash, (uchar*) func))
DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
/*
Empty the hash table for native functions.
Note: this code is not thread safe, and is intended to be used at server
......
......@@ -214,6 +214,7 @@ struct Native_func_registry
int item_create_init();
int item_create_append(Native_func_registry array[]);
int item_create_remove(Native_func_registry array[]);
void item_create_cleanup();
Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment