MySQL  8.0.18
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 */
Instrumentation helpers for mutexes.
mysql_rwlock_t * rwlock
Definition: sys_vars_shared.h:68
const string name("\ame\)
PolyLock_rwlock(mysql_rwlock_t *arg)
Definition: sys_vars_shared.h:71
~AutoRLock()
Definition: sys_vars_shared.h:103
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:515
Definition: sys_vars_shared.h:57
void rdlock()
Definition: sys_vars_shared.h:62
AutoRLock(PolyLock *l)
Definition: sys_vars_shared.h:100
AutoWLock(PolyLock *l)
Definition: sys_vars_shared.h:88
PolyLock_mutex(mysql_mutex_t *arg)
Definition: sys_vars_shared.h:61
wrapper to hide a mutex and an rwlock under a common interface
Definition: sys_vars_shared.h:49
A class representing one system variable - that is something that can be accessed as @global...
Definition: set_var.h:102
Definition: sys_vars_shared.h:67
virtual void wrlock()=0
Definition: sys_vars_shared.h:84
sys_var * intern_find_sys_var(const char *str, size_t length)
Find a user set-table variable.
Definition: set_var.cc:760
#define mysql_rwlock_unlock(T)
Definition: mysql_rwlock.h:84
void unlock()
Definition: sys_vars_shared.h:74
void wrlock()
Definition: sys_vars_shared.h:73
long long int longlong
Definition: my_inttypes.h:54
Instrumentation helpers for mysys threads.
mysql_mutex_t * mutex
Definition: sys_vars_shared.h:58
~AutoWLock()
Definition: sys_vars_shared.h:91
PolyLock * lock
Definition: sys_vars_shared.h:85
An instrumented rwlock structure.
Definition: mysql_rwlock_bits.h:50
#define mysql_rwlock_wrlock(T)
Definition: mysql_rwlock.h:64
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
virtual void unlock()=0
Definition: sys_vars_shared.h:77
void unlock()
Definition: sys_vars_shared.h:64
void rdlock()
Definition: sys_vars_shared.h:72
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:53
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:44
virtual void rdlock()=0
virtual ~PolyLock()
Definition: sys_vars_shared.h:54
PolyLock * lock
Definition: sys_vars_shared.h:97
void wrlock()
Definition: sys_vars_shared.h:63
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
Definition: sys_vars_shared.h:96
#define mysql_rwlock_rdlock(T)
Definition: mysql_rwlock.h:54
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778