MySQL 9.0.0
Source Code Documentation
sys_vars_shared.h
Go to the documentation of this file.
1#ifndef SYS_VARS_SHARED_INCLUDED
2#define SYS_VARS_SHARED_INCLUDED
3
4/* Copyright (c) 2002, 2024, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27/**
28 @file
29 "protected" interface to sys_var - server configuration variables.
30
31 This header is included by files implementing support and utility
32 functions of sys_var's (set_var.cc) and files implementing
33 classes in the sys_var hierarchy (sql_plugin.cc)
34*/
35
37#include "mysql/psi/mysql_thread.h" // mysql_mutex_t
38#include "sql/sql_table.h"
39
40class THD;
41class sys_var;
42
43extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed,
44 bool is_unsigned, longlong v);
45extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed,
46 double v);
47extern sys_var *find_static_system_variable(const std::string &name);
48extern sys_var *find_dynamic_system_variable(const std::string &name);
49extern sys_var *intern_find_sys_var(const char *str, size_t length);
50
51/** wrapper to hide a mutex and an rwlock under a common interface */
52class PolyLock {
53 public:
54 virtual void rdlock() = 0;
55 virtual void wrlock() = 0;
56 virtual void unlock() = 0;
57 virtual ~PolyLock() = default;
58};
59
60class PolyLock_mutex : public PolyLock {
62
63 public:
65 void rdlock() override { mysql_mutex_lock(mutex); }
66 void wrlock() override { mysql_mutex_lock(mutex); }
67 void unlock() override { mysql_mutex_unlock(mutex); }
68};
69
70class PolyLock_rwlock : public PolyLock {
72
73 public:
75 void rdlock() override { mysql_rwlock_rdlock(rwlock); }
76 void wrlock() override { mysql_rwlock_wrlock(rwlock); }
77 void unlock() override { mysql_rwlock_unlock(rwlock); }
78};
79
81 public:
82 void rdlock() override;
83 void wrlock() override;
84 void unlock() override;
85};
86
87class AutoWLock {
89
90 public:
92 if (lock) lock->wrlock();
93 }
95 if (lock) lock->unlock();
96 }
97};
98
99class AutoRLock {
101
102 public:
104 if (lock) lock->rdlock();
105 }
107 if (lock) lock->unlock();
108 }
109};
110
111#endif /* SYS_VARS_SHARED_INCLUDED */
Definition: sys_vars_shared.h:99
~AutoRLock()
Definition: sys_vars_shared.h:106
PolyLock * lock
Definition: sys_vars_shared.h:100
AutoRLock(PolyLock *l)
Definition: sys_vars_shared.h:103
Definition: sys_vars_shared.h:87
~AutoWLock()
Definition: sys_vars_shared.h:94
AutoWLock(PolyLock *l)
Definition: sys_vars_shared.h:91
PolyLock * lock
Definition: sys_vars_shared.h:88
Definition: sys_vars_shared.h:80
void wrlock() override
void unlock() override
void rdlock() override
Definition: sys_vars_shared.h:60
PolyLock_mutex(mysql_mutex_t *arg)
Definition: sys_vars_shared.h:64
mysql_mutex_t * mutex
Definition: sys_vars_shared.h:61
void wrlock() override
Definition: sys_vars_shared.h:66
void unlock() override
Definition: sys_vars_shared.h:67
void rdlock() override
Definition: sys_vars_shared.h:65
Definition: sys_vars_shared.h:70
void rdlock() override
Definition: sys_vars_shared.h:75
mysql_rwlock_t * rwlock
Definition: sys_vars_shared.h:71
PolyLock_rwlock(mysql_rwlock_t *arg)
Definition: sys_vars_shared.h:74
void wrlock() override
Definition: sys_vars_shared.h:76
void unlock() override
Definition: sys_vars_shared.h:77
wrapper to hide a mutex and an rwlock under a common interface
Definition: sys_vars_shared.h:52
virtual void wrlock()=0
virtual ~PolyLock()=default
virtual void rdlock()=0
virtual void unlock()=0
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:107
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:50
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:57
#define mysql_rwlock_rdlock(T)
Definition: mysql_rwlock.h:61
#define mysql_rwlock_unlock(T)
Definition: mysql_rwlock.h:91
#define mysql_rwlock_wrlock(T)
Definition: mysql_rwlock.h:71
Instrumentation helpers for mysys threads.
long long int longlong
Definition: my_inttypes.h:55
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
constexpr value_type is_unsigned
Definition: classic_protocol_constants.h:273
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
Instrumentation helpers for mutexes.
case opt name
Definition: sslopt-case.h:29
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:51
bool throw_bounds_warning(THD *thd, const char *name, bool fixed, bool is_unsigned, longlong v)
Throw warning (error in STRICT mode) if value for variable needed bounding.
Definition: set_var.cc:554
sys_var * find_static_system_variable(const std::string &name)
Find a static system variable.
Definition: set_var.cc:1314
sys_var * find_dynamic_system_variable(const std::string &name)
Find a dynamic system variable.
Definition: set_var.cc:1332
sys_var * intern_find_sys_var(const char *str, size_t length)
Find a system variable, either static or dynamic.
Definition: set_var.cc:1353