MySQL 8.0.39
Source Code Documentation
service_srv_session_info.h
Go to the documentation of this file.
1#ifndef MYSQL_SERVICE_SRV_SESSION_INFO_INCLUDED
2#define MYSQL_SERVICE_SRV_SESSION_INFO_INCLUDED
3/* Copyright (c) 2015, 2024, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26/**
27 @file include/mysql/service_srv_session_info.h
28 Service providing setters and getters for some properties of a session
29*/
30
32#ifndef MYSQL_ABI_CHECK
33#include <stdint.h> /* uint16_t */
34#include "m_string.h" /* LEX_CSTRING */
35#include "my_thread.h" /* my_thread_id */
36#include "my_thread_local.h"
37#include "mysql_com.h" /* Vio for violite.h */
38#include "plugin.h" /* MYSQL_THD */
39
40enum enum_vio_type : int;
41#endif
42
43extern "C" struct srv_session_info_service_st {
45
47
49
50 uint16_t (*get_client_port)(MYSQL_SESSION session);
51 int (*set_client_port)(MYSQL_SESSION session, uint16_t port);
52
54
55 int (*killed)(MYSQL_SESSION session);
56
57 unsigned int (*session_count)();
58 unsigned int (*thread_count)(const void *plugin);
60
61#ifdef MYSQL_DYNAMIC_PLUGIN
62#define srv_session_info_get_thd(session) \
63 srv_session_info_service->get_thd((session))
64#define srv_session_info_get_session_id(sess) \
65 srv_session_info_service->get_session_id((sess))
66#define srv_session_info_get_current_db(sess) \
67 srv_session_info_service->get_current_db((sess))
68#define srv_session_info_get_client_port(sess) \
69 srv_session_info_service->get_client_port((sess))
70#define srv_session_info_set_client_port(sess, port) \
71 srv_session_info_service->set_client_port((sess), (port))
72#define srv_session_info_set_connection_type(sess, type) \
73 srv_session_info_service->set_connection_type((sess), (type))
74#define srv_session_info_killed(sess) srv_session_info_service->killed((sess))
75#define srv_session_info_session_count() \
76 srv_session_info_service->session_count()
77#define srv_session_info_thread_count(plugin) \
78 srv_session_info_service->thread_count(plugin)
79
80#else
81
82/**
83 Returns the THD of a session.
84
85 @param session Session
86
87 @returns
88 address of the THD
89*/
91
92/**
93 Returns the ID of a session.
94
95 @param session Session
96*/
98
99/**
100 Returns the current database of a session.
101
102 @note {NULL, 0} is returned case of no current database or session is NULL
103
104
105 @param session Session
106*/
108
109/**
110 Returns the client port of a session.
111
112 @note The client port in SHOW PROCESSLIST, INFORMATION_SCHEMA.PROCESSLIST.
113 This port is NOT shown in PERFORMANCE_SCHEMA.THREADS.
114
115 @param session Session
116*/
118
119/**
120 Sets the client port of a session.
121
122 @note The client port in SHOW PROCESSLIST, INFORMATION_SCHEMA.PROCESSLIST.
123 This port is NOT shown in PERFORMANCE_SCHEMA.THREADS.
124
125 @param session Session
126 @param port Port number
127
128 @return
129 0 success
130 1 failure
131*/
133
134/**
135 Sets the connection type of a session.
136
137 @see enum_vio_type
138
139 @note The type is shown in PERFORMANCE_SCHEMA.THREADS. The value is translated
140 from the enum to a string according to @see vio_type_names array
141 in vio/vio.c
142
143 @note If NO_VIO_TYPE passed as type the call will fail.
144
145 @return
146 0 success
147 1 failure
148*/
150 enum enum_vio_type type);
151
152/**
153 Returns whether the session was killed
154
155 @param session Session
156
157 @return
158 0 not killed
159 1 killed
160*/
162
163/**
164 Returns the number opened sessions in thread initialized by srv_session
165 service.
166*/
167unsigned int srv_session_info_session_count();
168
169/**
170 Returns the number opened sessions in thread initialized by srv_session
171 service.
172
173 @param plugin Pointer to the plugin structure, passed to the plugin over
174 the plugin init function.
175*/
176unsigned int srv_session_info_thread_count(const void *plugin);
177
178#endif /* MYSQL_DYNAMIC_PLUGIN */
179
180#endif /* MYSQL_SERVICE_SRV_SESSION_INFO_INCLUDED */
#define MYSQL_THD
Definition: backup_page_tracker.h:38
struct MYSQL_LEX_CSTRING LEX_CSTRING
Definition: lex_string.h:42
Defines to make different thread packages compatible.
uint32 my_thread_id
Definition: my_thread_local.h:34
Common definition between mysql server & client.
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
required string type
Definition: replication_group_member_actions.proto:34
Header file for the Server session service.
class Srv_session * MYSQL_SESSION
Definition: service_srv_session_bits.h:37
MYSQL_THD srv_session_info_get_thd(MYSQL_SESSION session)
Returns the THD of a session.
uint16_t srv_session_info_get_client_port(MYSQL_SESSION session)
Returns the client port of a session.
enum enum_vio_type int struct srv_session_info_service_st * srv_session_info_service
unsigned int srv_session_info_thread_count(const void *plugin)
Returns the number opened sessions in thread initialized by srv_session service.
Definition: srv_session_info_service.cc:144
int srv_session_info_killed(MYSQL_SESSION session)
Returns whether the session was killed.
unsigned int srv_session_info_session_count()
Returns the number opened sessions in thread initialized by srv_session service.
Definition: srv_session_info_service.cc:133
int srv_session_info_set_client_port(MYSQL_SESSION session, uint16_t port)
Sets the client port of a session.
LEX_CSTRING srv_session_info_get_current_db(MYSQL_SESSION session)
Returns the current database of a session.
int srv_session_info_set_connection_type(MYSQL_SESSION session, enum enum_vio_type type)
Sets the connection type of a session.
my_thread_id srv_session_info_get_session_id(MYSQL_SESSION session)
Returns the ID of a session.
Definition: mysql_lex_string.h:40
Definition: service_srv_session_info.h:43
int(* killed)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:55
unsigned int(* thread_count)(const void *plugin)
Definition: service_srv_session_info.h:58
unsigned int(* session_count)()
Definition: service_srv_session_info.h:57
int(* set_client_port)(MYSQL_SESSION session, uint16_t port)
Definition: service_srv_session_info.h:51
my_thread_id(* get_session_id)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:46
uint16_t(* get_client_port)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:50
LEX_CSTRING(* get_current_db)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:48
int(* set_connection_type)(MYSQL_SESSION session, enum enum_vio_type type)
Definition: service_srv_session_info.h:53
MYSQL_THD(* get_thd)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:44
enum_vio_type
Definition: violite.h:79