MySQL 8.0.29
Source Code Documentation
psi_thread_service.h
Go to the documentation of this file.
1
2/* Copyright (c) 2017, 2022, Oracle and/or its affiliates.
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License, version 2.0,
6as published by the Free Software Foundation.
7
8This program is also distributed with certain software (including
9but not limited to OpenSSL) that is licensed under separate terms,
10as designated in a particular file or component or in included license
11documentation. The authors of MySQL hereby grant you an additional
12permission to link the program and your derivative works with the
13separately licensed software that they have included with MySQL.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef COMPONENTS_SERVICES_PSI_THREAD_SERVICE_H
25#define COMPONENTS_SERVICES_PSI_THREAD_SERVICE_H
26
29
30/*
31 Version 1.
32 Introduced in MySQL 8.0.3
33 Deprecated in MySQL 8.0.15
34 Abandoned in MySQL 8.0.17
35 Status: Removed.
36*/
37
38/*
39 Version 2.
40 Introduced in MySQL 8.0.15
41 Abandoned in MySQL 8.0.17
42 Status: Removed.
43*/
44
45/*
46 Version 3.
47 Introduced in MySQL 8.0.17
48 Abandoned in MySQL 8.0.22
49 Status: Removed.
50*/
51
52/*
53 Version 4.
54 Introduced in MySQL 8.0.22
55 Deprecated in MySQL 8.0.25
56 Status: deprecated, use version 5 instead.
57*/
58
60/** @sa register_thread_v1_t. */
61register_thread_v1_t register_thread;
62/** @sa spawn_thread_v1_t. */
63spawn_thread_v1_t spawn_thread;
64/** @sa new_thread_v1_t. */
65new_thread_v1_t new_thread;
66/** @sa set_thread_id_v1_t. */
67set_thread_id_v1_t set_thread_id;
68/** @sa get_current_thread_internal_id_v2_t. */
69get_current_thread_internal_id_v2_t get_current_thread_internal_id;
70/** @sa get_thread_internal_id_v2_t. */
71get_thread_internal_id_v2_t get_thread_internal_id;
72/** @sa get_thread_by_id_v2_t. */
73get_thread_by_id_v2_t get_thread_by_id;
74/** @sa set_thread_THD_v1_t. */
75set_thread_THD_v1_t set_thread_THD;
76/** @sa set_thread_os_id_v1_t. */
77set_thread_os_id_v1_t set_thread_os_id;
78/** @sa get_thread_v1_t. */
79get_thread_v1_t get_thread;
80/** @sa set_thread_user_v1_t. */
81set_thread_user_v1_t set_thread_user;
82/** @sa set_thread_account_v1_t. */
84/** @sa set_thread_db_v1_t. */
85set_thread_db_v1_t set_thread_db;
86/** @sa set_thread_command_v1_t. */
87set_thread_command_v1_t set_thread_command;
88/** @sa set_connection_type_v1_t. */
89set_connection_type_v1_t set_connection_type;
90/** @sa set_thread_start_time_v1_t. */
91set_thread_start_time_v1_t set_thread_start_time;
92/** @sa set_thread_info_v1_t. */
93set_thread_info_v1_t set_thread_info;
94/** @sa set_thread_v1_t. */
95set_thread_v1_t set_thread;
96/** @sa set_thread_peer_port_v4_t. */
97set_thread_peer_port_v4_t set_thread_peer_port;
98/** @sa aggregate_thread_status_v1_t. */
100/** @sa delete_current_thread_v1_t. */
101delete_current_thread_v1_t delete_current_thread;
102/** @sa delete_thread_v1_t. */
103delete_thread_v1_t delete_thread;
104/** @sa set_thread_connect_attrs_v1_t. */
105set_thread_connect_attrs_v1_t set_thread_connect_attrs;
106/** @sa get_current_thread_event_id_v2_t. */
107get_current_thread_event_id_v2_t get_current_thread_event_id;
108/** @sa get_thread_event_id_v2_t. */
109get_thread_event_id_v2_t get_thread_event_id;
110/** @sa get_thread_system_attrs_v3_t. */
111get_thread_system_attrs_v3_t get_thread_system_attrs;
112/** @sa get_thread_system_attrs_by_id_v3_t. */
113get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id;
114/** @sa register_notification_v3_t. */
115register_notification_v3_t register_notification;
116/** @sa unregister_notification_v1_t. */
117unregister_notification_v1_t unregister_notification;
118/** @sa notify_session_connect_v1_t. */
119notify_session_connect_v1_t notify_session_connect;
120/** @sa notify_session_disconnect_v1_t. */
121notify_session_disconnect_v1_t notify_session_disconnect;
122/** @sa notify_session_change_user_v1_t. */
123notify_session_change_user_v1_t notify_session_change_user;
125
126/*
127 Version 5.
128 Introduced in MySQL 8.0.25
129 Deprecated in MySQL 8.0.28
130 Status: deprecated, use version 6 instead.
131 Changes compared to version 4:
132 - register_thread takes an expanded PSI_thread_info_v5 instrumentation,
133 which includes a new m_os_name attribute.
134 - spawn_thread takes an extra sequence number parameter
135 - new_thread takes an extra sequence number parameter
136*/
137
139/** @sa register_thread_v5_t. */
140register_thread_v5_t register_thread;
141/** @sa spawn_thread_v5_t. */
142spawn_thread_v5_t spawn_thread;
143/** @sa new_thread_v5_t. */
145/** @sa set_thread_id_v1_t. */
146set_thread_id_v1_t set_thread_id;
147/** @sa get_current_thread_internal_id_v2_t. */
148get_current_thread_internal_id_v2_t get_current_thread_internal_id;
149/** @sa get_thread_internal_id_v2_t. */
150get_thread_internal_id_v2_t get_thread_internal_id;
151/** @sa get_thread_by_id_v2_t. */
152get_thread_by_id_v2_t get_thread_by_id;
153/** @sa set_thread_THD_v1_t. */
154set_thread_THD_v1_t set_thread_THD;
155/** @sa set_thread_os_id_v1_t. */
156set_thread_os_id_v1_t set_thread_os_id;
157/** @sa get_thread_v1_t. */
159/** @sa set_thread_user_v1_t. */
160set_thread_user_v1_t set_thread_user;
161/** @sa set_thread_account_v1_t. */
163/** @sa set_thread_db_v1_t. */
164set_thread_db_v1_t set_thread_db;
165/** @sa set_thread_command_v1_t. */
166set_thread_command_v1_t set_thread_command;
167/** @sa set_connection_type_v1_t. */
168set_connection_type_v1_t set_connection_type;
169/** @sa set_thread_start_time_v1_t. */
170set_thread_start_time_v1_t set_thread_start_time;
171/** @sa set_thread_info_v1_t. */
172set_thread_info_v1_t set_thread_info;
173/** @sa set_thread_v1_t. */
175/** @sa set_thread_peer_port_v4_t. */
176set_thread_peer_port_v4_t set_thread_peer_port;
177/** @sa aggregate_thread_status_v1_t. */
179/** @sa delete_current_thread_v1_t. */
180delete_current_thread_v1_t delete_current_thread;
181/** @sa delete_thread_v1_t. */
182delete_thread_v1_t delete_thread;
183/** @sa set_thread_connect_attrs_v1_t. */
184set_thread_connect_attrs_v1_t set_thread_connect_attrs;
185/** @sa get_current_thread_event_id_v2_t. */
186get_current_thread_event_id_v2_t get_current_thread_event_id;
187/** @sa get_thread_event_id_v2_t. */
188get_thread_event_id_v2_t get_thread_event_id;
189/** @sa get_thread_system_attrs_v3_t. */
190get_thread_system_attrs_v3_t get_thread_system_attrs;
191/** @sa get_thread_system_attrs_by_id_v3_t. */
192get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id;
193/** @sa register_notification_v3_t. */
194register_notification_v3_t register_notification;
195/** @sa unregister_notification_v1_t. */
196unregister_notification_v1_t unregister_notification;
197/** @sa notify_session_connect_v1_t. */
198notify_session_connect_v1_t notify_session_connect;
199/** @sa notify_session_disconnect_v1_t. */
200notify_session_disconnect_v1_t notify_session_disconnect;
201/** @sa notify_session_change_user_v1_t. */
202notify_session_change_user_v1_t notify_session_change_user;
204
205/*
206 Version 6.
207 Introduced in MySQL 8.0.28
208 Status: active
209 Changes compared to version 5:
210 - added set_thread_secondary_engine
211*/
212
214/** @sa register_thread_v5_t. */
215register_thread_v5_t register_thread;
216/** @sa spawn_thread_v5_t. */
217spawn_thread_v5_t spawn_thread;
218/** @sa new_thread_v5_t. */
220/** @sa set_thread_id_v1_t. */
221set_thread_id_v1_t set_thread_id;
222/** @sa get_current_thread_internal_id_v2_t. */
223get_current_thread_internal_id_v2_t get_current_thread_internal_id;
224/** @sa get_thread_internal_id_v2_t. */
225get_thread_internal_id_v2_t get_thread_internal_id;
226/** @sa get_thread_by_id_v2_t. */
227get_thread_by_id_v2_t get_thread_by_id;
228/** @sa set_thread_THD_v1_t. */
229set_thread_THD_v1_t set_thread_THD;
230/** @sa set_thread_os_id_v1_t. */
231set_thread_os_id_v1_t set_thread_os_id;
232/** @sa get_thread_v1_t. */
234/** @sa set_thread_user_v1_t. */
235set_thread_user_v1_t set_thread_user;
236/** @sa set_thread_account_v1_t. */
238/** @sa set_thread_db_v1_t. */
239set_thread_db_v1_t set_thread_db;
240/** @sa set_thread_command_v1_t. */
241set_thread_command_v1_t set_thread_command;
242/** @sa set_connection_type_v1_t. */
243set_connection_type_v1_t set_connection_type;
244/** @sa set_thread_start_time_v1_t. */
245set_thread_start_time_v1_t set_thread_start_time;
246/** @sa set_thread_info_v1_t. */
247set_thread_info_v1_t set_thread_info;
248/** @sa set_thread_secondary_engine_v6_t. */
249set_thread_secondary_engine_v6_t set_thread_secondary_engine;
250/** @sa set_thread_v1_t. */
252/** @sa set_thread_peer_port_v4_t. */
253set_thread_peer_port_v4_t set_thread_peer_port;
254/** @sa aggregate_thread_status_v1_t. */
256/** @sa delete_current_thread_v1_t. */
257delete_current_thread_v1_t delete_current_thread;
258/** @sa delete_thread_v1_t. */
259delete_thread_v1_t delete_thread;
260/** @sa set_thread_connect_attrs_v1_t. */
261set_thread_connect_attrs_v1_t set_thread_connect_attrs;
262/** @sa get_current_thread_event_id_v2_t. */
263get_current_thread_event_id_v2_t get_current_thread_event_id;
264/** @sa get_thread_event_id_v2_t. */
265get_thread_event_id_v2_t get_thread_event_id;
266/** @sa get_thread_system_attrs_v3_t. */
267get_thread_system_attrs_v3_t get_thread_system_attrs;
268/** @sa get_thread_system_attrs_by_id_v3_t. */
269get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id;
270/** @sa register_notification_v3_t. */
271register_notification_v3_t register_notification;
272/** @sa unregister_notification_v1_t. */
273unregister_notification_v1_t unregister_notification;
274/** @sa notify_session_connect_v1_t. */
275notify_session_connect_v1_t notify_session_connect;
276/** @sa notify_session_disconnect_v1_t. */
277notify_session_disconnect_v1_t notify_session_disconnect;
278/** @sa notify_session_change_user_v1_t. */
279notify_session_change_user_v1_t notify_session_change_user;
281
282#endif /* COMPONENTS_SERVICES_PSI_THREAD_SERVICE_H */
void aggregate_thread_status(PFS_thread *thread, PFS_account *safe_account, PFS_user *safe_user, PFS_host *safe_host)
Definition: pfs_instr.cc:1907
void set_thread_account(PFS_thread *thread)
Definition: pfs_instr.cc:2376
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:275
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:225
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:438
struct PSI_thread *(* new_thread_v5_t)(PSI_thread_key key, PSI_thread_seqnum seqnum, const void *identity, unsigned long long thread_id)
Definition: psi_thread_bits.h:245
void(* set_thread_THD_v1_t)(struct PSI_thread *thread, THD *thd)
Assign a THD to an instrumented thread.
Definition: psi_thread_bits.h:255
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:291
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:262
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:593
void(* set_thread_start_time_v1_t)(time_t start_time)
Assign a start time to the instrumented thread.
Definition: psi_thread_bits.h:342
void(* notify_session_disconnect_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a session disconnect event.
Definition: psi_thread_bits.h:586
void(* set_thread_command_v1_t)(int command)
Assign a current command to the instrumented thread.
Definition: psi_thread_bits.h:330
int(* spawn_thread_v5_t)(PSI_thread_key key, PSI_thread_seqnum seqnum, my_thread_handle *thread, const my_thread_attr_t *attr, void *(*start_routine)(void *), void *arg)
Definition: psi_thread_bits.h:229
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:355
void(* delete_current_thread_v1_t)(void)
Delete the current thread instrumentation.
Definition: psi_thread_bits.h:414
void(* set_thread_secondary_engine_v6_t)(bool secondary)
Set a thread EXECUTION_ENGINE attribute.
Definition: psi_thread_bits.h:361
void(* register_thread_v1_t)(const char *category, struct PSI_thread_info_v1 *info, int count)
Thread registration API.
Definition: psi_thread_bits.h:202
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:316
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:562
void(* notify_session_connect_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a session connect event.
Definition: psi_thread_bits.h:579
struct PSI_thread *(* get_thread_v1_t)(void)
Get the instrumentation for the running thread.
Definition: psi_thread_bits.h:300
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:307
void(* register_thread_v5_t)(const char *category, struct PSI_thread_info_v5 *info, int count)
Thread registration API.
Definition: psi_thread_bits.h:212
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:241
void(* aggregate_thread_status_v2_t)(struct PSI_thread *thread)
Aggregate the thread status variables.
Definition: psi_thread_bits.h:411
int(* unregister_notification_v1_t)(int handle)
Unregister callback functions for the Notification service.
Definition: psi_thread_bits.h:572
void(* delete_thread_v1_t)(struct PSI_thread *thread)
Delete a thread instrumentation.
Definition: psi_thread_bits.h:417
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:324
void(* set_thread_v1_t)(struct PSI_thread *thread)
Attach a thread instrumentation to the running thread.
Definition: psi_thread_bits.h:399
unsigned long long(* get_current_thread_internal_id_v2_t)()
Read the THREAD_ID of the current thread.
Definition: psi_thread_bits.h:268
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:538
void(* set_thread_peer_port_v4_t)(PSI_thread *thread, unsigned int port)
Assign the remote (peer) port to the instrumented thread.
Definition: psi_thread_bits.h:407
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:429
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:549
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:283
void(* set_connection_type_v1_t)(opaque_vio_type conn_type)
Assign a connection type to the instrumented thread.
Definition: psi_thread_bits.h:336
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:456
Performance schema instrumentation interface.
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:90
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:85