MySQL  8.0.22
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, 2020, Oracle and/or its affiliates. All rights reserved.
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 "m_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 
39 enum enum_vio_type : int;
40 #endif
41 
42 extern "C" struct srv_session_info_service_st {
44 
46 
48 
51 
53 
55 
56  unsigned int (*session_count)();
57  unsigned int (*thread_count)(const void *plugin);
59 
60 #ifdef MYSQL_DYNAMIC_PLUGIN
61 
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(sess) \
76  srv_session_info_service->session_count(sess)
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 */
167 unsigned 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 */
176 unsigned int srv_session_info_thread_count(const void *plugin);
177 
178 #endif /* MYSQL_DYNAMIC_PLUGIN */
179 
180 #endif /* MYSQL_SERVICE_SRV_SESSION_INFO_INCLUDED */
uint16_t(* get_client_port)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:49
int(* set_connection_type)(MYSQL_SESSION session, enum enum_vio_type type)
Definition: service_srv_session_info.h:52
unsigned int(* session_count)()
Definition: service_srv_session_info.h:56
unsigned int(* thread_count)(const void *plugin)
Definition: service_srv_session_info.h:57
class Srv_session * MYSQL_SESSION
Definition: service_srv_session_bits.h:36
MYSQL_SESSION session[9]
Definition: test_sql_9_sessions.cc:65
int srv_session_info_set_client_port(MYSQL_SESSION session, uint16_t port)
Sets the client port of a session.
Definition: mysql_lex_string.h:39
static struct st_mysql_daemon plugin
Definition: test_services_host_application_signal.cc:130
LEX_CSTRING srv_session_info_get_current_db(MYSQL_SESSION session)
Returns the current database of a session.
#define MYSQL_THD
Definition: backup_page_tracker.h:37
Common definition between mysql server & client.
static in_port_t port
Definition: testapp.c:33
int srv_session_info_killed(MYSQL_SESSION session)
Returns whether the session was killed.
my_thread_id srv_session_info_get_session_id(MYSQL_SESSION session)
Returns the ID of a session.
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_set_connection_type(MYSQL_SESSION session, enum enum_vio_type type)
Sets the connection type of a session.
Definition: service_srv_session_info.h:42
my_thread_id(* get_session_id)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:45
enum_vio_type
Definition: violite.h:77
enum enum_vio_type int struct srv_session_info_service_st * srv_session_info_service
LEX_CSTRING(* get_current_db)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:47
Defines to make different thread packages compatible.
uint16_t srv_session_info_get_client_port(MYSQL_SESSION session)
Returns the client port of a session.
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
uint32 my_thread_id
Definition: my_thread_local.h:33
MYSQL_THD srv_session_info_get_thd(MYSQL_SESSION session)
Returns the THD of a session.
struct MYSQL_LEX_CSTRING LEX_CSTRING
Definition: lex_string.h:40
int(* set_client_port)(MYSQL_SESSION session, uint16_t port)
Definition: service_srv_session_info.h:50
int(* killed)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:54
Header file for the Server session service.
MYSQL_THD(* get_thd)(MYSQL_SESSION session)
Definition: service_srv_session_info.h:43