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