MySQL 26.7.0
Source Code Documentation
event_set_fetchable.h
Go to the documentation of this file.
1// Copyright (c) 2026, 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#ifndef MYSQL_CSA_EVENT_SET_FETCHABLE_H
25#define MYSQL_CSA_EVENT_SET_FETCHABLE_H
26
27#include <list>
28#include <memory>
29#include <optional>
32
33namespace mysql::csa {
34
35class Event_set_fetchable;
36
37/// @brief Unique pointer to a specific implementation of Event_set_fetchable
38/// (no need to share).
39using Event_set_fetchable_ptr = std::unique_ptr<Event_set_fetchable>;
40
41/// @brief List of Event_set_fetchable pointers, each able to fetch a whole
42/// transaction from the storage.
43using Event_set_fetchable_list = std::list<Event_set_fetchable_ptr>;
44
45/// @brief Represents metadata of a set of events, capable of being fetched
46/// from a storage. Typically, one event set will contain
47/// metadata of a part of, or a whole transaction. Event_set_fetchable supplies
48/// a function to fetch consecutive Log_event objects. If needed, it
49/// decompresses the underlying event stream. A transaction contains one or many
50/// fetchable event sets; this is decided by a specific implementation of a
51/// storage reader (e.g., relay log storage reader will keep separate event sets
52/// for parts of transaction kept in separate files). The specific
53/// implementation of a fetchable event set is driven by the implementation of
54/// the storage type (see Event_set_fetchable_relay_log).
56 public:
58 using Fde_ptr = Fde_type *;
59 using Log_event_ptr = std::shared_ptr<Log_event>;
60 /// @brief Waits until the next event can be fetched.
61 /// @return true if the next event can be fetched, false on end/error.
62 virtual bool wait_next() = 0;
63 /// @brief Fetches the next event if possible.
64 ///
65 /// Callers are expected to wait for availability with `wait_next()` first
66 /// when the underlying implementation supports streaming updates.
67 /// @return Managed_event object or an empty optional if the stream ended
68 /// (with or without error).
69 virtual std::optional<Managed_event> fetch_next() = 0;
70 /// @brief Checks if the event set has been fully fetched successfully.
71 /// @return true if the event set finished successfully, false otherwise.
72 virtual bool is_done() const = 0;
73 /// @brief Checks if an error occurred during fetching.
74 /// @return true if an error occurred, false otherwise.
75 virtual bool is_error() const = 0;
76 /// @brief Retrieves the error message if an error occurred.
77 /// @return A reference to the error message string (empty if no error).
78 virtual const std::string &get_error_str() const = 0;
79 /// @brief Resets the state to allow fetching the event set again, also
80 /// clearing any error state.
81 /// @param reset_events When true events states need to be reset
82 virtual void reset(bool reset_events) = 0;
83 /// @brief Checks if this event set represents a complete transaction.
84 /// @return true if it represents a transaction, false otherwise.
85 virtual bool is_trx() const = 0;
86 /// @brief Obtains non-owning pointer to current transaction FDE.
87 /// @return Non-owning pointer to FDE.
88 virtual Fde_ptr get_fde() = 0;
89 /// @brief Sets the end of the stream if needed. Empty by default.
90 /// @brief Virtual destructor.
91 virtual ~Event_set_fetchable() = default;
92 /// @brief Callback on success, default - do nothing
93 virtual void set_success() {}
94
95 private:
96};
97
98} // namespace mysql::csa
99
100#endif // MYSQL_CSA_EVENT_SET_FETCHABLE_H
For binlog version 4.
Definition: log_event.h:1558
Represents metadata of a set of events, capable of being fetched from a storage.
Definition: event_set_fetchable.h:55
virtual std::optional< Managed_event > fetch_next()=0
Fetches the next event if possible.
virtual bool is_done() const =0
Checks if the event set has been fully fetched successfully.
virtual bool wait_next()=0
Waits until the next event can be fetched.
virtual ~Event_set_fetchable()=default
Sets the end of the stream if needed.
virtual bool is_trx() const =0
Checks if this event set represents a complete transaction.
std::shared_ptr< Log_event > Log_event_ptr
Definition: event_set_fetchable.h:59
virtual bool is_error() const =0
Checks if an error occurred during fetching.
virtual void reset(bool reset_events)=0
Resets the state to allow fetching the event set again, also clearing any error state.
virtual Fde_ptr get_fde()=0
Obtains non-owning pointer to current transaction FDE.
virtual void set_success()
Callback on success, default - do nothing.
Definition: event_set_fetchable.h:93
virtual const std::string & get_error_str() const =0
Retrieves the error message if an error occurred.
Definition: channel.cpp:28
std::unique_ptr< Event_set_fetchable > Event_set_fetchable_ptr
Unique pointer to a specific implementation of Event_set_fetchable (no need to share).
Definition: event_set_fetchable.h:39
std::list< Event_set_fetchable_ptr > Event_set_fetchable_list
List of Event_set_fetchable pointers, each able to fetch a whole transaction from the storage.
Definition: event_set_fetchable.h:43
Experimental API header.