Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ set(source_files
src/binsrv/event/common_header.hpp
src/binsrv/event/common_header.cpp

src/binsrv/event/common_header_flag_type_fwd.hpp
src/binsrv/event/common_header_flag_type.hpp

src/binsrv/event/empty_body_fwd.hpp
src/binsrv/event/empty_body.hpp
src/binsrv/event/empty_body.cpp
Expand All @@ -108,9 +111,6 @@ set(source_files
src/binsrv/event/event.hpp
src/binsrv/event/event.cpp

src/binsrv/event/flag_type_fwd.hpp
src/binsrv/event/flag_type.hpp

src/binsrv/event/footer_fwd.hpp
src/binsrv/event/footer.hpp
src/binsrv/event/footer.cpp
Expand All @@ -129,6 +129,17 @@ set(source_files
src/binsrv/event/generic_post_header_fwd.hpp
src/binsrv/event/generic_post_header.hpp

src/binsrv/event/gtid_log_flag_type_fwd.hpp
src/binsrv/event/gtid_log_flag_type.hpp

src/binsrv/event/gtid_log_body_impl_fwd.hpp
src/binsrv/event/gtid_log_body_impl.hpp
src/binsrv/event/gtid_log_body_impl.cpp

src/binsrv/event/gtid_log_post_header_impl_fwd.hpp
src/binsrv/event/gtid_log_post_header_impl.hpp
src/binsrv/event/gtid_log_post_header_impl.cpp

src/binsrv/event/protocol_traits_fwd.hpp
src/binsrv/event/protocol_traits.hpp
src/binsrv/event/protocol_traits.cpp
Expand Down Expand Up @@ -159,6 +170,9 @@ set(source_files
src/binsrv/event/unknown_post_header.hpp
src/binsrv/event/unknown_post_header.cpp

# gtid data structure files
src/binsrv/gtid/common_types.hpp

# binlog files
src/binsrv/basic_logger_fwd.hpp
src/binsrv/basic_logger.hpp
Expand Down Expand Up @@ -299,9 +313,8 @@ set(source_files

add_executable(binlog_server ${source_files})
target_link_libraries(binlog_server
PUBLIC
binlog_server_compiler_flags
PRIVATE
binlog_server_compiler_flags
Boost::headers Boost::url
ZLIB::ZLIB
MySQL::client
Expand Down
4 changes: 2 additions & 2 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
#include "binsrv/time_unit.hpp"

#include "binsrv/event/code_type.hpp"
#include "binsrv/event/common_header_flag_type.hpp"
#include "binsrv/event/event.hpp"
#include "binsrv/event/flag_type.hpp"
#include "binsrv/event/protocol_traits_fwd.hpp"
#include "binsrv/event/reader_context.hpp"

Expand Down Expand Up @@ -325,7 +325,7 @@ void process_binlog_event(const binsrv::event::event &current_event,
const auto code = current_common_header.get_type_code();

const auto is_artificial{current_common_header.get_flags().has_element(
binsrv::event::flag_type::artificial)};
binsrv::event::common_header_flag_type::artificial)};
const auto is_pseudo{current_common_header.get_next_event_position_raw() ==
0U};

Expand Down
6 changes: 3 additions & 3 deletions src/binsrv/event/common_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <boost/date_time/posix_time/time_formatters.hpp>

#include "binsrv/event/code_type.hpp"
#include "binsrv/event/flag_type.hpp"
#include "binsrv/event/common_header_flag_type.hpp"

#include "util/byte_span_extractors.hpp"
#include "util/byte_span_fwd.hpp"
Expand Down Expand Up @@ -106,8 +106,8 @@ common_header::get_readable_type_code() const noexcept {
return to_string_view(get_type_code());
}

[[nodiscard]] flag_set common_header::get_flags() const noexcept {
return flag_set{get_flags_raw()};
[[nodiscard]] common_header_flag_set common_header::get_flags() const noexcept {
return common_header_flag_set{get_flags_raw()};
}

[[nodiscard]] std::string common_header::get_readable_flags() const {
Expand Down
4 changes: 2 additions & 2 deletions src/binsrv/event/common_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <string_view>

#include "binsrv/event/code_type_fwd.hpp"
#include "binsrv/event/flag_type_fwd.hpp"
#include "binsrv/event/common_header_flag_type_fwd.hpp"
#include "binsrv/event/protocol_traits_fwd.hpp"

#include "util/byte_span_fwd.hpp"
Expand Down Expand Up @@ -66,7 +66,7 @@ class [[nodiscard]] common_header {
}

[[nodiscard]] std::uint16_t get_flags_raw() const noexcept { return flags_; }
[[nodiscard]] flag_set get_flags() const noexcept;
[[nodiscard]] common_header_flag_set get_flags() const noexcept;
[[nodiscard]] std::string get_readable_flags() const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#ifndef BINSRV_EVENT_FLAG_TYPE_HPP
#define BINSRV_EVENT_FLAG_TYPE_HPP
#ifndef BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_HPP
#define BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_HPP

#include "binsrv/event/flag_type_fwd.hpp" // IWYU pragma: export
#include "binsrv/event/common_header_flag_type_fwd.hpp" // IWYU pragma: export

#include <algorithm>
#include <array>
Expand All @@ -40,40 +40,41 @@ namespace binsrv::event {
// closed).
// Events received via network stream should never have this flag set.
// clang-format off
#define BINSRV_EVENT_FLAG_TYPE_XY_SEQUENCE() \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(binlog_in_use , 0x001U), \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(thread_specific, 0x004U), \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(suppress_use , 0x008U), \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(artificial , 0x020U), \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(relay_log , 0x040U), \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(ignorable , 0x080U), \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(no_filter , 0x100U), \
BINSRV_EVENT_FLAG_TYPE_XY_MACRO(mts_isolate , 0x200U)
#define BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_SEQUENCE() \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(binlog_in_use , 0x001U), \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(thread_specific, 0x004U), \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(suppress_use , 0x008U), \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(artificial , 0x020U), \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(relay_log , 0x040U), \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(ignorable , 0x080U), \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(no_filter , 0x100U), \
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(mts_isolate , 0x200U)
// clang-format on

#define BINSRV_EVENT_FLAG_TYPE_XY_MACRO(X, Y) X = Y
#define BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(X, Y) X = Y
// NOLINTNEXTLINE(readability-enum-initial-value,cert-int09-c)
enum class flag_type : std::uint16_t {
BINSRV_EVENT_FLAG_TYPE_XY_SEQUENCE(),
enum class common_header_flag_type : std::uint16_t {
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_SEQUENCE(),
delimiter
};
#undef BINSRV_EVENT_FLAG_TYPE_XY_MACRO
#undef BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO

inline std::string_view to_string_view(flag_type code) noexcept {
inline std::string_view to_string_view(common_header_flag_type code) noexcept {
using namespace std::string_view_literals;
using nv_pair = std::pair<flag_type, std::string_view>;
#define BINSRV_EVENT_FLAG_TYPE_XY_MACRO(X, Y) \
nv_pair { flag_type::X, #X##sv }
static constexpr std::array labels{BINSRV_EVENT_FLAG_TYPE_XY_SEQUENCE(),
nv_pair{flag_type::delimiter, ""sv}};
#undef BINSRV_EVENT_FLAG_TYPE_XY_MACRO
using nv_pair = std::pair<common_header_flag_type, std::string_view>;
#define BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO(X, Y) \
nv_pair { common_header_flag_type::X, #X##sv }
static constexpr std::array labels{
BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_SEQUENCE(),
nv_pair{common_header_flag_type::delimiter, ""sv}};
#undef BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_MACRO
// NOLINTNEXTLINE(llvm-qualified-auto,readability-qualified-auto)
const auto fnd{std::ranges::find(labels, code, &nv_pair::first)};
return fnd == std::end(labels) ? ""sv : fnd->second;
}
#undef BINSRV_EVENT_FLAG_TYPE_XY_SEQUENCE
#undef BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_XY_SEQUENCE
// NOLINTEND(cppcoreguidelines-macro-usage)

} // namespace binsrv::event

#endif // BINSRV_EVENT_FLAG_TYPE_HPP
#endif // BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_HPP
32 changes: 32 additions & 0 deletions src/binsrv/event/common_header_flag_type_fwd.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2023-2024 Percona and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License, version 2.0, for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#ifndef BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_FWD_HPP
#define BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_FWD_HPP

#include <cstdint>

#include "util/flag_set_fwd.hpp"

namespace binsrv::event {

// NOLINTNEXTLINE(readability-enum-initial-value,cert-int09-c)
enum class common_header_flag_type : std::uint16_t;

using common_header_flag_set = util::flag_set<common_header_flag_type>;

} // namespace binsrv::event

#endif // BINSRV_EVENT_COMMON_HEADER_FLAG_TYPE_FWD_HPP
6 changes: 4 additions & 2 deletions src/binsrv/event/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
#include "binsrv/event/footer.hpp" // IWYU pragma: export
#include "binsrv/event/format_description_body_impl.hpp" // IWYU pragma: export
#include "binsrv/event/format_description_post_header_impl.hpp" // IWYU pragma: export
#include "binsrv/event/generic_body.hpp" // IWYU pragma: export
#include "binsrv/event/generic_post_header.hpp" // IWYU pragma: export
#include "binsrv/event/generic_body.hpp" // IWYU pragma: export
#include "binsrv/event/generic_post_header.hpp" // IWYU pragma: export
#include "binsrv/event/gtid_log_body_impl.hpp" // IWYU pragma: export
#include "binsrv/event/gtid_log_post_header_impl.hpp" // IWYU pragma: export
#include "binsrv/event/reader_context_fwd.hpp"
#include "binsrv/event/rotate_body_impl.hpp" // IWYU pragma: export
#include "binsrv/event/rotate_post_header_impl.hpp" // IWYU pragma: export
Expand Down
Loading