MySQL 9.3.0
Source Code Documentation
get_system_variable.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2025, 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 GR_GET_SYSTEM_VARIABLE
25#define GR_GET_SYSTEM_VARIABLE
26
27#include <string>
29
31 public:
38 };
39
41 : m_result(""), m_service(service), m_error(1) {}
43
44 /**
45 Get value for class private member error.
46
47 @return the error value returned
48 @retval 0 OK
49 @retval !=0 Error
50 */
51 int get_error();
52
53 /**
54 Set value for class private member error.
55
56 @param [in] error Set value of error
57 */
58 void set_error(int error);
59
60 /**
61 Set value for class private member service.
62
63 @return System defined to run
64 */
66
67 // to avoid multiple copies on get and set methods we define it as public
68 std::string m_result{""};
69
70 private:
71 System_variable_service m_service{System_variable_service::VAR_GTID_EXECUTED};
72 // error returned by service executed
73 int m_error{1};
74};
75
77 public:
79
80 ~Get_system_variable() override = default;
81
82 /**
83 Method to return the server gtid_executed by executing the get_variables
84 component service.
85
86 @param [out] gtid_executed The string where the result will be appended
87
88 @return the error value returned
89 @retval 0 OK
90 @retval !=0 Error
91 */
92 int get_global_gtid_executed(std::string &gtid_executed);
93
94 /**
95 Method to return the server gtid_purged by executing the get_variables
96 component service.
97
98 @param [out] gtid_purged The string where the result will be appended
99
100 @return the error value returned
101 @retval 0 OK
102 @retval !=0 Error
103 */
104 int get_global_gtid_purged(std::string &gtid_purged);
105
106 /**
107 Method to return the global value of read_only by executing
108 the get_variables component service.
109
110 @param [out] value The variable where the value will be set
111
112 @return the error value returned
113 @retval 0 OK
114 @retval !=0 Error
115 */
116 int get_global_read_only(bool &value);
117
118 /**
119 Method to return the global value of super_read_only by executing
120 the get_variables component service.
121
122 @param [out] value The variable where the value will be set
123
124 @return the error value returned
125 @retval 0 OK
126 @retval !=0 Error
127 */
129
130 /**
131 Method to return the global value of
132 'group_replication_primary_failover.most_uptodate' by executing
133 the get_variables component service.
134
135 @param [out] value The variable where the value will be set
136
137 @return the error value returned
138 @retval 0 OK
139 @retval !=0 Error
140 */
141 int get_most_uptodate(bool &value);
142
143 /**
144 Method that will be run on mysql_thread.
145
146 @param [in, out] parameters Values used by method to get service variable.
147
148 */
149 void run(Mysql_thread_body_parameters *parameters) override;
150
151 private:
152 /**
153 Method to convert a string into a boolean.
154
155 @param [in] value The value as string.
156
157 @return the value as boolean
158 @retval true string value is "ON"
159 @retval false otherwise
160 */
161 bool string_to_bool(const std::string &value);
162
163 /**
164 Method to return the server system variable specified on variable.
165
166 @param [in] component The component where variable is defined
167 @param [in] variable The system variable name to be retrieved
168 @param [out] value The string where the result will be set
169 @param [in] value_max_length The maximum string value length
170
171 @return the error value returned
172 @retval 0 OK
173 @retval !=0 Error
174 */
175 int internal_get_system_variable(std::string component, std::string variable,
176 std::string &value, size_t value_max_length);
177};
178
179#endif // GR_GET_SYSTEM_VARIABLE
Definition: get_system_variable.h:30
int m_error
Definition: get_system_variable.h:73
std::string m_result
Definition: get_system_variable.h:68
Get_system_variable_parameters::System_variable_service get_service()
Set value for class private member service.
Definition: get_system_variable.cc:36
virtual ~Get_system_variable_parameters()
Definition: get_system_variable.h:42
System_variable_service
Definition: get_system_variable.h:32
@ VAR_MOST_UPTODATE
Definition: get_system_variable.h:37
@ VAR_READ_ONLY
Definition: get_system_variable.h:35
@ VAR_GTID_EXECUTED
Definition: get_system_variable.h:33
@ VAR_GTID_PURGED
Definition: get_system_variable.h:34
@ VAR_SUPER_READ_ONLY
Definition: get_system_variable.h:36
Get_system_variable_parameters(System_variable_service service)
Definition: get_system_variable.h:40
void set_error(int error)
Set value for class private member error.
Definition: get_system_variable.cc:33
System_variable_service m_service
Definition: get_system_variable.h:71
int get_error()
Get value for class private member error.
Definition: get_system_variable.cc:31
Definition: get_system_variable.h:76
Get_system_variable()=default
int get_most_uptodate(bool &value)
Method to return the global value of 'group_replication_primary_failover.most_uptodate' by executing ...
Definition: get_system_variable.cc:128
int internal_get_system_variable(std::string component, std::string variable, std::string &value, size_t value_max_length)
Method to return the server system variable specified on variable.
Definition: get_system_variable.cc:193
~Get_system_variable() override=default
int get_global_gtid_purged(std::string &gtid_purged)
Method to return the server gtid_purged by executing the get_variables component service.
Definition: get_system_variable.cc:62
int get_global_read_only(bool &value)
Method to return the global value of read_only by executing the get_variables component service.
Definition: get_system_variable.cc:84
void run(Mysql_thread_body_parameters *parameters) override
Method that will be run on mysql_thread.
Definition: get_system_variable.cc:158
int get_global_super_read_only(bool &value)
Method to return the global value of super_read_only by executing the get_variables component service...
Definition: get_system_variable.cc:106
int get_global_gtid_executed(std::string &gtid_executed)
Method to return the server gtid_executed by executing the get_variables component service.
Definition: get_system_variable.cc:40
bool string_to_bool(const std::string &value)
Method to convert a string into a boolean.
Definition: get_system_variable.cc:150
Interface for Mysql_thread_body parameters.
Definition: mysql_thread.h:39
Interface for Mysql_thread_body, the task of a Mysql_thread.
Definition: mysql_thread.h:108
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
Gtid_set * gtid_purged
Definition: sys_vars.cc:6584