MySQL 26.10.0
Source Code Documentation
mrs_component_system_vars.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MRS_COMPONENT_SYSTEM_VARS_H
27#define MRS_COMPONENT_SYSTEM_VARS_H
28
29#include <cstdint>
30#include <mutex>
31#include <string>
32
34
35namespace mrs_component {
36
37// Common sysvar layout
38struct SysvarBase {
39 SysvarBase() = default;
40
41 const char *name = nullptr;
42 const char *desc = nullptr;
43 int type = 0;
44 void *val_ptr = nullptr;
45 bool registered = false;
46
49};
50
51template <typename T>
52struct Sysvar : public SysvarBase {
53 Sysvar() { val_ptr = reinterpret_cast<void *>(&val); }
54 T val{};
55 T min{};
56 T max{};
57 T def{};
58};
59
60// Different types of sysvars
64
65/**
66 Owns and manages system variables exposed by the MRS component.
67*/
69 public:
71 uint64_t http_port;
72 std::string ssl_cert;
73 std::string ssl_key;
74 std::string ssl_cipher;
75 unsigned long io_worker_threads;
76 };
77
78 SystemVars() = default;
79 ~SystemVars() = default;
80 SystemVars(const SystemVars &) = delete;
81 SystemVars &operator=(const SystemVars &) = delete;
82 SystemVars(SystemVars &&) = delete;
84
85 int initialize_all();
86 int register_all();
87 int unregister_all();
88 int register_system_var(SysvarBase &sysvar, void *args) const;
89 int unregister_system_var(SysvarBase &sysvar) const;
90
91 [[nodiscard]] ConfiguredValues get_configured_values() const;
92 void apply_http_limits();
93
94 private:
95 static int check_http_port(MYSQL_THD, SYS_VAR *, void *new_value,
96 struct st_mysql_value *value);
97 static int check_io_worker_threads(MYSQL_THD, SYS_VAR *, void *new_value,
98 struct st_mysql_value *value);
99 static int check_http_max_connections(MYSQL_THD, SYS_VAR *, void *new_value,
100 struct st_mysql_value *value);
101 static int check_http_body_size(MYSQL_THD, SYS_VAR *, void *new_value,
102 struct st_mysql_value *value);
103 static int check_str_var(MYSQL_THD, SYS_VAR *var, void *new_value,
104 struct st_mysql_value *value);
105 static void update_ulong_var(MYSQL_THD, SYS_VAR *, void *val_ptr,
106 const void *checked);
107 static void update_ullong_var(MYSQL_THD, SYS_VAR *, void *val_ptr,
108 const void *checked);
109 static void update_string_var(MYSQL_THD, SYS_VAR *, void *val_ptr,
110 const void *checked);
111 static void update_http_max_connections(MYSQL_THD, SYS_VAR *, void *val_ptr,
112 const void *checked);
114 void *val_ptr,
115 const void *checked);
117 void *val_ptr,
118 const void *checked);
119
120 const char *m_sysvar_prefix{"mysql_rest_service"};
121
122 mutable std::mutex m_values_mutex;
123 sv_ulonglong m_http_port_sysvar; // mysql_rest_service.http_port;
124 sv_char m_ssl_cert_sysvar; // mysql_rest_service.ssl_cert;
125 sv_char m_ssl_key_sysvar; // mysql_rest_service.ssl_key;
126 sv_char m_ssl_cipher_sysvar; // mysql_rest_service.ssl_cipher;
127 sv_ulong m_io_worker_threads_sysvar; // mysql_rest_service.io_worker_threads;
131};
132
133} // namespace mrs_component
134
135#endif // MRS_COMPONENT_SYSTEM_VARS_H
#define MYSQL_THD
Definition: backup_page_tracker.h:38
Owns and manages system variables exposed by the MRS component.
Definition: mrs_component_system_vars.h:68
static void update_ulong_var(MYSQL_THD, SYS_VAR *, void *val_ptr, const void *checked)
Definition: mrs_component_system_vars.cc:482
static int check_http_port(MYSQL_THD, SYS_VAR *, void *new_value, struct st_mysql_value *value)
Check for a valid http port value.
Definition: mrs_component_system_vars.cc:390
sv_char m_ssl_cert_sysvar
Definition: mrs_component_system_vars.h:124
static void update_string_var(MYSQL_THD, SYS_VAR *, void *val_ptr, const void *checked)
Update a string system variable.
Definition: mrs_component_system_vars.cc:506
ConfiguredValues get_configured_values() const
Definition: mrs_component_system_vars.cc:286
static int check_io_worker_threads(MYSQL_THD, SYS_VAR *, void *new_value, struct st_mysql_value *value)
Definition: mrs_component_system_vars.cc:413
static void update_http_max_response_body_size(MYSQL_THD, SYS_VAR *, void *val_ptr, const void *checked)
Definition: mrs_component_system_vars.cc:538
std::mutex m_values_mutex
Definition: mrs_component_system_vars.h:122
static void update_http_max_connections(MYSQL_THD, SYS_VAR *, void *val_ptr, const void *checked)
Definition: mrs_component_system_vars.cc:515
int unregister_all()
Unregister the MySQL Rest Service Component system variables.
Definition: mrs_component_system_vars.cc:272
static int check_str_var(MYSQL_THD, SYS_VAR *var, void *new_value, struct st_mysql_value *value)
Definition: mrs_component_system_vars.cc:365
static int check_http_body_size(MYSQL_THD, SYS_VAR *, void *new_value, struct st_mysql_value *value)
Definition: mrs_component_system_vars.cc:460
static void update_ullong_var(MYSQL_THD, SYS_VAR *, void *val_ptr, const void *checked)
Update an unsigned long long system variable.
Definition: mrs_component_system_vars.cc:494
sv_char m_ssl_cipher_sysvar
Definition: mrs_component_system_vars.h:126
sv_ulonglong m_http_max_response_body_size_sysvar
Definition: mrs_component_system_vars.h:130
int register_system_var(SysvarBase &sysvar, void *args) const
Register one system variable.
Definition: mrs_component_system_vars.cc:322
int register_all()
Register the MySQL Rest Service Component system variables with the server and set the current values...
Definition: mrs_component_system_vars.cc:185
sv_ulong m_io_worker_threads_sysvar
Definition: mrs_component_system_vars.h:127
const char * m_sysvar_prefix
Definition: mrs_component_system_vars.h:120
sv_ulonglong m_http_port_sysvar
Definition: mrs_component_system_vars.h:123
int unregister_system_var(SysvarBase &sysvar) const
Unregister one system variable.
Definition: mrs_component_system_vars.cc:341
static void update_http_max_request_body_size(MYSQL_THD, SYS_VAR *, void *val_ptr, const void *checked)
Definition: mrs_component_system_vars.cc:526
SystemVars(const SystemVars &)=delete
void apply_http_limits()
Definition: mrs_component_system_vars.cc:303
SystemVars & operator=(SystemVars &&)=delete
sv_ulonglong m_http_max_request_body_size_sysvar
Definition: mrs_component_system_vars.h:129
static int check_http_max_connections(MYSQL_THD, SYS_VAR *, void *new_value, struct st_mysql_value *value)
Definition: mrs_component_system_vars.cc:436
sv_ulong m_http_max_connections_sysvar
Definition: mrs_component_system_vars.h:128
SystemVars & operator=(const SystemVars &)=delete
sv_char m_ssl_key_sysvar
Definition: mrs_component_system_vars.h:125
SystemVars(SystemVars &&)=delete
int initialize_all()
Initialize the MySQL Rest Service Component system variables.
Definition: mrs_component_system_vars.cc:92
int(* mysql_sys_var_check_func)(MYSQL_THD thd, SYS_VAR *var, void *save, struct st_mysql_value *value)
Signature for the check function.
Definition: component_sys_var_service.h:78
void(* mysql_sys_var_update_func)(MYSQL_THD thd, SYS_VAR *var, void *val_ptr, const void *save)
Signature for the update function.
Definition: component_sys_var_service.h:106
#define T
Definition: jit_executor_value.cc:373
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
Definition: mrs_component.cc:137
Definition: system_variables_bits.h:153
Definition: mrs_component_system_vars.h:70
unsigned long io_worker_threads
Definition: mrs_component_system_vars.h:75
std::string ssl_key
Definition: mrs_component_system_vars.h:73
std::string ssl_cipher
Definition: mrs_component_system_vars.h:74
uint64_t http_port
Definition: mrs_component_system_vars.h:71
std::string ssl_cert
Definition: mrs_component_system_vars.h:72
Definition: mrs_component_system_vars.h:38
int type
Definition: mrs_component_system_vars.h:43
bool registered
Definition: mrs_component_system_vars.h:45
mysql_sys_var_check_func check_func
Definition: mrs_component_system_vars.h:47
const char * name
Definition: mrs_component_system_vars.h:41
void * val_ptr
Definition: mrs_component_system_vars.h:44
mysql_sys_var_update_func update_func
Definition: mrs_component_system_vars.h:48
const char * desc
Definition: mrs_component_system_vars.h:42
Definition: mrs_component_system_vars.h:52
T def
Definition: mrs_component_system_vars.h:57
T min
Definition: mrs_component_system_vars.h:55
T max
Definition: mrs_component_system_vars.h:56
Sysvar()
Definition: mrs_component_system_vars.h:53
T val
Definition: mrs_component_system_vars.h:54
Definition: system_variables_bits.h:96