MySQL
8.4.2
Source Code Documentation
mysql_status_variable_reader.h
Go to the documentation of this file.
1
/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License, version 2.0,
5
as published by the Free Software Foundation.
6
7
This program is designed to work with certain software (including
8
but not limited to OpenSSL) that is licensed under separate terms,
9
as designated in a particular file or component or in included license
10
documentation. The authors of MySQL hereby grant you an additional
11
permission to link the program and your derivative works with the
12
separately licensed software that they have either included with
13
the program or referenced in the documentation.
14
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License, version 2.0, for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24
#ifndef MYSQL_STATUS_VARIABLE_READER_H
25
#define MYSQL_STATUS_VARIABLE_READER_H
26
27
#include <
mysql/components/service.h
>
28
#include <
mysql/components/services/bits/thd.h
>
29
#include <
mysql/components/services/mysql_string.h
>
30
31
/**
32
@file
33
Read status variable values service(s)
34
*/
35
36
/**
37
@ingroup group_components_services_inventory
38
39
Service to read the value of a status variable as a string.
40
41
Used approximately as follows:
42
43
@code
44
my_h_string value = nullptr;
45
bool get_global = true; // or false
46
MYSQL_THD thd = nullptr; // use a temp thd
47
const char *name = "gizmo";
48
char buffer[1024];
49
const char *charset= "utf8mb4";
50
51
// try to get the current thd if there is one
52
if (!get_global && mysql_service_mysql_current_thread_reader->get(&thd)) {
53
// failed to get the current THD
54
*is_null = 1;
55
*error = 1;
56
return nullptr;
57
}
58
if (!mysql_service_mysql_status_variable_string->get(thd, name, get_global,
59
&str) && str && !mysql_service_mysql_string_converter->convert_to_buffer( str,
60
buffer, sizeof(buffer) - 1, charset)) {
61
mysql_service_mysql_string_factory->destroy(str);
62
// the value is in buffer
63
}
64
65
// wasn't able to get the value. do cleanup
66
if (str) mysql_service_mysql_string_factory->destroy(str);
67
@endcode
68
69
@sa mysql_status_variable_reader_imp
70
*/
71
BEGIN_SERVICE_DEFINITION
(mysql_status_variable_string)
72
73
/**
74
Gets the string value of a status variable
75
76
Will read the value of the status variable supplied, convert to a string
77
as needed and store into the out_string parameter as a @ref my_h_string.
78
79
@note No status variable values aggregation will be done from the threads
80
to the globals. Will keep the status variable lock while extracting the value.
81
82
@warning The function will return an error if you do not supply a session
83
and request the session value.
84
85
@param thd The THD to operate on or a nullptr to create a temp THD
86
@param name The name of the status variable to access. US ASCII
87
@param get_global true if the global value of the status variable is
88
required, false if the session one.
89
@param [out] out_string a place to store the value
90
@return Status of the operation
91
@retval false success
92
@retval true failure
93
94
@sa mysql_status_variable_reader_imp::get
95
*/
96
DECLARE_BOOL_METHOD
(
get
, (
MYSQL_THD
thd,
const
char
*
name
,
bool
get_global,
97
my_h_string
*out_string));
98
99
END_SERVICE_DEFINITION
(mysql_status_variable_string)
100
101
#endif
/* MYSQL_STATUS_VARIABLE_READER_H */
MYSQL_THD
#define MYSQL_THD
Definition:
backup_page_tracker.h:38
mysql_string.h
pfs_plugin_column_bigint_v1_all_empty::get
void get(PSI_field *, PSI_longlong *) noexcept
Definition:
pfs_plugin_column_bigint_v1_all_empty.cc:32
service.h
END_SERVICE_DEFINITION
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition:
service.h:91
BEGIN_SERVICE_DEFINITION
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition:
service.h:86
DECLARE_BOOL_METHOD
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition:
service.h:112
name
case opt name
Definition:
sslopt-case.h:29
my_h_string_imp
Definition:
mysql_string_service.cc:60
thd.h
include
mysql
components
services
mysql_status_variable_reader.h
Generated by
1.9.2