MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
semisync.h
1 /* Copyright (C) 2007 Google Inc.
2  Copyright (C) 2008 MySQL AB
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 
17 
18 #ifndef SEMISYNC_H
19 #define SEMISYNC_H
20 
21 #define MYSQL_SERVER
22 #define HAVE_REPLICATION
23 #include <sql_priv.h>
24 #include "unireg.h"
25 #include <my_global.h>
26 #include <my_pthread.h>
27 #include <mysql/plugin.h>
28 #include <replication.h>
29 #include "log.h" /* sql_print_information */
30 
31 typedef struct st_mysql_show_var SHOW_VAR;
32 typedef struct st_mysql_sys_var SYS_VAR;
33 
34 
39 class Trace {
40 public:
41  static const unsigned long kTraceFunction;
42  static const unsigned long kTraceGeneral;
43  static const unsigned long kTraceDetail;
44  static const unsigned long kTraceNetWait;
45 
46  unsigned long trace_level_; /* the level for tracing */
47 
48  inline void function_enter(const char *func_name)
49  {
50  if (trace_level_ & kTraceFunction)
51  sql_print_information("---> %s enter", func_name);
52  }
53  inline int function_exit(const char *func_name, int exit_code)
54  {
55  if (trace_level_ & kTraceFunction)
56  sql_print_information("<--- %s exit (%d)", func_name, exit_code);
57  return exit_code;
58  }
59 
60  Trace()
61  :trace_level_(0L)
62  {}
63  Trace(unsigned long trace_level)
64  :trace_level_(trace_level)
65  {}
66 };
67 
72  :public Trace {
73 public:
74  static const unsigned char kSyncHeader[2]; /* three byte packet header */
75 
76  /* Constants in network packet header. */
77  static const unsigned char kPacketMagicNum;
78  static const unsigned char kPacketFlagSync;
79 };
80 
81 /* The layout of a semisync slave reply packet:
82  1 byte for the magic num
83  8 bytes for the binlog positon
84  n bytes for the binlog filename, terminated with a '\0'
85 */
86 #define REPLY_MAGIC_NUM_LEN 1
87 #define REPLY_BINLOG_POS_LEN 8
88 #define REPLY_BINLOG_NAME_LEN (FN_REFLEN + 1)
89 #define REPLY_MAGIC_NUM_OFFSET 0
90 #define REPLY_BINLOG_POS_OFFSET (REPLY_MAGIC_NUM_OFFSET + REPLY_MAGIC_NUM_LEN)
91 #define REPLY_BINLOG_NAME_OFFSET (REPLY_BINLOG_POS_OFFSET + REPLY_BINLOG_POS_LEN)
92 
93 #endif /* SEMISYNC_H */