MySQL 9.1.0
Source Code Documentation
set_system_variable.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 GR_SET_SYSTEM_VARIABLE
25#define GR_SET_SYSTEM_VARIABLE
26
27#include <string>
29
31 public:
38 };
39
40 /**
41 Set_system_variable_parameters constructor.
42
43 @param [in] variable The system variable to be set
44 @param [in] value The value to be set
45 @param [in] type GLOBAL or PERSIST_ONLY
46 @param [in] reason Explains why we set OFFLINE_MODE or SUPER_READ_ONLY to
47 ON
48 */
50 const std::string &value,
51 const std::string &type,
52 const std::string &reason)
53 : m_value(value),
54 m_type(type),
55 m_variable(variable),
56 m_error(1),
57 m_reason(reason) {}
59
60 /**
61 Get value for class private member error.
62
63 @return the error value returned
64 @retval 0 OK
65 @retval !=0 Error
66 */
67 int get_error();
68
69 /**
70 Set value for class private member error.
71
72 @param [in] error Set value of error
73 */
74 void set_error(int error);
75
76 /**
77 Get value for class private member variable.
78
79 @return System defined to run
80 */
82
83 // to avoid multiple copies on get and set methods we define it as public
84 const std::string m_value{""};
85 const std::string m_type{""};
86
87 private:
88 System_variable m_variable{System_variable::VAR_READ_ONLY};
89 int m_error{1};
90
91 public:
92 const std::string m_reason{};
93};
94
96 public:
98
99 ~Set_system_variable() override = default;
100
101 /**
102 Method to set the global value of read_only.
103
104 @param [in] value The value to be set
105
106 @return the error value returned
107 @retval 0 OK
108 @retval !=0 Error
109 */
110 int set_global_read_only(bool value);
111
112 /**
113 Method to set the global value of super_read_only.
114
115 @param [in] value The value to be set
116 @param [in] reason Explains why we set the mode
117
118 @return the error value returned
119 @retval 0 OK
120 @retval !=0 Error
121 */
122 int set_global_super_read_only(bool value, const std::string &reason);
123
124 /**
125 Method to set the global value of offline_mode.
126
127 @param [in] value The value to be set
128 @param [in] reason Explains why we set the mode
129
130 @return the error value returned
131 @retval 0 OK
132 @retval !=0 Error
133 */
134 int set_global_offline_mode(bool value, const std::string &reason);
135
136 /**
137 Method to only persist the value of
138 group_replication_single_primary_mode.
139
140 @param [in] value The value to be persisted
141
142 @return the error value returned
143 @retval 0 OK
144 @retval !=0 Error
145 */
147
148 /**
149 Method to only persist the value of
150 group_replication_enforce_update_everywhere_checks
151
152 @param [in] value The value to be persisted
153
154 @return the error value returned
155 @retval 0 OK
156 @retval !=0 Error
157 */
159 bool value);
160
161 /**
162 Method that will be run on mysql_thread.
163
164 @param [in, out] parameters Values used by method to get service variable.
165
166 */
167 void run(Mysql_thread_body_parameters *parameters) override;
168
169 private:
170 /**
171 Method to set the server system variable specified on variable.
172
173 @param [in] variable The system variable name to be set
174 @param [in] value The value to be set
175 @param [in] type GLOBAL or PERSIST_ONLY
176 @param [in] lock_wait_timeout Lock wait timeout in seconds
177 @param [in] reason Explains why we set the mode
178
179 @return the error value returned
180 @retval 0 OK
181 @retval !=0 Error
182 */
183 int internal_set_system_variable(const std::string &variable,
184 const std::string &value,
185 const std::string &type,
186 unsigned long long lock_wait_timeout,
187 const std::string &reason);
188};
189
190#endif // GR_SET_SYSTEM_VARIABLE
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
Definition: set_system_variable.h:30
const std::string m_value
Definition: set_system_variable.h:84
System_variable m_variable
Definition: set_system_variable.h:88
void set_error(int error)
Set value for class private member error.
Definition: set_system_variable.cc:32
virtual ~Set_system_variable_parameters()
Definition: set_system_variable.h:58
System_variable
Definition: set_system_variable.h:32
@ VAR_SUPER_READ_ONLY
Definition: set_system_variable.h:34
@ VAR_GROUP_REPLICATION_SINGLE_PRIMARY_MODE
Definition: set_system_variable.h:36
@ VAR_OFFLINE_MODE
Definition: set_system_variable.h:35
@ VAR_READ_ONLY
Definition: set_system_variable.h:33
@ VAR_GROUP_REPLICATION_ENFORCE_UPDATE_EVERYWHERE_CHECKS
Definition: set_system_variable.h:37
int m_error
Definition: set_system_variable.h:89
Set_system_variable_parameters::System_variable get_variable()
Get value for class private member variable.
Definition: set_system_variable.cc:35
const std::string m_reason
Definition: set_system_variable.h:92
const std::string m_type
Definition: set_system_variable.h:85
int get_error()
Get value for class private member error.
Definition: set_system_variable.cc:30
Set_system_variable_parameters(System_variable variable, const std::string &value, const std::string &type, const std::string &reason)
Set_system_variable_parameters constructor.
Definition: set_system_variable.h:49
Definition: set_system_variable.h:95
int set_persist_only_group_replication_enforce_update_everywhere_checks(bool value)
Method to only persist the value of group_replication_enforce_update_everywhere_checks.
Definition: set_system_variable.cc:166
int set_global_super_read_only(bool value, const std::string &reason)
Method to set the global value of super_read_only.
Definition: set_system_variable.cc:70
Set_system_variable()=default
int set_global_offline_mode(bool value, const std::string &reason)
Method to set the global value of offline_mode.
Definition: set_system_variable.cc:108
int set_persist_only_group_replication_single_primary_mode(bool value)
Method to only persist the value of group_replication_single_primary_mode.
Definition: set_system_variable.cc:139
~Set_system_variable() override=default
void run(Mysql_thread_body_parameters *parameters) override
Method that will be run on mysql_thread.
Definition: set_system_variable.cc:192
int set_global_read_only(bool value)
Method to set the global value of read_only.
Definition: set_system_variable.cc:39
int internal_set_system_variable(const std::string &variable, const std::string &value, const std::string &type, unsigned long long lock_wait_timeout, const std::string &reason)
Method to set the server system variable specified on variable.
Definition: set_system_variable.cc:242
System variable derived from sys_var object.
Definition: pfs_variable.h:169
required string type
Definition: replication_group_member_actions.proto:34