MySQL 9.1.0
Source Code Documentation
|
#include "sql/sql_udf.h"
#include <stdio.h>
#include <string.h>
#include <iterator>
#include <memory>
#include <new>
#include <string>
#include <unordered_map>
#include <utility>
#include "m_string.h"
#include "map_helpers.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_config.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sharedlib.h"
#include "my_sys.h"
#include "my_thread_local.h"
#include "mysql/components/service_implementation.h"
#include "mysql/components/services/bits/mysql_rwlock_bits.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_memory_bits.h"
#include "mysql/components/services/bits/psi_rwlock_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/my_loglevel.h"
#include "mysql/psi/mysql_memory.h"
#include "mysql/psi/mysql_rwlock.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "nulls.h"
#include "sql/derror.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/iterators/row_iterator.h"
#include "sql/mdl.h"
#include "sql/mysqld.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_executor.h"
#include "sql/sql_parse.h"
#include "sql/sql_plugin.h"
#include "sql/sql_system_table_check.h"
#include "sql/sql_table.h"
#include "sql/table.h"
#include "sql/thd_raii.h"
#include "sql/thr_malloc.h"
#include "sql/transaction.h"
#include "string_with_len.h"
#include "strxnmov.h"
#include "thr_lock.h"
#include "udf_registration_imp.h"
#include <dlfcn.h>
Functions | |
static udf_func * | add_udf (LEX_STRING *name, Item_result ret, char *dl, Item_udftype typ) |
static void | udf_hash_delete (udf_func *udf) |
Delete the UDF function from the UDF hash. More... | |
static void * | find_udf_dl (const char *dl) |
static char * | init_syms (udf_func *tmp, char *nm) |
static void | init_udf_psi_keys (void) |
void | udf_init_globals () |
Initialize the UDF global structures. More... | |
void | udf_read_functions_table () |
void | udf_unload_udfs () |
Deinitialize the UDF subsystem. More... | |
void | udf_deinit_globals () |
Deinitialize the UDF subsystem. More... | |
void | free_udf (udf_func *udf) |
udf_func * | find_udf (const char *name, size_t length, bool mark_used) |
static bool | udf_end_transaction (THD *thd, bool rollback, udf_func *udf, bool insert_udf) |
Commit or rollback a transaction. More... | |
bool | mysql_create_function (THD *thd, udf_func *udf, bool if_not_exists) |
Create a user defined function. More... | |
bool | mysql_drop_function (THD *thd, const LEX_STRING *udf_name) |
Drop a user defined function. More... | |
void | udf_hash_rlock (void) |
void | udf_hash_unlock (void) |
ulong | udf_hash_size (void) |
void | udf_hash_for_each (udf_hash_for_each_func_t *func, void *arg) |
Variables | |
static bool | initialized = false |
A local flag indicating whether SQL based UDF operations are allowed. More... | |
static MEM_ROOT | mem |
static collation_unordered_map< std::string, udf_func * > * | udf_hash |
static mysql_rwlock_t | THR_LOCK_udf |
static constexpr const size_t | UDF_ALLOC_BLOCK_SIZE {1024} |
static const int | MYSQL_UDF_TABLE_FIELD_COUNT = 4 |
static const TABLE_FIELD_TYPE | mysql_udf_table_fields [MYSQL_UDF_TABLE_FIELD_COUNT] |
static const TABLE_FIELD_DEF | mysql_udf_table_def |
static PSI_memory_key | key_memory_udf_mem |
static PSI_rwlock_key | key_rwlock_THR_LOCK_udf |
static PSI_rwlock_info | all_udf_rwlocks [] |
static PSI_memory_info | all_udf_memory [] |
|
static |
udf_func * find_udf | ( | const char * | name, |
size_t | length, | ||
bool | mark_used | ||
) |
|
static |
void free_udf | ( | udf_func * | udf | ) |
|
static |
|
static |
Create a user defined function.
Atomicity: The operation to create a user defined function is atomic/crash-safe. Changes to the Data-dictionary and writing event to binlog are part of the same transaction. All the changes are done as part of the same transaction or do not have any side effects on the operation failure. UDF hash is in sync with operation state. UDF hash do not contain any stale/incorrect data in case of failure. In case of crash, there won't be any discrepancy between the data-dictionary table and the binary log.
thd | THD context. |
udf | Pointer to UDF function. |
if_not_exists | True if 'IF NOT EXISTS' clause was specified. |
bool mysql_drop_function | ( | THD * | thd, |
const LEX_STRING * | udf_name | ||
) |
Drop a user defined function.
Atomicity: The operation to drop a user defined function is atomic/crash-safe. Changes to the Data-dictionary and writing event to binlog are part of the same transaction. All the changes are done as part of the same transaction or do not have any side effects on the operation failure. UDF hash is in sync with operation state. UDF hash do not contain any stale/incorrect data in case of failure. In case of crash, there won't be any discrepancy between the data-dictionary table and the binary log.
thd | THD context. |
udf_name | Name of the UDF function. |
void udf_deinit_globals | ( | ) |
Deinitialize the UDF subsystem.
This function does the following:
|
static |
Commit or rollback a transaction.
Also close tables which it has opened and release metadata locks. Add/Remove from the in-memory hash depending on transaction commit or rollback and the bool flag passed to this function.
thd | THD context. |
rollback | Rollback transaction if true. |
udf | Pointer to UDF function. |
insert_udf | Insert UDF in hash if true. |
False | - Success. |
True | - Error. |
|
static |
Delete the UDF function from the UDF hash.
udf | Pointer to the UDF function. |
void udf_hash_for_each | ( | udf_hash_for_each_func_t * | func, |
void * | arg | ||
) |
void udf_hash_rlock | ( | void | ) |
ulong udf_hash_size | ( | void | ) |
void udf_hash_unlock | ( | void | ) |
void udf_init_globals | ( | ) |
Initialize the UDF global structures.
This is done as a separate step so that the UDF registration service can work when initializing plugins, which happens before reading the UDF table.
void udf_read_functions_table | ( | ) |
void udf_unload_udfs | ( | ) |
Deinitialize the UDF subsystem.
This function closes the shared libraries.
|
static |
|
static |
|
static |
A local flag indicating whether SQL based UDF operations are allowed.
Now the UDF structures are always allocated/deallocated due to the component service.
So this variable does not cover initialization/deinitialization of these. mem and THR_LOCK_udf are always initialized, even in –skip-grant-tables mode.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
staticconstexpr |
|
static |