MySQL 8.0.40
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 */
48 const std::string &value,
49 const std::string &type)
50 : m_value(value), m_type(type), m_variable(variable), m_error(1){};
52
53 /**
54 Get value for class private member error.
55
56 @return the error value returned
57 @retval 0 OK
58 @retval !=0 Error
59 */
60 int get_error();
61
62 /**
63 Set value for class private member error.
64
65 @param [in] error Set value of error
66 */
67 void set_error(int error);
68
69 /**
70 Get value for class private member variable.
71
72 @return System defined to run
73 */
75
76 // to avoid multiple copies on get and set methods we define it as public
77 const std::string m_value{""};
78 const std::string m_type{""};
79
80 private:
81 System_variable m_variable{System_variable::VAR_READ_ONLY};
82 int m_error{1};
83};
84
86 public:
88
89 virtual ~Set_system_variable() = default;
90
91 /**
92 Method to set the global value of read_only.
93
94 @param [in] value The value to be set
95
96 @return the error value returned
97 @retval 0 OK
98 @retval !=0 Error
99 */
100 int set_global_read_only(bool value);
101
102 /**
103 Method to set the global value of super_read_only.
104
105 @param [in] value The value to be set
106
107 @return the error value returned
108 @retval 0 OK
109 @retval !=0 Error
110 */
111 int set_global_super_read_only(bool value);
112
113 /**
114 Method to set the global value of offline_mode.
115
116 @param [in] value The value to be set
117
118 @return the error value returned
119 @retval 0 OK
120 @retval !=0 Error
121 */
122 int set_global_offline_mode(bool value);
123
124 /**
125 Method to only persist the value of
126 group_replication_single_primary_mode.
127
128 @param [in] value The value to be persisted
129
130 @return the error value returned
131 @retval 0 OK
132 @retval !=0 Error
133 */
135
136 /**
137 Method to only persist the value of
138 group_replication_enforce_update_everywhere_checks
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 bool value);
148
149 /**
150 Method that will be run on mysql_thread.
151
152 @param [in, out] parameters Values used by method to get service variable.
153
154 */
155 void run(Mysql_thread_body_parameters *parameters);
156
157 private:
158 /**
159 Method to set the server system variable specified on variable.
160
161 @param [in] variable The system variable name to be set
162 @param [in] value The value to be set
163 @param [in] type GLOBAL or PERSIST_ONLY
164 @param [in] lock_wait_timeout Lock wait timeout in seconds
165
166 @return the error value returned
167 @retval 0 OK
168 @retval !=0 Error
169 */
170 int internal_set_system_variable(const std::string &variable,
171 const std::string &value,
172 const std::string &type,
173 unsigned long long lock_wait_timeout);
174};
175
176#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:77
System_variable m_variable
Definition: set_system_variable.h:81
void set_error(int error)
Set value for class private member error.
Definition: set_system_variable.cc:32
Set_system_variable_parameters(System_variable variable, const std::string &value, const std::string &type)
Set_system_variable_parameters constructor.
Definition: set_system_variable.h:47
virtual ~Set_system_variable_parameters()
Definition: set_system_variable.h:51
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:82
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_type
Definition: set_system_variable.h:78
int get_error()
Get value for class private member error.
Definition: set_system_variable.cc:30
Definition: set_system_variable.h:85
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:152
virtual ~Set_system_variable()=default
int set_global_super_read_only(bool value)
Method to set the global value of super_read_only.
Definition: set_system_variable.cc:70
void run(Mysql_thread_body_parameters *parameters)
Method that will be run on mysql_thread.
Definition: set_system_variable.cc:178
Set_system_variable()=default
int internal_set_system_variable(const std::string &variable, const std::string &value, const std::string &type, unsigned long long lock_wait_timeout)
Method to set the server system variable specified on variable.
Definition: set_system_variable.cc:228
int set_global_offline_mode(bool value)
Method to set the global value of offline_mode.
Definition: set_system_variable.cc:101
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:125
int set_global_read_only(bool value)
Method to set the global value of read_only.
Definition: set_system_variable.cc:39
System variable derived from sys_var object.
Definition: pfs_variable.h:169
required string type
Definition: replication_group_member_actions.proto:34