1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/* Copyright (c) 2021, 2025, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is designed to work with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have either included with
the program or referenced in the documentation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#ifndef GR_GET_SYSTEM_VARIABLE
#define GR_GET_SYSTEM_VARIABLE
#include <string>
#include "plugin/group_replication/include/thread/mysql_thread.h"
class Get_system_variable_parameters : public Mysql_thread_body_parameters {
public:
enum System_variable_service {
VAR_GTID_EXECUTED,
VAR_GTID_PURGED,
VAR_READ_ONLY,
VAR_SUPER_READ_ONLY
};
Get_system_variable_parameters(System_variable_service service)
: m_result(""), m_service(service), m_error(1){};
virtual ~Get_system_variable_parameters(){};
/**
Get value for class private member error.
@return the error value returned
@retval 0 OK
@retval !=0 Error
*/
int get_error();
/**
Set value for class private member error.
@param [in] error Set value of error
*/
void set_error(int error);
/**
Set value for class private member service.
@return System defined to run
*/
Get_system_variable_parameters::System_variable_service get_service();
// to avoid multiple copies on get and set methods we define it as public
std::string m_result{""};
private:
System_variable_service m_service{System_variable_service::VAR_GTID_EXECUTED};
// error returned by service executed
int m_error{1};
};
class Get_system_variable : Mysql_thread_body {
public:
Get_system_variable() = default;
virtual ~Get_system_variable() = default;
/**
Method to return the server gtid_executed by executing the get_variables
component service.
@param [out] gtid_executed The string where the result will be appended
@return the error value returned
@retval 0 OK
@retval !=0 Error
*/
int get_global_gtid_executed(std::string >id_executed);
/**
Method to return the server gtid_purged by executing the get_variables
component service.
@param [out] gtid_purged The string where the result will be appended
@return the error value returned
@retval 0 OK
@retval !=0 Error
*/
int get_global_gtid_purged(std::string >id_purged);
/**
Method to return the global value of read_only by executing
the get_variables component service.
@param [out] value The variable where the value will be set
@return the error value returned
@retval 0 OK
@retval !=0 Error
*/
int get_global_read_only(bool &value);
/**
Method to return the global value of super_read_only by executing
the get_variables component service.
@param [out] value The variable where the value will be set
@return the error value returned
@retval 0 OK
@retval !=0 Error
*/
int get_global_super_read_only(bool &value);
/**
Method that will be run on mysql_thread.
@param [in, out] parameters Values used by method to get service variable.
*/
void run(Mysql_thread_body_parameters *parameters);
private:
/**
Method to convert a string into a boolean.
@param [in] value The value as string.
@return the value as boolean
@retval true string value is "ON"
@retval false otherwise
*/
bool string_to_bool(const std::string &value);
/**
Method to return the server system variable specified on variable.
@param [in] variable The system variable name to be retrieved
@param [out] value The string where the result will be set
@param [in] value_max_length The maximum string value length
@return the error value returned
@retval 0 OK
@retval !=0 Error
*/
int internal_get_system_variable(std::string variable, std::string &value,
size_t value_max_length);
};
#endif // GR_GET_SYSTEM_VARIABLE
|