mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge branch '10.9' into 10.10
This commit is contained in:
@ -49,20 +49,6 @@ get_native_fct_hash_key(const uchar *buff, size_t *length,
|
||||
}
|
||||
|
||||
|
||||
bool Native_func_registry_array::append_to_hash(HASH *hash) const
|
||||
{
|
||||
DBUG_ENTER("Native_func_registry_array::append_to_hash");
|
||||
for (size_t i= 0; i < count(); i++)
|
||||
{
|
||||
const Native_func_registry &func= element(i);
|
||||
DBUG_ASSERT(func.builder != NULL);
|
||||
if (my_hash_insert(hash, (uchar*) &func))
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_SPATIAL
|
||||
extern Native_func_registry_array native_func_registry_array_geom;
|
||||
#endif
|
||||
@ -5686,7 +5672,7 @@ Create_func_year_week::create_native(THD *thd, const LEX_CSTRING *name,
|
||||
- keep 1 line per entry, it makes grep | sort easier
|
||||
*/
|
||||
|
||||
Native_func_registry func_array[] =
|
||||
const Native_func_registry func_array[] =
|
||||
{
|
||||
{ { STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)},
|
||||
{ { STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)},
|
||||
@ -5892,7 +5878,9 @@ Native_func_registry func_array[] =
|
||||
Native_func_registry_array
|
||||
native_func_registry_array(func_array, array_elements(func_array));
|
||||
|
||||
static HASH native_functions_hash;
|
||||
const size_t func_array_length= sizeof(func_array) / sizeof(Native_func_registry) - 1;
|
||||
|
||||
Native_functions_hash native_functions_hash;
|
||||
|
||||
/*
|
||||
Load the hash table for native functions.
|
||||
@ -5900,74 +5888,57 @@ static HASH native_functions_hash;
|
||||
startup only (before going multi-threaded)
|
||||
*/
|
||||
|
||||
int item_create_init()
|
||||
bool Native_functions_hash::init(size_t count)
|
||||
{
|
||||
DBUG_ENTER("item_create_init");
|
||||
size_t count= native_func_registry_array.count();
|
||||
#ifdef HAVE_SPATIAL
|
||||
count+= native_func_registry_array_geom.count();
|
||||
#endif
|
||||
if (my_hash_init(key_memory_native_functions, & native_functions_hash,
|
||||
DBUG_ENTER("Native_functions_hash::init");
|
||||
|
||||
if (my_hash_init(key_memory_native_functions, this,
|
||||
system_charset_info, (ulong) count, 0, 0, (my_hash_get_key)
|
||||
get_native_fct_hash_key, NULL, MYF(0)))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN(true);
|
||||
|
||||
if (native_func_registry_array.append_to_hash(&native_functions_hash))
|
||||
DBUG_RETURN(1);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPATIAL
|
||||
if (native_func_registry_array_geom.append_to_hash(&native_functions_hash))
|
||||
DBUG_RETURN(1);
|
||||
#endif
|
||||
|
||||
#ifdef DBUG_TRACE
|
||||
for (uint i=0 ; i < native_functions_hash.records ; i++)
|
||||
bool Native_functions_hash::append(const Native_func_registry array[],
|
||||
size_t count)
|
||||
{
|
||||
DBUG_ENTER("Native_functions_hash::append");
|
||||
|
||||
for (size_t i= 0; i < count; i++)
|
||||
{
|
||||
Native_func_registry *func;
|
||||
func= (Native_func_registry*) my_hash_element(& native_functions_hash, i);
|
||||
if (my_hash_insert(this, (uchar*) &array[i]))
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
#if ! defined (DBUG_OFF) && defined (DBUG_TRACE)
|
||||
for (uint i=0 ; i < records ; i++)
|
||||
{
|
||||
const Native_func_registry *func=
|
||||
(Native_func_registry*) my_hash_element(this, i);
|
||||
DBUG_PRINT("info", ("native function: %s length: %u",
|
||||
func->name.str, (uint) func->name.length));
|
||||
}
|
||||
#endif
|
||||
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This function is used (dangerously) by plugin/versioning/versioning.cc
|
||||
TODO: MDEV-20842 Wrap SQL functions defined in
|
||||
plugin/versioning/versioning.cc into MariaDB_FUNCTION_PLUGIN
|
||||
*/
|
||||
int item_create_append(Native_func_registry array[])
|
||||
bool Native_functions_hash::remove(const Native_func_registry array[],
|
||||
size_t count)
|
||||
{
|
||||
Native_func_registry *func;
|
||||
DBUG_ENTER("Native_functions_hash::remove");
|
||||
|
||||
DBUG_ENTER("item_create_append");
|
||||
|
||||
for (func= array; func->builder != NULL; func++)
|
||||
for (size_t i= 0; i < count; i++)
|
||||
{
|
||||
if (my_hash_insert(& native_functions_hash, (uchar*) func))
|
||||
DBUG_RETURN(1);
|
||||
if (my_hash_delete(this, (uchar*) &array[i]))
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
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.
|
||||
@ -5975,10 +5946,10 @@ int item_create_remove(Native_func_registry array[])
|
||||
shutdown only (after thread requests have been executed).
|
||||
*/
|
||||
|
||||
void item_create_cleanup()
|
||||
void Native_functions_hash::cleanup()
|
||||
{
|
||||
DBUG_ENTER("item_create_cleanup");
|
||||
my_hash_free(& native_functions_hash);
|
||||
DBUG_ENTER("Native_functions_hash::cleanup");
|
||||
my_hash_free(this);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -6001,25 +5972,53 @@ function_plugin_find_native_function_builder(THD *thd, const LEX_CSTRING &name)
|
||||
|
||||
|
||||
Create_func *
|
||||
find_native_function_builder(THD *thd, const LEX_CSTRING *name)
|
||||
Native_functions_hash::find(THD *thd, const LEX_CSTRING &name) const
|
||||
{
|
||||
Native_func_registry *func;
|
||||
Create_func *builder= NULL;
|
||||
|
||||
/* Thread safe */
|
||||
func= (Native_func_registry*) my_hash_search(&native_functions_hash,
|
||||
(uchar*) name->str,
|
||||
name->length);
|
||||
func= (Native_func_registry*) my_hash_search(this,
|
||||
(uchar*) name.str,
|
||||
name.length);
|
||||
|
||||
if (func && (builder= func->builder))
|
||||
return builder;
|
||||
|
||||
if ((builder= function_plugin_find_native_function_builder(thd, *name)))
|
||||
if ((builder= function_plugin_find_native_function_builder(thd, name)))
|
||||
return builder;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int item_create_init()
|
||||
{
|
||||
size_t count= native_func_registry_array.count();
|
||||
#ifdef HAVE_SPATIAL
|
||||
count+= native_func_registry_array_geom.count();
|
||||
#endif
|
||||
|
||||
if (native_functions_hash.init(count) ||
|
||||
native_functions_hash.append(native_func_registry_array.elements(),
|
||||
native_func_registry_array.count()))
|
||||
return true;
|
||||
|
||||
#ifdef HAVE_SPATIAL
|
||||
if (native_functions_hash.append(native_func_registry_array_geom.elements(),
|
||||
native_func_registry_array_geom.count()))
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void item_create_cleanup()
|
||||
{
|
||||
native_functions_hash.cleanup();
|
||||
}
|
||||
|
||||
|
||||
Create_qfunc *
|
||||
find_qualified_function_builder(THD *thd)
|
||||
{
|
||||
|
Reference in New Issue
Block a user