MySQL  8.0.19
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, 2018, Oracle and/or its affiliates. All rights reserved.
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 
35 #include "mysql/psi/mysql_mutex.h"
36 #include "mysql/psi/mysql_thread.h" // mysql_mutex_t
37 #include "sql/sql_table.h"
38 
39 class THD;
40 class sys_var;
41 
42 extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed,
43  bool is_unsigned, longlong v);
44 extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed,
45  double v);
46 extern sys_var *intern_find_sys_var(const char *str, size_t length);
47 
48 /** wrapper to hide a mutex and an rwlock under a common interface */
49 class PolyLock {
50  public:
51  virtual void rdlock() = 0;
52  virtual void wrlock() = 0;
53  virtual void unlock() = 0;
54  virtual ~PolyLock() {}
55 };
56 
57 class PolyLock_mutex : public PolyLock {
59 
60  public:
65 };
66 
67 class PolyLock_rwlock : public PolyLock {
69 
70  public:
75 };
76 
77 class PolyLock_lock_log : public PolyLock {
78  public:
79  void rdlock();
80  void wrlock();
81  void unlock();
82 };
83 
84 class AutoWLock {
86 
87  public:
88  AutoWLock(PolyLock *l) : lock(l) {
89  if (lock) lock->wrlock();
90  }
92  if (lock) lock->unlock();
93  }
94 };
95 
96 class AutoRLock {
98 
99  public:
101  if (lock) lock->rdlock();
102  }
104  if (lock) lock->unlock();
105  }
106 };
107 
108 #endif /* SYS_VARS_SHARED_INCLUDED */
AutoRLock
Definition: sys_vars_shared.h:96
THD
Definition: sql_class.h:764
PolyLock_lock_log::unlock
void unlock()
mysql_rwlock_wrlock
#define mysql_rwlock_wrlock(T)
Definition: mysql_rwlock.h:64
mysql_mutex_lock
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:44
PolyLock_mutex::mutex
mysql_mutex_t * mutex
Definition: sys_vars_shared.h:58
AutoWLock::lock
PolyLock * lock
Definition: sys_vars_shared.h:85
PolyLock_rwlock::rdlock
void rdlock()
Definition: sys_vars_shared.h:72
AutoWLock::~AutoWLock
~AutoWLock()
Definition: sys_vars_shared.h:91
mysql_rwlock_t
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:50
AutoRLock::AutoRLock
AutoRLock(PolyLock *l)
Definition: sys_vars_shared.h:100
PolyLock_mutex::rdlock
void rdlock()
Definition: sys_vars_shared.h:62
mysql_mutex_t
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
longlong
long long int longlong
Definition: my_inttypes.h:54
PolyLock_mutex
Definition: sys_vars_shared.h:57
AutoRLock::lock
PolyLock * lock
Definition: sys_vars_shared.h:97
mysql_rwlock_rdlock
#define mysql_rwlock_rdlock(T)
Definition: mysql_rwlock.h:54
PolyLock_rwlock::unlock
void unlock()
Definition: sys_vars_shared.h:74
mysql_thread.h
throw_bounds_warning
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:481
PolyLock_mutex::wrlock
void wrlock()
Definition: sys_vars_shared.h:63
AutoWLock
Definition: sys_vars_shared.h:84
PolyLock::wrlock
virtual void wrlock()=0
AutoRLock::~AutoRLock
~AutoRLock()
Definition: sys_vars_shared.h:103
PolyLock_lock_log::wrlock
void wrlock()
PolyLock::~PolyLock
virtual ~PolyLock()
Definition: sys_vars_shared.h:54
sql_table.h
mysql_mutex_unlock
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:53
PolyLock_lock_log
Definition: sys_vars_shared.h:77
PolyLock_rwlock::PolyLock_rwlock
PolyLock_rwlock(mysql_rwlock_t *arg)
Definition: sys_vars_shared.h:71
mysql_rwlock_unlock
#define mysql_rwlock_unlock(T)
Definition: mysql_rwlock.h:84
PolyLock_mutex::PolyLock_mutex
PolyLock_mutex(mysql_mutex_t *arg)
Definition: sys_vars_shared.h:61
PolyLock_lock_log::rdlock
void rdlock()
name
const string name("\"Name\"")
intern_find_sys_var
sys_var * intern_find_sys_var(const char *str, size_t length)
Find a user set-table variable.
Definition: set_var.cc:726
PolyLock::rdlock
virtual void rdlock()=0
PolyLock_mutex::unlock
void unlock()
Definition: sys_vars_shared.h:64
AutoWLock::AutoWLock
AutoWLock(PolyLock *l)
Definition: sys_vars_shared.h:88
gis::length
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
PolyLock
wrapper to hide a mutex and an rwlock under a common interface
Definition: sys_vars_shared.h:49
PolyLock_rwlock
Definition: sys_vars_shared.h:67
mysql_mutex.h
PolyLock_rwlock::rwlock
mysql_rwlock_t * rwlock
Definition: sys_vars_shared.h:68
sys_var
A class representing one system variable - that is something that can be accessed as @global....
Definition: set_var.h:102
PolyLock::unlock
virtual void unlock()=0
PolyLock_rwlock::wrlock
void wrlock()
Definition: sys_vars_shared.h:73