MySQL  8.0.22
Source Code Documentation
event_reader_macros.h
Go to the documentation of this file.
1 /* Copyright (c) 2018, 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, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 /**
24  @addtogroup Replication
25  @{
26 
27  @file event_reader_macros.h
28 
29  @brief Contains macros used by libbinlogevents deserialization.
30 */
31 
32 #ifndef EVENT_READER_MACROS_INCLUDED
33 #define EVENT_READER_MACROS_INCLUDED
34 
35 namespace binary_log {
36 
37 /*
38  Macro to be sourced by all event constructors to skip trying to deserialize a
39  buffer that already found errors.
40 */
41 #define READER_TRY_INITIALIZATION \
42  if (!header()->get_is_valid()) BAPI_VOID_RETURN
43 
44 /*
45  Macro to be sourced by all event constructors to skip trying to deserialize a
46  buffer once finding errors.
47 */
48 #define READER_CATCH_ERROR \
49  event_reader_footer: \
50  header()->set_is_valid(READER_CALL(has_error) == false)
51 
52 /*
53  Macro to be used to wrap calls to Event_reader functions that does not
54  return values (void) or when the returned value is not needed.
55 */
56 #define READER_CALL(func, ...) reader().func(__VA_ARGS__)
57 
58 /*
59  Same as READER_CALL, but checking if Event_reader entered error state.
60 */
61 #define READER_TRY_CALL(func, ...) \
62  READER_CALL(func, __VA_ARGS__); \
63  if (reader().get_error()) goto event_reader_footer
64 
65 /*
66  Macro to be used to wrap calls to Event_reader functions that return values.
67 */
68 #define READER_SET(var, func, ...) \
69  BAPI_PRINT("debug", ("Event_reader::SET %s", #var)); \
70  var = reader().func(__VA_ARGS__)
71 
72 /*
73  Same as READER_SET, but checking if Event_reader entered error state.
74 */
75 #define READER_TRY_SET(var, func, ...) \
76  READER_SET(var, func, __VA_ARGS__); \
77  if (reader().get_error()) goto event_reader_footer
78 
79 /*
80  Macro to be used when event deserialization find illegal values or conditions.
81 */
82 #define READER_THROW(message) \
83  { \
84  reader().set_error(message); \
85  goto event_reader_footer; \
86  }
87 
88 /*
89  Macro to assert that the cursor is in a specified position.
90 */
91 #define READER_ASSERT_POSITION(pos) BAPI_ASSERT(READER_CALL(position) == pos)
92 
93 } // end namespace binary_log
94 /**
95  @} (end of group Replication)
96 */
97 #endif /* EVENT_READER_MACROS_INCLUDED */
The namespace contains classes representing events that can occur in a replication stream...