MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
replication.h
1 /* Copyright (c) 2008, 2010, 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 Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 
16 #ifndef REPLICATION_H
17 #define REPLICATION_H
18 
19 #include <mysql.h>
20 
21 typedef struct st_mysql MYSQL;
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
30 enum Trans_flags {
32  TRANS_IS_REAL_TRANS = 1
33 };
34 
38 typedef struct Trans_param {
39  uint32 server_id;
40  uint32 flags;
41 
42  /*
43  The latest binary log file name and position written by current
44  transaction, if binary log is disabled or no log event has been
45  written into binary log file by current transaction (events
46  written into transaction log cache are not counted), these two
47  member will be zero.
48  */
49  const char *log_file;
50  my_off_t log_pos;
51 } Trans_param;
52 
56 typedef struct Trans_observer {
57  uint32 len;
58 
76  int (*after_commit)(Trans_param *param);
77 
95  int (*after_rollback)(Trans_param *param);
97 
101 enum Binlog_storage_flags {
103  BINLOG_STORAGE_IS_SYNCED = 1
104 };
105 
109 typedef struct Binlog_storage_param {
110  uint32 server_id;
112 
116 typedef struct Binlog_storage_observer {
117  uint32 len;
118 
133  const char *log_file, my_off_t log_pos);
135 
139 typedef struct Binlog_transmit_param {
140  uint32 server_id;
141  uint32 flags;
143 
147 typedef struct Binlog_transmit_observer {
148  uint32 len;
149 
162  const char *log_file, my_off_t log_pos);
163 
173 
193  unsigned char *header,
194  unsigned long size,
195  unsigned long *len);
196 
210  unsigned char *packet, unsigned long len,
211  const char *log_file, my_off_t log_pos );
212 
230  const char *event_buf, unsigned long len,
231  const char *skipped_log_file, my_off_t skipped_log_pos);
232 
246 
250 enum Binlog_relay_IO_flags {
252  BINLOG_RELAY_IS_SYNCED = 1
253 };
254 
255 
259 typedef struct Binlog_relay_IO_param {
260  uint32 server_id;
261 
262  /* Master host, user and port */
263  char *host;
264  char *user;
265  unsigned int port;
266 
267  char *master_log_name;
268  my_off_t master_log_pos;
269 
270  MYSQL *mysql; /* the connection to master */
272 
276 typedef struct Binlog_relay_IO_observer {
277  uint32 len;
278 
288 
298 
312 
326  const char *packet, unsigned long len,
327  const char **event_buf, unsigned long *event_len);
328 
341  const char *event_buf, unsigned long event_len,
342  uint32 flags);
343 
354 
355 
365 int register_trans_observer(Trans_observer *observer, void *p);
366 
376 int unregister_trans_observer(Trans_observer *observer, void *p);
377 
387 int register_binlog_storage_observer(Binlog_storage_observer *observer, void *p);
388 
398 int unregister_binlog_storage_observer(Binlog_storage_observer *observer, void *p);
399 
409 int register_binlog_transmit_observer(Binlog_transmit_observer *observer, void *p);
410 
420 int unregister_binlog_transmit_observer(Binlog_transmit_observer *observer, void *p);
421 
431 int register_binlog_relay_io_observer(Binlog_relay_IO_observer *observer, void *p);
432 
442 int unregister_binlog_relay_io_observer(Binlog_relay_IO_observer *observer, void *p);
443 
464 MYSQL *rpl_connect_master(MYSQL *mysql);
465 
483 void thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond, mysql_mutex_t *mutex,
484  const PSI_stage_info *stage, PSI_stage_info *old_stage,
485  const char *src_function, const char *src_file,
486  int src_line);
487 
488 #define THD_ENTER_COND(P1, P2, P3, P4, P5) \
489  thd_enter_cond(P1, P2, P3, P4, P5, __func__, __FILE__, __LINE__)
490 
504 void thd_exit_cond(MYSQL_THD thd, const PSI_stage_info *stage,
505  const char *src_function, const char *src_file,
506  int src_line);
507 
508 #define THD_EXIT_COND(P1, P2) \
509  thd_exit_cond(P1, P2, __func__, __FILE__, __LINE__)
510 
526 int get_user_var_int(const char *name,
527  long long int *value, int *null_value);
528 
544 int get_user_var_real(const char *name,
545  double *value, int *null_value);
546 
564 int get_user_var_str(const char *name,
565  char *value, unsigned long len,
566  unsigned int precision, int *null_value);
567 
568 
569 
570 #ifdef __cplusplus
571 }
572 #endif
573 #endif /* REPLICATION_H */