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