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