For the complete documentation index, see llms.txt. This page is also available as Markdown.

THD Specifics Service

Plugin API reference: THD Specifics Service. Generated from the MariaDB server headers by doxygen and moxygen.

Plugin API / Services for Plugins / Plugin Services

THD specific for plugin(s)

This API provides pthread_getspecific() like functionality to plugin authors. This is a functional alternative to the declarative MYSQL_THDVAR_* API.

A plugin should at init call thd_key_create() that create a key that will have storage in each THD. The key should be used by all threads and can be used concurrently from all threads.

A plugin should at deinit call thd_key_delete().

Alternatively, a plugin can use thd_key_create_from_var(K,V) to create a key that corresponds to a named MYSQL_THDVAR_* variable.

This API is also safe when using pool-of-threads in which case pthread_getspecific() is not, because the actual OS thread may change.

Normally one should prefer MYSQL_THDVAR_* declarative API.

The benefits are:

  • It supports typed variables (int, char*, enum, etc), not only void*.

  • The memory allocated for MYSQL_THDVAR_* is free'd automatically (if PLUGIN_VAR_MEMALLOC is specified).

  • Continuous loading and unloading of the same plugin does not allocate memory for same variables over and over again.

An example of using MYSQL_THDVAR_* for a thd local storage:

MYSQL_THDVAR_STR(my_tls,
        PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT,
        "thd local storage example", 0, 0, 0);

Classes

Macros

Name
Description

create THD specific storage

delete THD specific storage

get thd specific storage

set thd specific storage


thd_key_create_from_var

Defined in service_thd_specifics.h:81


thd_key_create

Defined in service_thd_specifics.h:90

create THD specific storage

Returns

0 on success else errno is returned


thd_key_delete

Defined in service_thd_specifics.h:94

delete THD specific storage


thd_getspecific

Defined in service_thd_specifics.h:102

get thd specific storage

  • first time this is called from a thread it will return 0

  • this call is thread-safe in that different threads may call this simultaneously if operating on different THDs.

  • this call acquires no mutexes and is implemented as an array lookup


thd_setspecific

Defined in service_thd_specifics.h:110

set thd specific storage

  • first time this is called from a thread it will return 0

  • this call is thread-safe in that different threads may call this simultaneously if operating on different THDs.

  • this call acquires no mutexes and is implemented as an array lookup

Typedefs

Return
Name
Description

MYSQL_THD_KEY_T

Defined in service_thd_specifics.h:72

Variables

Return
Name
Description

thd_specifics_service

Type: struct thd_specifics_service_st *

Defined in service_thd_specifics.h:79

Class Definitions

thd_specifics_service_st

Defined in service_thd_specifics.h:74

Public Attributes


thd_key_create_func

Defined in service_thd_specifics.h:75


thd_key_delete_func

Defined in service_thd_specifics.h:76


thd_getspecific_func

Defined in service_thd_specifics.h:77


thd_setspecific_func

Defined in service_thd_specifics.h:78

This page is licensed: GPLv2

spinner

Last updated

Was this helpful?