MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rpl_info.h
1 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef RPL_INFO_H
17 #define RPL_INFO_H
18 
19 #include "sql_priv.h"
20 #include "sql_class.h"
21 #include "rpl_info_handler.h"
22 #include "rpl_reporting.h"
23 
25 {
26 public:
27  virtual ~Rpl_info();
28 
29  /*
30  standard lock acquisition order to avoid deadlocks:
31  run_lock, data_lock, relay_log.LOCK_log, relay_log.LOCK_index
32  run_lock, sleep_lock
33  */
34  mysql_mutex_t data_lock, run_lock, sleep_lock;
35  /*
36  start_cond is broadcast when SQL thread is started
37  stop_cond - when stopped
38  data_cond - when data protected by data_lock changes
39  sleep_cond - when killed
40  */
41  mysql_cond_t data_cond, start_cond, stop_cond, sleep_cond;
42 
43 #ifdef HAVE_PSI_INTERFACE
44  PSI_mutex_key *key_info_run_lock, *key_info_data_lock, *key_info_sleep_lock;
45 
46  PSI_mutex_key *key_info_data_cond, *key_info_start_cond, *key_info_stop_cond,
47  *key_info_sleep_cond;
48 #endif
49 
50  THD *info_thd;
51 
52  bool inited;
53  volatile bool abort_slave;
54  volatile uint slave_running;
55  volatile ulong slave_run_id;
56 
57 #ifndef DBUG_OFF
58  int events_until_exit;
59 #endif
60 
66  void set_rpl_info_handler(Rpl_info_handler * param_handler)
67  {
68  handler= param_handler;
69  }
70 
76  Rpl_info_handler *get_rpl_info_handler()
77  {
78  return (handler);
79  }
80 
81  enum_return_check check_info()
82  {
83  return (handler->check_info());
84  }
85 
86  int remove_info()
87  {
88  return (handler->remove_info());
89  }
90 
91  int clean_info()
92  {
93  return (handler->clean_info());
94  }
95 
96  bool is_transactional()
97  {
98  return (handler->is_transactional());
99  }
100 
101  bool update_is_transactional()
102  {
103  return (handler->update_is_transactional());
104  }
105 
106  char *get_description_info()
107  {
108  return (handler->get_description_info());
109  }
110 
111  bool copy_info(Rpl_info_handler *from, Rpl_info_handler *to)
112  {
113  if (read_info(from) || write_info(to))
114  return(TRUE);
115 
116  return(FALSE);
117  }
118 
119  uint get_internal_id()
120  {
121  return internal_id;
122  }
123 
124 protected:
128  Rpl_info_handler *handler;
129 
137 
138  Rpl_info(const char* type
139 #ifdef HAVE_PSI_INTERFACE
140  ,PSI_mutex_key *param_key_info_run_lock,
141  PSI_mutex_key *param_key_info_data_lock,
142  PSI_mutex_key *param_key_info_sleep_lock,
143  PSI_mutex_key *param_key_info_data_cond,
144  PSI_mutex_key *param_key_info_start_cond,
145  PSI_mutex_key *param_key_info_stop_cond,
146  PSI_mutex_key *param_key_info_sleep_cond
147 #endif
148  ,uint param_id
149  );
150 
151 private:
152  virtual bool read_info(Rpl_info_handler *from)= 0;
153  virtual bool write_info(Rpl_info_handler *to)= 0;
154 
155  Rpl_info(const Rpl_info& info);
156  Rpl_info& operator=(const Rpl_info& info);
157 };
158 #endif /* RPL_INFO_H */