MySQL  8.0.17
Source Code Documentation
psi_thread.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef MYSQL_PSI_THREAD_H
24 #define MYSQL_PSI_THREAD_H
25 
26 /**
27  @file include/mysql/psi/psi_thread.h
28  Performance schema instrumentation interface.
29 
30  @defgroup psi_abi_thread Thread Instrumentation (ABI)
31  @ingroup psi_abi
32  @{
33 */
34 
35 #include "my_inttypes.h"
36 #include "my_macros.h"
37 #include "my_psi_config.h" // IWYU pragma: keep
38 #include "my_sharedlib.h"
40 
41 /**
42  @def PSI_THREAD_VERSION_1
43  Performance Schema Thread Interface number for version 1.
44  This version is obsolete.
45 */
46 #define PSI_THREAD_VERSION_1 1
47 
48 /**
49  @def PSI_THREAD_VERSION_2
50  Performance Schema Thread Interface number for version 2.
51  This version is obsolete.
52 */
53 #define PSI_THREAD_VERSION_2 2
54 
55 /**
56  @def PSI_THREAD_VERSION_3
57  Performance Schema Thread Interface number for version 3.
58  This version is supported.
59 */
60 #define PSI_THREAD_VERSION_3 3
61 
62 /**
63  @def PSI_CURRENT_THREAD_VERSION
64  Performance Schema Thread Interface number for the most recent version.
65  The most current version is @c PSI_THREAD_VERSION_3
66 */
67 #define PSI_CURRENT_THREAD_VERSION 3
68 
69 /** Entry point for the performance schema interface. */
71  /**
72  ABI interface finder.
73  Calling this method with an interface version number returns either
74  an instance of the ABI for this version, or NULL.
75  @sa PSI_THREAD_VERSION_1
76  @sa PSI_THREAD_VERSION_2
77  @sa PSI_THREAD_VERSION_3
78  @sa PSI_CURRENT_THREAD_VERSION
79  */
80  void *(*get_interface)(int version);
81 };
83 
84 #ifdef HAVE_PSI_THREAD_INTERFACE
85 
86 /**
87  Performance Schema Thread Interface, version 3.
88  @since PSI_THREAD_VERSION_3
89 */
91  /** @sa register_thread_v1_t. */
93  /** @sa spawn_thread_v1_t. */
95  /** @sa new_thread_v1_t. */
97  /** @sa set_thread_id_v1_t. */
99  /** @sa get_current_thread_internal_id_v2_t. */
101  /** @sa get_thread_internal_id_v2_t. */
103  /** @sa get_thread_by_id_v2_t. */
105  /** @sa set_thread_THD_v1_t. */
107  /** @sa set_thread_os_id_v1_t. */
109  /** @sa get_thread_v1_t. */
111  /** @sa set_thread_user_v1_t. */
113  /** @sa set_thread_account_v1_t. */
115  /** @sa set_thread_db_v1_t. */
117  /** @sa set_thread_command_v1_t. */
119  /** @sa set_connection_type_v1_t. */
121  /** @sa set_thread_start_time_v1_t. */
123  /** @sa set_thread_info_v1_t. */
125  /** @sa set_thread_resource_group_v1_t. */
127  /** @sa set_thread_resource_group_by_id_v1_t. */
129  /** @sa set_thread_v1_t. */
131  /** @sa aggregate_thread_status_v1_t. */
133  /** @sa delete_current_thread_v1_t. */
135  /** @sa delete_thread_v1_t. */
137  /** @sa set_thread_connect_attrs_v1_t. */
139  /** @sa get_current_thread_event_id_v2_t. */
141  /** @sa get_thread_event_id_v2_t. */
143  /** @sa get_thread_system_attrs_v1_t. */
145  /** @sa get_thread_system_attrs_by_id_v1_t. */
147  /** @sa register_notification_v1_t. */
149  /** @sa unregister_notification_v1_t. */
151  /** @sa notify_session_connect_v1_t. */
153  /** @sa notify_session_disconnect_v1_t. */
155  /** @sa notify_session_change_user_v1_t. */
157 };
158 
160 
162 
163 #endif /* HAVE_PSI_THREAD_INTERFACE */
164 
165 /** @} (end of group psi_abi_thread) */
166 
167 #endif /* MYSQL_PSI_THREAD_H */
void(* delete_current_thread_v1_t)(void)
Delete the current thread instrumentation.
Definition: psi_thread_bits.h:283
void(* set_thread_command_v1_t)(int command)
Assign a current command to the instrumented thread.
Definition: psi_thread_bits.h:214
Some common macros.
int(* get_thread_system_attrs_by_id_v3_t)(PSI_thread *thread, unsigned long long thread_id, PSI_thread_attrs_v3 *thread_attrs)
Get system attributes for an instrumented thread, identified either by the thread instrumentation or ...
Definition: psi_thread_bits.h:418
void(* set_thread_user_v1_t)(const char *user, int user_len)
Assign a user name to the instrumented thread.
Definition: psi_thread_bits.h:191
void(* register_thread_v1_t)(const char *category, struct PSI_thread_info_v1 *info, int count)
Thread registration API.
Definition: psi_thread_bits.h:106
int(* spawn_thread_v1_t)(PSI_thread_key key, my_thread_handle *thread, const my_thread_attr_t *attr, void *(*start_routine)(void *), void *arg)
Spawn a thread.
Definition: psi_thread_bits.h:119
Entry point for the performance schema interface.
Definition: psi_thread.h:70
void(* aggregate_thread_status_v2_t)(struct PSI_thread *thread)
Aggregate the thread status variables.
Definition: psi_thread_bits.h:280
set_thread_v1_t set_thread
Definition: psi_thread.h:130
set_thread_info_v1_t set_thread_info
Definition: psi_thread.h:124
Some integer typedefs for easier portability.
set_connection_type_v1_t set_connection_type
Definition: psi_thread.h:120
unsigned long long(* get_current_thread_internal_id_v2_t)()
Read the THREAD_ID of the current thread.
Definition: psi_thread_bits.h:152
int(* set_thread_resource_group_v1_t)(const char *group_name, int group_name_len, void *user_data)
Assign a resource group name to the current thread.
Definition: psi_thread_bits.h:249
#define MYSQL_PLUGIN_IMPORT
Definition: my_sharedlib.h:70
get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id
Definition: psi_thread.h:146
set_thread_user_v1_t set_thread_user
Definition: psi_thread.h:112
set_thread_resource_group_by_id_v1_t set_thread_resource_group_by_id
Definition: psi_thread.h:128
int(* unregister_notification_v1_t)(int handle)
Unregister callback functions for the Notification service.
Definition: psi_thread_bits.h:441
struct PSI_thread *(* get_thread_by_id_v2_t)(unsigned long long processlist_id)
Get the instrumentation for the thread of given PROCESSLIST_ID.
Definition: psi_thread_bits.h:167
get_thread_internal_id_v2_t get_thread_internal_id
Definition: psi_thread.h:102
register_notification_v3_t register_notification
Definition: psi_thread.h:148
void(* set_thread_info_v1_t)(const char *info, unsigned int info_len)
Assign a process info to the instrumented thread.
Definition: psi_thread_bits.h:239
notify_session_connect_v1_t notify_session_connect
Definition: psi_thread.h:152
MYSQL_PLUGIN_IMPORT PSI_thread_service_t * psi_thread_service
Definition: psi_noop.cc:224
int(* register_notification_v3_t)(const PSI_notification_v3 *callbacks, bool with_ref_count)
Register callback functions for the Notification service.
Definition: psi_thread_bits.h:431
void(* set_thread_db_v1_t)(const char *db, int db_len)
Assign a current database to the instrumented thread.
Definition: psi_thread_bits.h:208
void(* set_thread_v1_t)(struct PSI_thread *thread)
Attach a thread instrumentation to the running thread.
Definition: psi_thread_bits.h:277
void(* notify_session_change_user_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a changer user event.
Definition: psi_thread_bits.h:462
void(* get_thread_event_id_v2_t)(struct PSI_thread *psi, unsigned long long *thread_internal_id, unsigned long long *event_id)
Get the thread current event.
Definition: psi_thread_bits.h:325
Functions related to handling of plugins and other dynamically loaded libraries.
void(* set_thread_os_id_v1_t)(struct PSI_thread *thread)
Assign the current operating system thread id to an instrumented thread.
Definition: psi_thread_bits.h:175
set_thread_account_v1_t set_thread_account
Definition: psi_thread.h:114
get_thread_event_id_v2_t get_thread_event_id
Definition: psi_thread.h:142
notify_session_change_user_v1_t notify_session_change_user
Definition: psi_thread.h:156
delete_current_thread_v1_t delete_current_thread
Definition: psi_thread.h:134
set_thread_resource_group_v1_t set_thread_resource_group
Definition: psi_thread.h:126
unregister_notification_v1_t unregister_notification
Definition: psi_thread.h:150
Performance schema instrumentation interface.
set_thread_os_id_v1_t set_thread_os_id
Definition: psi_thread.h:108
set_thread_connect_attrs_v1_t set_thread_connect_attrs
Definition: psi_thread.h:138
void(* notify_session_connect_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a session connect event.
Definition: psi_thread_bits.h:448
void(* set_thread_account_v1_t)(const char *user, int user_len, const char *host, int host_len)
Assign a user name and host name to the instrumented thread.
Definition: psi_thread_bits.h:200
void(* delete_thread_v1_t)(struct PSI_thread *thread)
Delete a thread instrumentation.
Definition: psi_thread_bits.h:286
void(* get_current_thread_event_id_v2_t)(unsigned long long *thread_internal_id, unsigned long long *event_id)
Get the current thread current event.
Definition: psi_thread_bits.h:307
spawn_thread_v1_t spawn_thread
Definition: psi_thread.h:94
get_current_thread_event_id_v2_t get_current_thread_event_id
Definition: psi_thread.h:140
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Performance Schema Thread Interface, version 3.
Definition: psi_thread.h:90
void(* notify_session_disconnect_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a session disconnect event.
Definition: psi_thread_bits.h:455
set_thread_THD_v1_t set_thread_THD
Definition: psi_thread.h:106
void(* set_thread_start_time_v1_t)(time_t start_time)
Assign a start time to the instrumented thread.
Definition: psi_thread_bits.h:226
notify_session_disconnect_v1_t notify_session_disconnect
Definition: psi_thread.h:154
const string version("\ersion\)
delete_thread_v1_t delete_thread
Definition: psi_thread.h:136
set_thread_start_time_v1_t set_thread_start_time
Definition: psi_thread.h:122
int(* get_thread_system_attrs_v3_t)(PSI_thread_attrs_v3 *thread_attrs)
Get system attributes for the current thread.
Definition: psi_thread_bits.h:407
void(* set_connection_type_v1_t)(opaque_vio_type conn_type)
Assign a connection type to the instrumented thread.
Definition: psi_thread_bits.h:220
int(* set_thread_resource_group_by_id_v1_t)(PSI_thread *thread, unsigned long long thread_id, const char *group_name, int group_name_len, void *user_data)
Assign a resource group name to an instrumented thread, identified either by the thread instrumentati...
Definition: psi_thread_bits.h:264
register_thread_v1_t register_thread
Definition: psi_thread.h:92
void(* set_thread_id_v1_t)(struct PSI_thread *thread, unsigned long long id)
Assign an id to an instrumented thread.
Definition: psi_thread_bits.h:146
set_thread_id_v1_t set_thread_id
Definition: psi_thread.h:98
get_thread_by_id_v2_t get_thread_by_id
Definition: psi_thread.h:104
get_thread_system_attrs_v3_t get_thread_system_attrs
Definition: psi_thread.h:144
set_thread_command_v1_t set_thread_command
Definition: psi_thread.h:118
new_thread_v1_t new_thread
Definition: psi_thread.h:96
unsigned long long(* get_thread_internal_id_v2_t)(struct PSI_thread *thread)
Read the THREAD_ID of an instrumented thread.
Definition: psi_thread_bits.h:159
get_thread_v1_t get_thread
Definition: psi_thread.h:110
void(* set_thread_THD_v1_t)(struct PSI_thread *thread, THD *thd)
Assign a THD to an instrumented thread.
Definition: psi_thread_bits.h:139
get_current_thread_internal_id_v2_t get_current_thread_internal_id
Definition: psi_thread.h:100
set_thread_db_v1_t set_thread_db
Definition: psi_thread.h:116
struct PSI_thread *(* get_thread_v1_t)(void)
Get the instrumentation for the running thread.
Definition: psi_thread_bits.h:184
int(* set_thread_connect_attrs_v1_t)(const char *buffer, unsigned int length, const void *from_cs)
Stores an array of connection attributes.
Definition: psi_thread_bits.h:298
aggregate_thread_status_v2_t aggregate_thread_status
Definition: psi_thread.h:132
struct PSI_thread *(* new_thread_v1_t)(PSI_thread_key key, const void *identity, unsigned long long thread_id)
Create instrumentation for a thread.
Definition: psi_thread_bits.h:130