MySQL 8.4.0
Source Code Documentation
binlog_storage_iterator.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef BINLOG_STORAGE_ITERATOR_SERVICE_HEADERS_H
25#define BINLOG_STORAGE_ITERATOR_SERVICE_HEADERS_H
26#include <cstdint>
27#include <string>
28
32
34
36 /// @brief Iterator was successfully initialized.
38
39 /// @brief Returned when the required GTIDs have already been purged and
40 /// therefore the iterator cannot fetch the needed entries. Caller should
41 /// still call the deinit function on the iterator.
43
44 /// @brief Returned when the log is closed and therefore the iterator cannot
45 /// get the change entries. Caller should still call the deinit function on
46 /// the iterator.
48
49 /// @brief Failure to initialize iterator due to undefined error. Caller
50 /// should still call the deinit function on the iterator.
52};
53
54/// @brief This enumeration lists the possible return values for the get
55/// function
57 /// @brief returned when the get operation succeeded.
58 ///
59 /// If the get operation succeeds, this also means that the iterator advances.
61
62 /// @brief returned when there are no more entries to get.
63 ///
64 /// The iterator remains open and you can call get on it again. If
65 /// more content has been created in the meantime, get will get it
66 /// for you.
68
69 /// @brief returned whenever the get was called with an insufficient buffer.
70 ///
71 /// The iterator does not advance and the caller can call get again with a
72 /// larger buffer.
74
75 /// @brief Returned when there is an unrecoverable error and this iterator has
76 /// been closed. The caller still needs to deinitialize the iterator.
78
79 /// @brief returned whenever the iterator context is invalid.
80 ///
81 /// The iterator became invalid and therefore it cannot be used successfully
82 /// from now onwards. I must still be de-initialized to release resources.
84
85 /// @brief returned whenever there was an unspecified error attempting to get
86 /// the next entry.
87 ///
88 /// In case of an unspecified error, the caller can retry but there is no
89 /// guarantee whether the retry is successful or not.
91};
92
93BEGIN_SERVICE_DEFINITION(binlog_storage_iterator)
94
95/// @brief Initializes the iterator.
96///
97/// my_h_binlog_storage_iterator is the service handle defined and is an opaque
98/// pointer to the stream state.
99///
100/// @param[out] iterator where the iterator created will be stored.
101///
102/// @param[in] excluded_gtids_as_string The set of GTIDs to filter out from the
103/// iterator.
104///
105/// @retval kBinlogIteratorInitOk @see
106/// Binlog_iterator_service_init_status#kBinlogIteratorInitOk
107/// @retval kBinlogIteratorIniErrorPurgedGtids @see
108/// Binlog_iterator_service_init_status#kBinlogIteratorIniErrorPurgedGtids
109/// @retval kBinlogIteratorInitErrorLogClosed @see
110/// Binlog_iterator_service_init_status#kBinlogIteratorInitErrorLogClosed
111/// @retval kBinlogIteratorInitErrorUnspecified @see
112/// Binlog_iterator_service_init_status#kBinlogIteratorGetErrorUnspecified
115 const char *excluded_gtids_as_string));
116
117/// @brief Shall get the next event in the iterator.
118///
119/// Gets the next event in the iterator. If there are no more events in the
120/// iterator, it just returns immediately. Note that this function will also
121/// advance the iterator if the operation is successful or the next entries are
122/// to be skipped.
123///
124/// In case the error is kBinlogIteratorGetErrorInvalid or
125/// kBinlogIteratorGetErrorUnspecified the iterator must be de initialized by
126/// calling deinit. If the caller attempts to call get again, then the
127/// same error is returned.
128///
129/// @param iterator the iterator reference to use use during the get operation.
130///
131/// @param[in,out] buffer the buffer to store the raw change stream bytes for
132/// the next entry fetched from the given iterator.
133///
134/// @param[in] buffer_capacity the capacity of the buffer where the bytes are to
135/// be stored.
136///
137/// @param[out] bytes_read the amount of bytes read and put into the buffer.
138///
139/// @retval kBinlogIteratorGetOk
140/// Binlog_iterator_service_get_status#kBinlogIteratorGetOk
141/// @retval kBinlogIteratorGetEndOfChanges
142/// Binlog_iterator_service_get_status#kBinlogIteratorGetEndOfChanges
143/// @retval kBinlogIteratorGetInsufficientBuffer
144/// Binlog_iterator_service_get_status#kBinlogIteratorGetInsufficientBuffer
145/// @retval kBinlogIteratorGetErrorClosed @see
146/// Binlog_iterator_service_get_status#kBinlogIteratorGetErrorClosed
147/// @retval kBinlogIteratorGetErrorInvalid @see
148/// Binlog_iterator_service_get_status#kBinlogIteratorGetErrorInvalid
149/// @retval kBinlogIteratorGetErrorUnspecified @see
150/// Binlog_iterator_service_get_status#kBinlogIteratorGetErrorUnspecified
152 (my_h_binlog_storage_iterator iterator, unsigned char *buffer,
153 uint64_t buffer_capacity, uint64_t *bytes_read));
154
155/// @brief Destroys the iterator and releases resources associated with it.
156///
157/// @param[in] iterator the iterator to destroy.
159
160/// @brief Gets details about the entry's storage in a JSON format.
161///
162/// Allows the caller to get information about the underlying storage. Some
163/// implementations may return a name and a position, for instance.
164///
165/// @param[in] iterator the iterator handle.
166///
167/// @param[in,out] buffer The buffer to store the information in.
168///
169/// @param[in,out] size As input, the size of the buffer provided. As output,
170/// the size of the data copied into the buffer.
171///
172/// @return true if there was an error, false otherwise.
173DECLARE_BOOL_METHOD(get_storage_details, (my_h_binlog_storage_iterator iterator,
174 char *buffer, uint64_t *size));
175
176/// @brief Gets the size of the next entry to fetch from the iterator.
177///
178/// Useful to drive reallocations.
179///
180/// @param[in] iterator the iterator being operated.
181/// @param[out] size a pointer to store the size of the next entry to get.
182///
183/// @return false on success, true otherwise. Note that if the iterator has
184/// reached the end of changes, then it means that an error shall be returned.
185DECLARE_BOOL_METHOD(get_next_entry_size,
186 (my_h_binlog_storage_iterator iterator, uint64_t *size));
187
188END_SERVICE_DEFINITION(binlog_storage_iterator)
189
190#endif /* BINLOG_STORAGE_ITERATOR_SERVICE_HEADERS_H */
static mysql_service_status_t deinit()
Component deinitialization.
Definition: audit_api_message_emit.cc:580
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
Binlog_iterator_service_init_status
Definition: binlog_storage_iterator.h:35
@ kBinlogIteratorInitErrorUnspecified
Failure to initialize iterator due to undefined error.
Definition: binlog_storage_iterator.h:51
@ kBinlogIteratorInitErrorLogClosed
Returned when the log is closed and therefore the iterator cannot get the change entries.
Definition: binlog_storage_iterator.h:47
@ kBinlogIteratorInitOk
Iterator was successfully initialized.
Definition: binlog_storage_iterator.h:37
@ kBinlogIteratorIniErrorPurgedGtids
Returned when the required GTIDs have already been purged and therefore the iterator cannot fetch the...
Definition: binlog_storage_iterator.h:42
Binlog_iterator_service_get_status
This enumeration lists the possible return values for the get function.
Definition: binlog_storage_iterator.h:56
@ kBinlogIteratorGetErrorClosed
Returned when there is an unrecoverable error and this iterator has been closed.
Definition: binlog_storage_iterator.h:77
@ kBinlogIteratorGetErrorInvalid
returned whenever the iterator context is invalid.
Definition: binlog_storage_iterator.h:83
@ kBinlogIteratorGetErrorUnspecified
returned whenever there was an unspecified error attempting to get the next entry.
Definition: binlog_storage_iterator.h:90
@ kBinlogIteratorGetEndOfChanges
returned when there are no more entries to get.
Definition: binlog_storage_iterator.h:67
@ kBinlogIteratorGetInsufficientBuffer
returned whenever the get was called with an insufficient buffer.
Definition: binlog_storage_iterator.h:73
@ kBinlogIteratorGetOk
returned when the get operation succeeded.
Definition: binlog_storage_iterator.h:60
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
void get(PSI_field *, PSI_longlong *) noexcept
Definition: pfs_plugin_column_bigint_v1_all_empty.cc:32
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:103
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86
#define DEFINE_SERVICE_HANDLE(name)
Defines an object type that is meant for carrying handles to the implementation-specific objects used...
Definition: service.h:129
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:112
Definition: file_storage.cc:430