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