MySQL 8.0.33
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, 2023, 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 also distributed 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 included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26/**
27 @file
28 "protected" interface to sys_var - server configuration variables.
29
30 This header is included by files implementing support and utility
31 functions of sys_var's (set_var.cc) and files implementing
32 classes in the sys_var hierarchy (sql_plugin.cc)
33*/
34
36#include "mysql/psi/mysql_thread.h" // mysql_mutex_t
37#include "sql/sql_table.h"
38
39class THD;
40class sys_var;
41
42extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed,
43 bool is_unsigned, longlong v);
44extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed,
45 double v);
46extern sys_var *find_static_system_variable(const std::string &name);
47extern sys_var *find_dynamic_system_variable(const std::string &name);
48extern sys_var *intern_find_sys_var(const char *str, size_t length);
49
50/** wrapper to hide a mutex and an rwlock under a common interface */
51class PolyLock {
52 public:
53 virtual void rdlock() = 0;
54 virtual void wrlock() = 0;
55 virtual void unlock() = 0;
56 virtual ~PolyLock() = default;
57};
58
59class PolyLock_mutex : public PolyLock {
61
62 public:
64 void rdlock() override { mysql_mutex_lock(mutex); }
65 void wrlock() override { mysql_mutex_lock(mutex); }
66 void unlock() override { mysql_mutex_unlock(mutex); }
67};
68
69class PolyLock_rwlock : public PolyLock {
71
72 public:
74 void rdlock() override { mysql_rwlock_rdlock(rwlock); }
75 void wrlock() override { mysql_rwlock_wrlock(rwlock); }
76 void unlock() override { mysql_rwlock_unlock(rwlock); }
77};
78
80 public:
81 void rdlock() override;
82 void wrlock() override;
83 void unlock() override;
84};
85
86class AutoWLock {
88
89 public:
91 if (lock) lock->wrlock();
92 }
94 if (lock) lock->unlock();
95 }
96};
97
98class AutoRLock {
100
101 public:
103 if (lock) lock->rdlock();
104 }
106 if (lock) lock->unlock();
107 }
108};
109
110#endif /* SYS_VARS_SHARED_INCLUDED */
Definition: sys_vars_shared.h:98
~AutoRLock()
Definition: sys_vars_shared.h:105
PolyLock * lock
Definition: sys_vars_shared.h:99
AutoRLock(PolyLock *l)
Definition: sys_vars_shared.h:102
Definition: sys_vars_shared.h:86
~AutoWLock()
Definition: sys_vars_shared.h:93
AutoWLock(PolyLock *l)
Definition: sys_vars_shared.h:90
PolyLock * lock
Definition: sys_vars_shared.h:87
Definition: sys_vars_shared.h:79
void wrlock() override
void unlock() override
void rdlock() override
Definition: sys_vars_shared.h:59
PolyLock_mutex(mysql_mutex_t *arg)
Definition: sys_vars_shared.h:63
mysql_mutex_t * mutex
Definition: sys_vars_shared.h:60
void wrlock() override
Definition: sys_vars_shared.h:65
void unlock() override
Definition: sys_vars_shared.h:66
void rdlock() override
Definition: sys_vars_shared.h:64
Definition: sys_vars_shared.h:69
void rdlock() override
Definition: sys_vars_shared.h:74
mysql_rwlock_t * rwlock
Definition: sys_vars_shared.h:70
PolyLock_rwlock(mysql_rwlock_t *arg)
Definition: sys_vars_shared.h:73
void wrlock() override
Definition: sys_vars_shared.h:75
void unlock() override
Definition: sys_vars_shared.h:76
wrapper to hide a mutex and an rwlock under a common interface
Definition: sys_vars_shared.h:51
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:33
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:104
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:49
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:56
#define mysql_rwlock_rdlock(T)
Definition: mysql_rwlock.h:60
#define mysql_rwlock_unlock(T)
Definition: mysql_rwlock.h:90
#define mysql_rwlock_wrlock(T)
Definition: mysql_rwlock.h:70
Instrumentation helpers for mysys threads.
long long int longlong
Definition: my_inttypes.h:54
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1054
constexpr value_type is_unsigned
Definition: classic_protocol_constants.h:270
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:75
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
Instrumentation helpers for mutexes.
case opt name
Definition: sslopt-case.h:32
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:50
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:549
sys_var * find_static_system_variable(const std::string &name)
Find a static system variable.
Definition: set_var.cc:1307
sys_var * find_dynamic_system_variable(const std::string &name)
Find a dynamic system variable.
Definition: set_var.cc:1325
sys_var * intern_find_sys_var(const char *str, size_t length)
Find a system variable, either static or dynamic.
Definition: set_var.cc:1346