MySQL 9.1.0
Source Code Documentation
psi_thread_service.h
Go to the documentation of this file.
1
2/* Copyright (c) 2017, 2024, 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 designed to work 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 either included with
14the program or referenced in the documentation.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License, version 2.0, for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software
23Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25#ifndef COMPONENTS_SERVICES_PSI_THREAD_SERVICE_H
26#define COMPONENTS_SERVICES_PSI_THREAD_SERVICE_H
27
30
31/*
32 Version 1.
33 Introduced in MySQL 8.0.3
34 Deprecated in MySQL 8.0.15
35 Abandoned in MySQL 8.0.17
36 Status: Removed.
37*/
38
39/*
40 Version 2.
41 Introduced in MySQL 8.0.15
42 Abandoned in MySQL 8.0.17
43 Status: Removed.
44*/
45
46/*
47 Version 3.
48 Introduced in MySQL 8.0.17
49 Abandoned in MySQL 8.0.22
50 Status: Removed.
51*/
52
53/*
54 Version 4.
55 Introduced in MySQL 8.0.22
56 Deprecated in MySQL 8.0.25
57 Status: deprecated, use version 5 instead.
58*/
59
61/** @sa register_thread_v1_t. */
62register_thread_v1_t register_thread;
63/** @sa spawn_thread_v1_t. */
64spawn_thread_v1_t spawn_thread;
65/** @sa new_thread_v1_t. */
66new_thread_v1_t new_thread;
67/** @sa set_thread_id_v1_t. */
68set_thread_id_v1_t set_thread_id;
69/** @sa get_current_thread_internal_id_v2_t. */
70get_current_thread_internal_id_v2_t get_current_thread_internal_id;
71/** @sa get_thread_internal_id_v2_t. */
72get_thread_internal_id_v2_t get_thread_internal_id;
73/** @sa get_thread_by_id_v2_t. */
74get_thread_by_id_v2_t get_thread_by_id;
75/** @sa set_thread_THD_v1_t. */
76set_thread_THD_v1_t set_thread_THD;
77/** @sa set_thread_os_id_v1_t. */
78set_thread_os_id_v1_t set_thread_os_id;
79/** @sa get_thread_v1_t. */
80get_thread_v1_t get_thread;
81/** @sa set_thread_user_v1_t. */
82set_thread_user_v1_t set_thread_user;
83/** @sa set_thread_account_v1_t. */
85/** @sa set_thread_db_v1_t. */
86set_thread_db_v1_t set_thread_db;
87/** @sa set_thread_command_v1_t. */
88set_thread_command_v1_t set_thread_command;
89/** @sa set_connection_type_v1_t. */
90set_connection_type_v1_t set_connection_type;
91/** @sa set_thread_start_time_v1_t. */
92set_thread_start_time_v1_t set_thread_start_time;
93/** @sa set_thread_info_v1_t. */
94set_thread_info_v1_t set_thread_info;
95/** @sa set_thread_v1_t. */
96set_thread_v1_t set_thread;
97/** @sa set_thread_peer_port_v4_t. */
98set_thread_peer_port_v4_t set_thread_peer_port;
99/** @sa aggregate_thread_status_v1_t. */
101/** @sa delete_current_thread_v1_t. */
102delete_current_thread_v1_t delete_current_thread;
103/** @sa delete_thread_v1_t. */
104delete_thread_v1_t delete_thread;
105/** @sa set_thread_connect_attrs_v1_t. */
106set_thread_connect_attrs_v1_t set_thread_connect_attrs;
107/** @sa get_current_thread_event_id_v2_t. */
108get_current_thread_event_id_v2_t get_current_thread_event_id;
109/** @sa get_thread_event_id_v2_t. */
110get_thread_event_id_v2_t get_thread_event_id;
111/** @sa get_thread_system_attrs_v3_t. */
112get_thread_system_attrs_v3_t get_thread_system_attrs;
113/** @sa get_thread_system_attrs_by_id_v3_t. */
114get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id;
115/** @sa register_notification_v3_t. */
116register_notification_v3_t register_notification;
117/** @sa unregister_notification_v1_t. */
118unregister_notification_v1_t unregister_notification;
119/** @sa notify_session_connect_v1_t. */
120notify_session_connect_v1_t notify_session_connect;
121/** @sa notify_session_disconnect_v1_t. */
122notify_session_disconnect_v1_t notify_session_disconnect;
123/** @sa notify_session_change_user_v1_t. */
124notify_session_change_user_v1_t notify_session_change_user;
126
127/*
128 Version 5.
129 Introduced in MySQL 8.0.25
130 Deprecated in MySQL 8.0.28
131 Status: deprecated, use version 6 instead.
132 Changes compared to version 4:
133 - register_thread takes an expanded PSI_thread_info_v5 instrumentation,
134 which includes a new m_os_name attribute.
135 - spawn_thread takes an extra sequence number parameter
136 - new_thread takes an extra sequence number parameter
137*/
138
140/** @sa register_thread_v5_t. */
141register_thread_v5_t register_thread;
142/** @sa spawn_thread_v5_t. */
143spawn_thread_v5_t spawn_thread;
144/** @sa new_thread_v5_t. */
146/** @sa set_thread_id_v1_t. */
147set_thread_id_v1_t set_thread_id;
148/** @sa get_current_thread_internal_id_v2_t. */
149get_current_thread_internal_id_v2_t get_current_thread_internal_id;
150/** @sa get_thread_internal_id_v2_t. */
151get_thread_internal_id_v2_t get_thread_internal_id;
152/** @sa get_thread_by_id_v2_t. */
153get_thread_by_id_v2_t get_thread_by_id;
154/** @sa set_thread_THD_v1_t. */
155set_thread_THD_v1_t set_thread_THD;
156/** @sa set_thread_os_id_v1_t. */
157set_thread_os_id_v1_t set_thread_os_id;
158/** @sa get_thread_v1_t. */
160/** @sa set_thread_user_v1_t. */
161set_thread_user_v1_t set_thread_user;
162/** @sa set_thread_account_v1_t. */
164/** @sa set_thread_db_v1_t. */
165set_thread_db_v1_t set_thread_db;
166/** @sa set_thread_command_v1_t. */
167set_thread_command_v1_t set_thread_command;
168/** @sa set_connection_type_v1_t. */
169set_connection_type_v1_t set_connection_type;
170/** @sa set_thread_start_time_v1_t. */
171set_thread_start_time_v1_t set_thread_start_time;
172/** @sa set_thread_info_v1_t. */
173set_thread_info_v1_t set_thread_info;
174/** @sa set_thread_v1_t. */
176/** @sa set_thread_peer_port_v4_t. */
177set_thread_peer_port_v4_t set_thread_peer_port;
178/** @sa aggregate_thread_status_v1_t. */
180/** @sa delete_current_thread_v1_t. */
181delete_current_thread_v1_t delete_current_thread;
182/** @sa delete_thread_v1_t. */
183delete_thread_v1_t delete_thread;
184/** @sa set_thread_connect_attrs_v1_t. */
185set_thread_connect_attrs_v1_t set_thread_connect_attrs;
186/** @sa get_current_thread_event_id_v2_t. */
187get_current_thread_event_id_v2_t get_current_thread_event_id;
188/** @sa get_thread_event_id_v2_t. */
189get_thread_event_id_v2_t get_thread_event_id;
190/** @sa get_thread_system_attrs_v3_t. */
191get_thread_system_attrs_v3_t get_thread_system_attrs;
192/** @sa get_thread_system_attrs_by_id_v3_t. */
193get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id;
194/** @sa register_notification_v3_t. */
195register_notification_v3_t register_notification;
196/** @sa unregister_notification_v1_t. */
197unregister_notification_v1_t unregister_notification;
198/** @sa notify_session_connect_v1_t. */
199notify_session_connect_v1_t notify_session_connect;
200/** @sa notify_session_disconnect_v1_t. */
201notify_session_disconnect_v1_t notify_session_disconnect;
202/** @sa notify_session_change_user_v1_t. */
203notify_session_change_user_v1_t notify_session_change_user;
205
206/*
207 Version 6.
208 Introduced in MySQL 8.0.28
209 Deprecated in MySQL 8.0.33
210 Status: deprecated, use version 7 instead.
211 Changes compared to version 5:
212 - added set_thread_secondary_engine
213*/
214
216/** @sa register_thread_v5_t. */
217register_thread_v5_t register_thread;
218/** @sa spawn_thread_v5_t. */
219spawn_thread_v5_t spawn_thread;
220/** @sa new_thread_v5_t. */
222/** @sa set_thread_id_v1_t. */
223set_thread_id_v1_t set_thread_id;
224/** @sa get_current_thread_internal_id_v2_t. */
225get_current_thread_internal_id_v2_t get_current_thread_internal_id;
226/** @sa get_thread_internal_id_v2_t. */
227get_thread_internal_id_v2_t get_thread_internal_id;
228/** @sa get_thread_by_id_v2_t. */
229get_thread_by_id_v2_t get_thread_by_id;
230/** @sa set_thread_THD_v1_t. */
231set_thread_THD_v1_t set_thread_THD;
232/** @sa set_thread_os_id_v1_t. */
233set_thread_os_id_v1_t set_thread_os_id;
234/** @sa get_thread_v1_t. */
236/** @sa set_thread_user_v1_t. */
237set_thread_user_v1_t set_thread_user;
238/** @sa set_thread_account_v1_t. */
240/** @sa set_thread_db_v1_t. */
241set_thread_db_v1_t set_thread_db;
242/** @sa set_thread_command_v1_t. */
243set_thread_command_v1_t set_thread_command;
244/** @sa set_connection_type_v1_t. */
245set_connection_type_v1_t set_connection_type;
246/** @sa set_thread_start_time_v1_t. */
247set_thread_start_time_v1_t set_thread_start_time;
248/** @sa set_thread_info_v1_t. */
249set_thread_info_v1_t set_thread_info;
250/** @sa set_thread_secondary_engine_v6_t. */
251set_thread_secondary_engine_v6_t set_thread_secondary_engine;
252/** @sa set_thread_v1_t. */
254/** @sa set_thread_peer_port_v4_t. */
255set_thread_peer_port_v4_t set_thread_peer_port;
256/** @sa aggregate_thread_status_v1_t. */
258/** @sa delete_current_thread_v1_t. */
259delete_current_thread_v1_t delete_current_thread;
260/** @sa delete_thread_v1_t. */
261delete_thread_v1_t delete_thread;
262/** @sa set_thread_connect_attrs_v1_t. */
263set_thread_connect_attrs_v1_t set_thread_connect_attrs;
264/** @sa get_current_thread_event_id_v2_t. */
265get_current_thread_event_id_v2_t get_current_thread_event_id;
266/** @sa get_thread_event_id_v2_t. */
267get_thread_event_id_v2_t get_thread_event_id;
268/** @sa get_thread_system_attrs_v3_t. */
269get_thread_system_attrs_v3_t get_thread_system_attrs;
270/** @sa get_thread_system_attrs_by_id_v3_t. */
271get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id;
272/** @sa register_notification_v3_t. */
273register_notification_v3_t register_notification;
274/** @sa unregister_notification_v1_t. */
275unregister_notification_v1_t unregister_notification;
276/** @sa notify_session_connect_v1_t. */
277notify_session_connect_v1_t notify_session_connect;
278/** @sa notify_session_disconnect_v1_t. */
279notify_session_disconnect_v1_t notify_session_disconnect;
280/** @sa notify_session_change_user_v1_t. */
281notify_session_change_user_v1_t notify_session_change_user;
283
284/*
285 Version 7.
286 Introduced in MySQL 8.0.33
287 Status: active
288 Changes compared to version 6:
289 - added detect_telemetry, abort_telemetry
290*/
291
293/** @sa register_thread_v5_t. */
294register_thread_v5_t register_thread;
295/** @sa spawn_thread_v5_t. */
296spawn_thread_v5_t spawn_thread;
297/** @sa new_thread_v5_t. */
299/** @sa set_thread_id_v1_t. */
300set_thread_id_v1_t set_thread_id;
301/** @sa get_current_thread_internal_id_v2_t. */
302get_current_thread_internal_id_v2_t get_current_thread_internal_id;
303/** @sa get_thread_internal_id_v2_t. */
304get_thread_internal_id_v2_t get_thread_internal_id;
305/** @sa get_thread_by_id_v2_t. */
306get_thread_by_id_v2_t get_thread_by_id;
307/** @sa set_thread_THD_v1_t. */
308set_thread_THD_v1_t set_thread_THD;
309/** @sa set_thread_os_id_v1_t. */
310set_thread_os_id_v1_t set_thread_os_id;
311/** @sa get_thread_v1_t. */
313/** @sa set_thread_user_v1_t. */
314set_thread_user_v1_t set_thread_user;
315/** @sa set_thread_account_v1_t. */
317/** @sa set_thread_db_v1_t. */
318set_thread_db_v1_t set_thread_db;
319/** @sa set_thread_command_v1_t. */
320set_thread_command_v1_t set_thread_command;
321/** @sa set_connection_type_v1_t. */
322set_connection_type_v1_t set_connection_type;
323/** @sa set_thread_start_time_v1_t. */
324set_thread_start_time_v1_t set_thread_start_time;
325/** @sa set_thread_info_v1_t. */
326set_thread_info_v1_t set_thread_info;
327/** @sa set_thread_secondary_engine_v6_t. */
328set_thread_secondary_engine_v6_t set_thread_secondary_engine;
329/** @sa set_thread_v1_t. */
331/** @sa set_thread_peer_port_v4_t. */
332set_thread_peer_port_v4_t set_thread_peer_port;
333/** @sa aggregate_thread_status_v1_t. */
335/** @sa delete_current_thread_v1_t. */
336delete_current_thread_v1_t delete_current_thread;
337/** @sa delete_thread_v1_t. */
338delete_thread_v1_t delete_thread;
339/** @sa set_thread_connect_attrs_v1_t. */
340set_thread_connect_attrs_v1_t set_thread_connect_attrs;
341/** @sa get_current_thread_event_id_v2_t. */
342get_current_thread_event_id_v2_t get_current_thread_event_id;
343/** @sa get_thread_event_id_v2_t. */
344get_thread_event_id_v2_t get_thread_event_id;
345/** @sa get_thread_system_attrs_v3_t. */
346get_thread_system_attrs_v3_t get_thread_system_attrs;
347/** @sa get_thread_system_attrs_by_id_v3_t. */
348get_thread_system_attrs_by_id_v3_t get_thread_system_attrs_by_id;
349/** @sa register_notification_v3_t. */
350register_notification_v3_t register_notification;
351/** @sa unregister_notification_v1_t. */
352unregister_notification_v1_t unregister_notification;
353/** @sa notify_session_connect_v1_t. */
354notify_session_connect_v1_t notify_session_connect;
355/** @sa notify_session_disconnect_v1_t. */
356notify_session_disconnect_v1_t notify_session_disconnect;
357/** @sa notify_session_change_user_v1_t. */
358notify_session_change_user_v1_t notify_session_change_user;
359
363
364#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:1937
void set_thread_account(PFS_thread *thread)
Definition: pfs_instr.cc:2410
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:276
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:226
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:439
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:246
void(* set_thread_THD_v1_t)(struct PSI_thread *thread, THD *thd)
Assign a THD to an instrumented thread.
Definition: psi_thread_bits.h:256
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:292
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:263
void(* notify_session_change_user_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a change user event.
Definition: psi_thread_bits.h:594
void(* set_thread_start_time_v1_t)(time_t start_time)
Assign a start time to the instrumented thread.
Definition: psi_thread_bits.h:343
void(* notify_session_disconnect_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a session disconnect event.
Definition: psi_thread_bits.h:587
void(* set_thread_command_v1_t)(int command)
Assign a current command to the instrumented thread.
Definition: psi_thread_bits.h:331
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:230
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:356
void(* delete_current_thread_v1_t)(void)
Delete the current thread instrumentation.
Definition: psi_thread_bits.h:415
void(* set_thread_secondary_engine_v6_t)(bool secondary)
Set a thread EXECUTION_ENGINE attribute.
Definition: psi_thread_bits.h:362
void(* register_thread_v1_t)(const char *category, struct PSI_thread_info_v1 *info, int count)
Thread registration API.
Definition: psi_thread_bits.h:203
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:317
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:563
void(* notify_session_connect_v1_t)(PSI_thread *thread)
Invoke the callback function registered for a session connect event.
Definition: psi_thread_bits.h:580
struct PSI_thread *(* get_thread_v1_t)(void)
Get the instrumentation for the running thread.
Definition: psi_thread_bits.h:301
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:308
void(* register_thread_v5_t)(const char *category, struct PSI_thread_info_v5 *info, int count)
Thread registration API.
Definition: psi_thread_bits.h:213
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:242
void(* aggregate_thread_status_v2_t)(struct PSI_thread *thread)
Aggregate the thread status variables.
Definition: psi_thread_bits.h:412
int(* unregister_notification_v1_t)(int handle)
Unregister callback functions for the Notification service.
Definition: psi_thread_bits.h:573
void(* delete_thread_v1_t)(struct PSI_thread *thread)
Delete a thread instrumentation.
Definition: psi_thread_bits.h:418
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:325
void(* set_thread_v1_t)(struct PSI_thread *thread)
Attach a thread instrumentation to the running thread.
Definition: psi_thread_bits.h:400
unsigned long long(* get_current_thread_internal_id_v2_t)()
Read the THREAD_ID of the current thread.
Definition: psi_thread_bits.h:269
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:539
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:408
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:430
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:550
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:284
void(* thread_abort_telemetry_v7_t)(PSI_thread *thread)
Definition: psi_thread_bits.h:600
void(* set_connection_type_v1_t)(opaque_vio_type conn_type)
Assign a connection type to the instrumented thread.
Definition: psi_thread_bits.h:337
void(* thread_detect_telemetry_v7_t)(PSI_thread *thread)
Definition: psi_thread_bits.h:598
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:457
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:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86