MySQL 8.0.30
Source Code Documentation
control_events.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2022, 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 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 control_events.h
28
29 @brief Contains the classes representing events operating in the replication
30 stream properties. Each event is represented as a byte sequence with logical
31 divisions as event header, event specific data and event footer. The header
32 and footer are common to all the events and are represented as two different
33 subclasses.
34*/
35
36#ifndef CONTROL_EVENT_INCLUDED
37#define CONTROL_EVENT_INCLUDED
38
39#include <sys/types.h>
40#include <time.h>
41#include <list>
42#include <map>
43#include <vector>
44
45#include "binlog_event.h"
46#include "template_utils.h"
47#include "uuid.h"
48
49#include "compression/base.h"
50
51namespace binary_log {
52/**
53 @class Rotate_event
54
55 When a binary log file exceeds a size limit, a ROTATE_EVENT is written
56 at the end of the file that points to the next file in the sequence.
57 This event is information for the slave to know the name of the next
58 binary log it is going to receive.
59
60 ROTATE_EVENT is generated locally and written to the binary log
61 on the master. It is written to the relay log on the slave when FLUSH LOGS
62 occurs, and when receiving a ROTATE_EVENT from the master.
63 In the latter case, there will be two rotate events in total originating
64 on different servers.
65
66 @section Rotate_event_binary_format Binary Format
67
68 <table>
69 <caption>Post-Header for Rotate_event</caption>
70
71 <tr>
72 <th>Name</th>
73 <th>Format</th>
74 <th>Description</th>
75 </tr>
76
77 <tr>
78 <td>position</td>
79 <td>8 byte integer</td>
80 <td>The position within the binary log to rotate to.</td>
81 </tr>
82
83 </table>
84
85 The Body has one component:
86
87 <table>
88 <caption>Body for Rotate_event</caption>
89
90 <tr>
91 <th>Name</th>
92 <th>Format</th>
93 <th>Description</th>
94 </tr>
95
96 <tr>
97 <td>new_log_ident</td>
98 <td>variable length string without trailing zero, extending to the
99 end of the event (determined by the length field of the
100 Common-Header)
101 </td>
102 <td>Name of the binlog to rotate to.</td>
103 </tr>
104
105 </table>
106*/
108 public:
109 const char *new_log_ident;
110 size_t ident_len;
111 unsigned int flags;
112 uint64_t pos;
113
114 enum {
115 /* Values taken by the flag member variable */
116 DUP_NAME = 2, // if constructor should dup the string argument
117 RELAY_LOG = 4 // rotate event for the relay log
118 };
119
120 enum {
121 /* Rotate event post_header */
124 };
125
126 /**
127 This is the minimal constructor, it will set the type code as ROTATE_EVENT.
128 */
129 Rotate_event(const char *new_log_ident_arg, size_t ident_len_arg,
130 unsigned int flags_arg, uint64_t pos_arg)
132 new_log_ident(new_log_ident_arg),
133 ident_len(ident_len_arg ? ident_len_arg : strlen(new_log_ident_arg)),
134 flags(flags_arg),
135 pos(pos_arg) {}
136
137 /**
138 The layout of Rotate_event data part is as follows:
139
140 <pre>
141 +-----------------------------------------------------------------------+
142 | common_header | post_header | position of the first event | file name |
143 +-----------------------------------------------------------------------+
144 </pre>
145
146 @param buf Contains the serialized event.
147 @param fde An FDE event, used to get the following information:
148 -binlog_version
149 -server_version
150 -post_header_len
151 -common_header_len
152 The content of this object depends on the binlog-version
153 currently in use.
154 */
155 Rotate_event(const char *buf, const Format_description_event *fde);
156
157#ifndef HAVE_MYSYS
158 void print_event_info(std::ostream &) override;
159 void print_long_info(std::ostream &) override;
160#endif
161
162 ~Rotate_event() override {
163 if (flags & DUP_NAME) bapi_free(const_cast<char *>(new_log_ident));
164 }
165};
166
167/**
168 @class Format_description_event
169 For binlog version 4.
170 This event is saved by threads which read it, as they need it for future
171 use (to decode the ordinary events).
172
173 @section Format_description_event_binary_format Binary Format
174
175 The Post-Header has six components:
176
177 <table>
178 <caption>Post-Header for Format_description_event</caption>
179
180 <tr>
181 <th>Name</th>
182 <th>Format</th>
183 <th>Description</th>
184 </tr>
185
186 <tr>
187 <td>created</td>
188 <td>4 byte unsigned integer</td>
189 <td>The creation timestamp, if non-zero,
190 is the time in seconds when this event was created</td>
191 </tr>
192 <tr>
193 <td>binlog_version</td>
194 <td>2 byte unsigned integer</td>
195 <td>This is 1 in MySQL 3.23 and 3 in MySQL 4.0 and 4.1
196 (In MySQL 5.0 and up, FORMAT_DESCRIPTION_EVENT is
197 used instead of START_EVENT_V3 and for them its 4).</td>
198 </tr>
199 <tr>
200 <td>server_version</td>
201 <td>char array of 50 bytes</td>
202 <td>The MySQL server's version (example: 4.0.14-debug-log),
203 padded with 0x00 bytes on the right</td>
204 </tr>
205 <tr>
206 <td>common_header_len</td>
207 <td>1 byte unsigned integer</td>
208 <td>The length of the event header. This value includes the extra_headers
209 field, so this header length - 19 yields the size
210 of the extra_headers field.</td>
211 </tr>
212 <tr>
213 <td>post_header_len</td>
214 <td>array of type 1 byte unsigned integer</td>
215 <td>The lengths for the fixed data part of each event</td>
216 </tr>
217 <tr>
218 <td>server_version_split</td>
219 <td>unsigned char array</td>
220 <td>Stores the server version of the server
221 and splits them in three parts</td>
222 </tr>
223 <tr>
224 <td>number_of_event_types</td>
225 <td>1 byte unsigned integer</td>
226 <td>number of event types present in the server</td>
227 </tr>
228 </table>
229*/
231 public:
232 /**
233 If this event is at the start of the first binary log since server
234 startup 'created' should be the timestamp when the event (and the
235 binary log) was created. In the other case (i.e. this event is at
236 the start of a binary log created by FLUSH LOGS or automatic
237 rotation), 'created' should be 0. This "trick" is used by MySQL
238 >=4.0.14 slaves to know whether they must drop stale temporary
239 tables and whether they should abort unfinished transaction.
240
241 Note that when 'created'!=0, it is always equal to the event's
242 timestamp; indeed Format_description_event is written only in binlog.cc
243 where the first constructor below is called, in which 'created' is set to
244 'when'. So in fact 'created' is a useless variable. When it is 0 we can
245 read the actual value from timestamp ('when') and when it is non-zero we
246 can read the same value from timestamp
247 ('when'). Conclusion:
248 - we use timestamp to print when the binlog was created.
249 - we use 'created' only to know if this is a first binlog or not.
250 */
251 time_t created;
254 /*
255 We set this to 1 if we don't want to have the created time in the log,
256 which is the case when we rollover to a new log.
257 */
259
260 /**
261 The size of the fixed header which _all_ events have
262 (for binlogs written by this version, this is equal to
263 LOG_EVENT_HEADER_LEN), except FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT
264 (those have a header of size LOG_EVENT_MINIMAL_HEADER_LEN).
265 */
267 /*
268 The list of post-headers' lengths followed
269 by the checksum alg description byte
270 */
271 std::vector<uint8_t> post_header_len;
273
274 /**
275 Format_description_event 1st constructor.
276
277 This constructor can be used to create the event to write to the binary log
278 (when the server starts or when FLUSH LOGS)
279
280 @param binlog_ver the binlog version for which we want to build
281 an event. It should only be 4, old versions are not compatible anymore
282 since 8.0.2.
283 @param server_ver The MySQL server's version.
284 */
285 Format_description_event(uint8_t binlog_ver, const char *server_ver);
286 /**
287 The layout of Format_description_event data part is as follows:
288
289 <pre>
290 +=====================================+
291 | event | binlog_version 19 : 2 | = 4
292 | data +----------------------------+
293 | | server_version 21 : 50 |
294 | +----------------------------+
295 | | create_timestamp 71 : 4 |
296 | +----------------------------+
297 | | header_length 75 : 1 |
298 | +----------------------------+
299 | | post-header 76 : n | = array of n bytes, one byte
300 | | lengths for all | per event type that the
301 | | event types | server knows about
302 +=====================================+
303 </pre>
304 @param buf Contains the serialized event.
305 @param fde An FDE event (see Rotate_event constructor for more info).
306
307 @note The fde passed to this constructor was created through another
308 constructor of FDE class.
309 */
310 Format_description_event(const char *buf,
311 const Format_description_event *fde);
312
315 default;
317 /**
318 This method is used to find out the version of server that originated
319 the current FD instance.
320
321 @return the version of server.
322 */
323 unsigned long get_product_version() const;
324 /**
325 This method checks the MySQL version to determine whether checksums may be
326 present in the events contained in the binary log.
327
328 @retval true if the event's version is earlier than one that introduced
329 the replication event checksum.
330 @retval false otherwise.
331 */
332 bool is_version_before_checksum() const;
333 /**
334 This method populates the array server_version_split which is then used for
335 lookups to find if the server which created this event has some known bug.
336 */
338#ifndef HAVE_MYSYS
339 void print_event_info(std::ostream &info) override;
340 void print_long_info(std::ostream &info) override;
341#endif
343
344 bool header_is_valid() const {
346 (!post_header_len.empty()));
347 }
348
349 bool version_is_valid() const {
350 /* It is invalid only when all version numbers are 0 */
351 return server_version_split[0] != 0 || server_version_split[1] != 0 ||
352 server_version_split[2] != 0;
353 }
354};
355
356/**
357 @class Stop_event
358
359 A stop event is written to the log files under these circumstances:
360 - A master writes the event to the binary log when it shuts down.
361 - A slave writes the event to the relay log when it shuts down or
362 when a RESET SLAVE statement is executed.
363
364 @section Stop_event_binary_format Binary Format
365
366 The Post-Header and Body for this event type are empty; it only has
367 the Common-Header.
368*/
369
371 public:
372 /**
373 It is the minimal constructor, and all it will do is set the type_code as
374 STOP_EVENT in the header object in Binary_log_event.
375 */
377
378 /**
379 A Stop_event is occurs under these circumstances:
380 - A master writes the event to the binary log when it shuts down
381 - A slave writes the event to the relay log when it shuts down or when a
382 RESET SLAVE statement is executed
383 @param buf Contains the serialized event.
384 @param fde An FDE event (see Rotate_event constructor for more info).
385 */
386 Stop_event(const char *buf, const Format_description_event *fde);
387
388#ifndef HAVE_MYSYS
389 void print_event_info(std::ostream &) override {}
390 void print_long_info(std::ostream &info) override;
391#endif
392};
393
394/**
395 @class Incident_event
396
397 Class representing an incident, an occurrence out of the ordinary,
398 that happened on the master.
399
400 The event is used to inform the slave that something out of the
401 ordinary happened on the master that might cause the database to be
402 in an inconsistent state.
403
404 @section Incident_event_binary_format Binary Format
405
406 <table id="IncidentFormat">
407 <caption>Incident event format</caption>
408 <tr>
409 <th>Symbol</th>
410 <th>Format</th>
411 <th>Description</th>
412 </tr>
413 <tr>
414 <td>INCIDENT</td>
415 <td align="right">2</td>
416 <td>Incident number as an unsigned integer</td>
417 </tr>
418 <tr>
419 <td>MSGLEN</td>
420 <td align="right">1</td>
421 <td>Message length as an unsigned integer</td>
422 </tr>
423 <tr>
424 <td>MESSAGE</td>
425 <td align="right">MSGLEN</td>
426 <td>The message, if present. Not null terminated.</td>
427 </tr>
428 </table>
429
430*/
432 public:
433 /**
434 Enumeration of the incidents that can occur for the server.
435 */
437 /** No incident */
439 /** There are possibly lost events in the replication stream */
441 /** Shall be last event of the enumeration */
443 };
444
446 char *get_message() { return message; }
447
448 /**
449 This will create an Incident_event with an empty message and set the
450 type_code as INCIDENT_EVENT in the header object in Binary_log_event.
451 */
452 explicit Incident_event(enum_incident incident_arg)
454 incident(incident_arg),
456 message_length(0) {}
457
458 /**
459 Constructor of Incident_event
460 The buffer layout is as follows:
461 <pre>
462 +-----------------------------------------------------+
463 | Incident_number | message_length | Incident_message |
464 +-----------------------------------------------------+
465 </pre>
466
467 Incident number codes are listed in binlog_evnet.h.
468 The only code currently used is INCIDENT_LOST_EVENTS, which indicates that
469 there may be lost events (a "gap") in the replication stream that requires
470 databases to be resynchronized.
471
472 @param buf Contains the serialized event.
473 @param fde An FDE event (see Rotate_event constructor for more info).
474 */
475 Incident_event(const char *buf, const Format_description_event *fde);
476#ifndef HAVE_MYSYS
477 void print_event_info(std::ostream &info) override;
478 void print_long_info(std::ostream &info) override;
479#endif
480 protected:
482 char *message;
484};
485
486/**
487 @class Xid_event
488
489 An XID event is generated for a commit of a transaction that modifies one or
490 more tables of an XA-capable storage engine.
491
492 @section Xid_event_binary_format Binary Format
493
494The Body has the following component:
495
496 <table>
497 <caption>Body for Xid_event</caption>
498
499 <tr>
500 <th>Name</th>
501 <th>Format</th>
502 <th>Description</th>
503 </tr>
504
505 <tr>
506 <td>xid</td>
507 <td>8 byte unsigned integer</td>
508 <td>The XID transaction number.</td>
509 </tr>
510 </table>
511 The Post-Header and Body for this event type are empty; it only has
512 the common header.
513*/
515 public:
516 /**
517 The minimal constructor of Xid_event, it initializes the instance variable
518 xid and set the type_code as XID_EVENT in the header object in
519 Binary_log_event
520 */
521 explicit Xid_event(uint64_t xid_arg)
522 : Binary_log_event(XID_EVENT), xid(xid_arg) {}
523
524 /**
525 An XID event is generated for a commit of a transaction that modifies one or
526 more tables of an XA-capable storage engine
527 @param buf Contains the serialized event.
528 @param fde An FDE event (see Rotate_event constructor for more info).
529 */
530 Xid_event(const char *buf, const Format_description_event *fde);
531 uint64_t xid;
532#ifndef HAVE_MYSYS
533 void print_event_info(std::ostream &info) override;
534 void print_long_info(std::ostream &info) override;
535#endif
536};
537
538/**
539 @class XA_prepare_event
540
541 An XA_prepare event is generated for a XA prepared transaction.
542 Like Xid_event it contains XID of the *prepared* transaction.
543
544 @section XA_prepare_event_binary_format Binary Format
545
546The Body has the following component:
547
548 <table>
549 <caption>Body for XA_prepare_event</caption>
550
551 <tr>
552 <th>Name</th>
553 <th>Format</th>
554 <th>Description</th>
555 </tr>
556
557 <tr>
558 <td>my_xid</td>
559 <td>a struct similar to mysql/plugin.h containing three members.</td>
560 <td>serialized XID representation of XA transaction.</td>
561 </tr>
562
563 <tr>
564 <td>xid</td>
565 <td>a pointer to XID object.</td>
566 <td>a reference to an object for mysql logger.</td>
567 </tr>
568
569 <tr>
570 <td>one_phase</td>
571 <td>a bool</td>
572 <td>the value specifies the current XA transaction commit method.</td>
573 </tr>
574 </table>
575 The Post-Header and Body for this event type are empty; it only has
576 the common header.
577*/
578
580 /*
581 Struct def is copied from $MYSQL/include/mysql/plugin.h,
582 consult there about fine details.
583 */
584 static const int MY_XIDDATASIZE = 128;
585
586 public:
587 struct MY_XID {
591 char data[MY_XIDDATASIZE]; /* Not \0-terminated */
592 };
593
594 protected:
595 /* size of serialization buffer is explained in $MYSQL/sql/xa.h. */
596 static const uint16_t ser_buf_size =
597 8 + 2 * MY_XIDDATASIZE + 4 * sizeof(long) + 1;
599 void *xid; /* Master side only */
601
602 public:
603 /**
604 The minimal constructor of XA_prepare_event, it initializes the
605 instance variable xid and set the type_code as XID_EVENT in the
606 header object in Binary_log_event
607 */
608 XA_prepare_event(void *xid_arg, bool oph_arg)
610 xid(xid_arg),
611 one_phase(oph_arg) {}
612
613 /**
614 An XID event is generated for a commit of a transaction that modifies one or
615 more tables of an XA-capable storage engine
616 @param buf Contains the serialized event.
617 @param fde An FDE event (see Rotate_event constructor for more info).
618 */
619 XA_prepare_event(const char *buf, const Format_description_event *fde);
620#ifndef HAVE_MYSYS
621 /*
622 todo: we need to find way how to exploit server's code of
623 serialize_xid()
624 */
625 void print_event_info(std::ostream &) override {}
626 void print_long_info(std::ostream &) override {}
627#endif
628 /**
629 Whether or not this `XA_prepare_event` represents an `XA COMMIT ONE
630 PHASE`.
631
632 @return true if it's an `XA COMMIT ONE PHASE`, false otherwise.
633 */
634 bool is_one_phase() const;
635 /**
636 Retrieves the content of `my_xid` member variable.
637
638 @return The const-reference to the `my_xid` member variable.
639 */
640 MY_XID const &get_xid() const;
641};
642
643/**
644 @class Ignorable_event
645
646 Base class for ignorable log events. Events deriving from
647 this class can be safely ignored by slaves that cannot
648 recognize them. Newer slaves, will be able to read and
649 handle them. This has been designed to be an open-ended
650 architecture, so adding new derived events shall not harm
651 the old slaves that support ignorable log event mechanism
652 (they will just ignore unrecognized ignorable events).
653
654 @note The only thing that makes an event ignorable is that it has
655 the LOG_EVENT_IGNORABLE_F flag set. It is not strictly necessary
656 that ignorable event types derive from Ignorable_event; they may
657 just as well derive from Binary_log_event and Log_event and pass
658 LOG_EVENT_IGNORABLE_F as argument to the Log_event constructor.
659
660 @section Ignoarble_event_binary_format Binary format
661
662 The Post-Header and Body for this event type are empty; it only has
663 the Common-Header.
664*/
666 public:
667 // buf is advanced in Binary_log_event constructor to point to beginning of
668 // post-header
669
670 /**
671 The minimal constructor and all it will do is set the type_code as
672 IGNORABLE_LOG_EVENT in the header object in Binary_log_event.
673 */
675 : Binary_log_event(type_arg) {}
676 /**
677 @param buf Contains the serialized event.
678 @param fde An FDE event (see Rotate_event constructor for more info).
679 */
680 Ignorable_event(const char *buf, const Format_description_event *fde);
681#ifndef HAVE_MYSYS
682 void print_event_info(std::ostream &) override {}
683 void print_long_info(std::ostream &) override {}
684#endif
685};
686
687/**
688 @struct gtid_info
689 Structure to hold the members declared in the class Gtid_log_event those
690 member are objects of classes defined in server(rpl_gtid.h). As we can not
691 move all the classes defined there(in rpl_gtid.h) in libbinlogevents so this
692 structure was created, to provide a way to map the decoded value in Gtid_event
693 ctor and the class members defined in rpl_gtid.h, these classes are also the
694 members of Gtid_log_event(subclass of this in server code)
695
696 The structure contains the following components.
697 <table>
698 <caption>Structure gtid_info</caption>
699
700 <tr>
701 <th>Name</th>
702 <th>Format</th>
703 <th>Description</th>
704 </tr>
705 <tr>
706 <td>rpl_gtid_sidno</td>
707 <td>4 bytes integer</td>
708 <td>SIDNO (source ID number, first component of GTID)</td>
709 </tr>
710 <tr>
711 <td>rpl_gtid_gno</td>
712 <td>8 bytes integer</td>
713 <td>GNO (group number, second component of GTID)</td>
714 </tr>
715 </table>
716*/
717struct gtid_info {
720};
721
722/**
723 This event is a wrapper event and encloses many other events.
724
725 It is mostly used for carrying compressed payloads as its content
726 can be compressed, in which case, its metadata shall contain
727 information about the compression metadata as well.
728 */
730 private:
732 delete;
734
735 protected:
736 /**
737 The raw bytes which are the data that this event contains.
738 */
739 const char *m_payload{nullptr};
740
741 /**
742 The size of the data.
743 */
744 uint64_t m_payload_size{0};
745
746 /**
747 If the data is compressed, which compression was used.
748
749 For now, the only compressors supported are: ZSTD or NONE.
750
751 NONE means no compression at all. ZSTD means using ZSTD compression.
752 */
755
756 /**
757 The size of the data uncompressed. This is the same as @c m_payload_size if
758 there is no compression involved.
759 */
761
762 public:
763 static const unsigned short COMPRESSION_TYPE_MIN_LENGTH = 1;
764 static const unsigned short COMPRESSION_TYPE_MAX_LENGTH = 9;
765 static const unsigned short PAYLOAD_SIZE_MIN_LENGTH = 0;
766 static const unsigned short PAYLOAD_SIZE_MAX_LENGTH = 9;
767 static const unsigned short UNCOMPRESSED_SIZE_MIN_LENGTH = 0;
768 static const unsigned short UNCOMPRESSED_SIZE_MAX_LENGTH = 9;
769
773 /**
774 Creates @c Transaction_payload_event with the given data which has the
775 given size.
776
777 @param payload the data that this event shall wrap.
778 @param payload_size the size of the payload.
779
780 The data shall not be compressed. However, there is no other validation
781 that this is the case.
782 */
783 Transaction_payload_event(const char *payload, uint64_t payload_size);
784
785 /**
786 Creates @c Transaction_payload_event with the given data which has the
787 given size. The data provided may or may not have been compressed. In
788 any case the compression_type must be set.
789
790 @param payload the data that this event shall wrap.
791 @param payload_size the size of the payload.
792 @param compression_type the compression type used for the data provided.
793 @param uncompressed_size the size of the data when uncompressed.
794
795 The data may or may not be compressed. There is no validation or check
796 that it is or that the payload matches the metadata provided.
797 */
798 Transaction_payload_event(const char *payload, uint64_t payload_size,
799 uint16_t compression_type,
800 uint64_t uncompressed_size);
801
802 /**
803 This constructor takes a raw buffer and a format descriptor event and
804 decodes the buffer. It populates this event metadata with the contents
805 of the buffer.
806
807 @param buf the buffer to decode.
808 @param fde the format description event used to decode the buffer.
809 */
810 Transaction_payload_event(const char *buf,
811 const Format_description_event *fde);
812
813 /**
814 This destroys the transaction payload event.
815 */
817
818 /**
819 Shall set the compression type used for the enclosed payload.
820
821 @param type the compression type.
822 */
825 }
826
827 /**
828 Shall return the compression type used for the enclosed payload.
829
830 @return the compression type.
831 */
833 return m_compression_type;
834 }
835
836 /**
837 Shall set the size of the payload inside this event.
838
839 @param size The payload size.
840 */
841 void set_payload_size(uint64_t size) { m_payload_size = size; }
842
843 /**
844 Shall get the size of the payload inside this event.
845
846 @return The payload size.
847 */
848 uint64_t get_payload_size() const { return m_payload_size; }
849
850 /**
851 Shall set the uncompressed size of the payload.
852
853 @param size the uncompressed size of the payload.
854 */
855 void set_uncompressed_size(uint64_t size) { m_uncompressed_size = size; }
856
857 /**
858 Shall get the uncompressed size of the event.
859
860 @return uncompressed_size.
861 */
862 uint64_t get_uncompressed_size() const { return m_uncompressed_size; }
863
864 /**
865 Shall set the payload of the event.
866
867 @param data the payload of the event.
868 */
869 void set_payload(const char *data) { m_payload = data; }
870
871 /**
872 Shall get the payload of the event.
873
874 @return the payload of the event.
875 */
876 const char *get_payload() const { return m_payload; }
877
878 /**
879 Shall return a textual representation of this event.
880
881 @return a textial representation of this event.
882 */
883 std::string to_string() const;
884
885#ifndef HAVE_MYSYS
886 virtual void print_event_info(std::ostream &) override;
887 virtual void print_long_info(std::ostream &) override;
888#endif
889};
890
891/**
892 @class Gtid_event
893 GTID stands for Global Transaction IDentifier
894 It is composed of two parts:
895 - SID for Source Identifier, and
896 - GNO for Group Number.
897 The basic idea is to
898 - Associate an identifier, the Global Transaction IDentifier or GTID,
899 to every transaction.
900 - When a transaction is copied to a slave, re-executed on the slave,
901 and written to the slave's binary log, the GTID is preserved.
902 - When a slave connects to a master, the slave uses GTIDs instead of
903 (file, offset)
904
905 @section Gtid_event_binary_format Binary Format
906
907 The Body can have up to nine components:
908
909 <table>
910 <caption>Body for Gtid_event</caption>
911
912 <tr>
913 <th>Name</th>
914 <th>Format</th>
915 <th>Description</th>
916 </tr>
917
918 <tr>
919 <td>GTID_FLAGS</td>
920 <td>1 byte</td>
921 <td>00000001 = Transaction may have changes logged with SBR.
922 In 5.6, 5.7.0-5.7.18, and 8.0.0-8.0.1, this flag is always set.
923 Starting in 5.7.19 and 8.0.2, this flag is cleared if the transaction
924 only contains row events. It is set if any part of the transaction is
925 written in statement format.</td>
926 </tr>
927 <tr>
928 <td>SID</td>
929 <td>16 byte sequence</td>
930 <td>UUID representing the SID</td>
931 </tr>
932 <tr>
933 <td>GNO</td>
934 <td>8 byte integer</td>
935 <td>Group number, second component of GTID.</td>
936 </tr>
937 <tr>
938 <td>logical clock timestamp typecode</td>
939 <td>1 byte integer</td>
940 <td>The type of logical timestamp used in the logical clock fields.</td>
941 </tr>
942 <tr>
943 <td>last_committed</td>
944 <td>8 byte integer</td>
945 <td>Store the transaction's commit parent sequence_number</td>
946 </tr>
947 <tr>
948 <td>sequence_number</td>
949 <td>8 byte integer</td>
950 <td>The transaction's logical timestamp assigned at prepare phase</td>
951 </tr>
952 <tr>
953 <td>immediate_commit_timestamp</td>
954 <td>7 byte integer</td>
955 <td>Timestamp of commit on the immediate master</td>
956 </tr>
957 <tr>
958 <td>original_commit_timestamp</td>
959 <td>7 byte integer</td>
960 <td>Timestamp of commit on the originating master</td>
961 </tr>
962 <tr>
963 <td>transaction_length</td>
964 <td>1 to 9 byte integer // See net_length_size(ulonglong num)</td>
965 <td>The packed transaction's length in bytes, including the Gtid</td>
966 </tr>
967 <tr>
968 <td>immediate_server_version</td>
969 <td>4 byte integer</td>
970 <td>Server version of the immediate server</td>
971 </tr>
972 <tr>
973 <td>original_server_version</td>
974 <td>4 byte integer</td>
975 <td>Version of the server where the transaction was originally executed</td>
976 </tr>
977 </table>
978
979*/
981 public:
982 /*
983 The transaction's logical timestamps used for MTS: see
984 Transaction_ctx::last_committed and
985 Transaction_ctx::sequence_number for details.
986 Note: Transaction_ctx is in the MySQL server code.
987 */
988 long long int last_committed;
989 long long int sequence_number;
990 /** GTID flags constants */
991 unsigned const char FLAG_MAY_HAVE_SBR = 1;
992 /** Transaction might have changes logged with SBR */
994 /** Timestamp when the transaction was committed on the originating master. */
995 unsigned long long int original_commit_timestamp;
996 /** Timestamp when the transaction was committed on the nearest master. */
997 unsigned long long int immediate_commit_timestamp;
999 /** The length of the transaction in bytes. */
1000 unsigned long long int transaction_length;
1001
1002 public:
1003 /**
1004 Ctor of Gtid_event
1005
1006 The layout of the buffer is as follows
1007 <pre>
1008 +----------+---+---+-------+--------------+---------+----------+
1009 |gtid flags|SID|GNO|TS_TYPE|logical ts(:s)|commit ts|trx length|
1010 +----------+---+---+-------+------------------------+----------+
1011 </pre>
1012 TS_TYPE is from {G_COMMIT_TS2} singleton set of values
1013 Details on commit timestamps in Gtid_event(const char*...)
1014
1015 @param buf Contains the serialized event.
1016 @param fde An FDE event (see Rotate_event constructor for more info).
1017 */
1018
1019 Gtid_event(const char *buf, const Format_description_event *fde);
1020 /**
1021 Constructor.
1022 */
1023 explicit Gtid_event(long long int last_committed_arg,
1024 long long int sequence_number_arg,
1025 bool may_have_sbr_stmts_arg,
1026 unsigned long long int original_commit_timestamp_arg,
1027 unsigned long long int immediate_commit_timestamp_arg,
1028 uint32_t original_server_version_arg,
1029 uint32_t immediate_server_version_arg)
1031 last_committed(last_committed_arg),
1032 sequence_number(sequence_number_arg),
1033 may_have_sbr_stmts(may_have_sbr_stmts_arg),
1034 original_commit_timestamp(original_commit_timestamp_arg),
1035 immediate_commit_timestamp(immediate_commit_timestamp_arg),
1037 original_server_version(original_server_version_arg),
1038 immediate_server_version(immediate_server_version_arg) {}
1039#ifndef HAVE_MYSYS
1040 // TODO(WL#7684): Implement the method print_event_info and print_long_info
1041 // for all the events supported in MySQL Binlog
1042 void print_event_info(std::ostream &) override {}
1043 void print_long_info(std::ostream &) override {}
1044#endif
1045 protected:
1046 static const int ENCODED_FLAG_LENGTH = 1;
1047 static const int ENCODED_SID_LENGTH = 16; // Uuid::BYTE_LENGTH;
1048 static const int ENCODED_GNO_LENGTH = 8;
1049 /// Length of typecode for logical timestamps.
1051 /// Length of two logical timestamps.
1052 static const int LOGICAL_TIMESTAMP_LENGTH = 16;
1053 // Type code used before the logical timestamps.
1054 static const int LOGICAL_TIMESTAMP_TYPECODE = 2;
1055
1058 // Length of two timestamps (from original/immediate masters)
1061 // We use 7 bytes out of which 1 bit is used as a flag.
1062 static const int ENCODED_COMMIT_TIMESTAMP_LENGTH = 55;
1063 // Minimum and maximum lengths of transaction length field.
1064 static const int TRANSACTION_LENGTH_MIN_LENGTH = 1;
1065 static const int TRANSACTION_LENGTH_MAX_LENGTH = 9;
1066 /// Length of original_server_version
1068 /// Length of immediate_server_version
1070 /// Length of original and immediate server version
1073 // We use 4 bytes out of which 1 bit is used as a flag.
1074 static const int ENCODED_SERVER_VERSION_LENGTH = 31;
1075
1076 /* We have only original commit timestamp if both timestamps are equal. */
1081 }
1082
1083 /**
1084 We only store the immediate_server_version if both server versions are the
1085 same.
1086 */
1091 }
1092
1095
1096 /* Minimum GNO expected in a serialized GTID event */
1097 static const int64_t MIN_GNO = 1;
1098 /// One-past-the-max value of GNO
1099 static const std::int64_t GNO_END = INT64_MAX;
1100
1101 public:
1102 std::int64_t get_gno() const { return gtid_info_struct.rpl_gtid_gno; }
1104 /// Total length of post header
1105 static const int POST_HEADER_LENGTH =
1106 ENCODED_FLAG_LENGTH + /* flags */
1107 ENCODED_SID_LENGTH + /* SID length */
1108 ENCODED_GNO_LENGTH + /* GNO length */
1109 LOGICAL_TIMESTAMP_TYPECODE_LENGTH + /* length of typecode */
1110 LOGICAL_TIMESTAMP_LENGTH; /* length of two logical timestamps */
1111
1112 /*
1113 We keep the commit timestamps in the body section because they can be of
1114 variable length.
1115 On the originating master, the event has only one timestamp as the two
1116 timestamps are equal. On every other server we have two timestamps.
1117 */
1121
1122 static const int MAX_EVENT_LENGTH =
1124 /**
1125 Set the transaction length information.
1126
1127 This function should be used when the full transaction length (including
1128 the Gtid event length) is known.
1129
1130 @param transaction_length_arg The transaction length.
1131 */
1132 void set_trx_length(unsigned long long int transaction_length_arg) {
1133 transaction_length = transaction_length_arg;
1134 }
1135
1136 /** The version of the server where the transaction was originally executed */
1138 /** The version of the immediate server */
1140};
1141
1142/**
1143 @class Previous_gtids_event
1144
1145 @section Previous_gtids_event_binary_format Binary Format
1146
1147 The Post-Header for this event type is empty. The Body has two
1148 components:
1149
1150 <table>
1151 <caption>Body for Previous_gtids_event</caption>
1152
1153 <tr>
1154 <th>Name</th>
1155 <th>Format</th>
1156 <th>Description</th>
1157 </tr>
1158
1159 <tr>
1160 <td>buf</td>
1161 <td>unsigned char array</td>
1162 <td>It contains the Gtids executed in the
1163 last binary log file.</td>
1164 </tr>
1165
1166 <tr>
1167 <td>buf_size</td>
1168 <td>4 byte integer</td>
1169 <td>Size of the above buffer</td>
1170 </tr>
1171 </table>
1172*/
1174 public:
1175 /**
1176 Decodes the gtid_executed in the last binlog file
1177
1178 <pre>
1179 The buffer layout is as follows
1180 +--------------------------------------------+
1181 | Gtids executed in the last binary log file |
1182 +--------------------------------------------+
1183 </pre>
1184 @param buf Contains the serialized event.
1185 @param fde An FDE event (see Rotate_event constructor for more info).
1186 */
1187 Previous_gtids_event(const char *buf, const Format_description_event *fde);
1188 /**
1189 This is the minimal constructor, and set the
1190 type_code as PREVIOUS_GTIDS_LOG_EVENT in the header object in
1191 Binary_log_event
1192 */
1194#ifndef HAVE_MYSYS
1195 // TODO(WL#7684): Implement the method print_event_info and print_long_info
1196 // for all the events supported in MySQL Binlog
1197 void print_event_info(std::ostream &) override {}
1198 void print_long_info(std::ostream &) override {}
1199#endif
1200 protected:
1201 size_t buf_size;
1202 const unsigned char *buf;
1203};
1204
1205/**
1206 @class Transaction_context_event
1207
1208 This class is used to combine the information of the ongoing transaction
1209 including the write set and other information of the thread executing the
1210 transaction.
1211
1212 <tr>
1213 <th>Name</th>
1214 <th>Format</th>
1215 <th>Description</th>
1216 </tr>
1217
1218 <tr>
1219 <td>thread_id</td>
1220 <td>4 byte integer</td>
1221 <td>The identifier for the thread executing the transaction.</td>
1222 </tr>
1223
1224 <tr>
1225 <td>gtid_specified</td>
1226 <td>bool type variable</td>
1227 <td>Variable to identify whether the Gtid have been specified for the
1228 ongoing transaction or not.
1229 </td>
1230 </tr>
1231
1232 <tr>
1233 <td>encoded_snapshot_version</td>
1234 <td>unsigned char array</td>
1235 <td>A gtid_set which is used to store the transaction set used for
1236 conflict detection.</td>
1237 </tr>
1238
1239 <tr>
1240 <td>encoded_snapshot_version_length</td>
1241 <td>4 byte integer</td>
1242 <td>Length of the above char array.</td>
1243 </tr>
1244
1245 <tr>
1246 <td>write_set</td>
1247 <td>variable length list to store the hash values. </td>
1248 <td>Used to store the hash values of the rows identifier for the rows
1249 which have changed in the ongoing transaction.
1250 </td>
1251 </tr>
1252
1253 <tr>
1254 <td>read_set</td>
1255 <td>variable length list to store the read set values. Currently empty.
1256 </td> <td>Will be used to store the read set values of the current
1257 transaction.</td>
1258 </tr>
1259
1260*/
1262 public:
1263 /**
1264 Decodes the transaction_context_log_event of the ongoing transaction.
1265
1266 <pre>
1267 The buffer layout is as follows
1268 </pre>
1269
1270 @param buf Contains the serialized event.
1271 @param fde An FDE event (see Rotate_event constructor for more info).
1272 */
1273 Transaction_context_event(const char *buf,
1274 const Format_description_event *fde);
1275
1276 Transaction_context_event(unsigned int thread_id_arg,
1277 bool is_gtid_specified_arg)
1279 thread_id(thread_id_arg),
1280 gtid_specified(is_gtid_specified_arg) {}
1281
1282 ~Transaction_context_event() override;
1283
1284 static const char *read_data_set(const char *pos, uint32_t set_len,
1285 std::list<const char *> *set,
1286 uint32_t remaining_buffer);
1287
1288 static void clear_set(std::list<const char *> *set);
1289
1290#ifndef HAVE_MYSYS
1291 void print_event_info(std::ostream &) override {}
1292 void print_long_info(std::ostream &) override {}
1293#endif
1294
1295 protected:
1296 const char *server_uuid;
1297 uint32_t thread_id;
1299 const unsigned char *encoded_snapshot_version;
1301 std::list<const char *> write_set;
1302 std::list<const char *> read_set;
1303
1304 // The values mentioned on the next class constants is the offset where the
1305 // data that will be copied in the buffer.
1306
1307 // 1 byte length.
1309 // 4 bytes length.
1310 static const int ENCODED_THREAD_ID_OFFSET = 1;
1311 // 1 byte length.
1312 static const int ENCODED_GTID_SPECIFIED_OFFSET = 5;
1313 // 4 bytes length
1315 // 4 bytes length.
1316 static const int ENCODED_WRITE_SET_ITEMS_OFFSET = 10;
1317 // 4 bytes length.
1318 static const int ENCODED_READ_SET_ITEMS_OFFSET = 14;
1319
1320 // The values mentioned on the next class's constants is the length of the
1321 // data that will be copied in the buffer.
1323 static const int ENCODED_SNAPSHOT_VERSION_LEN = 2;
1324};
1325
1326/**
1327 @class View_change_event
1328
1329 This class is used to add view change markers in the binary log when a
1330 member of the group enters or leaves the group.
1331
1332 <tr>
1333 <th>Name</th>
1334 <th>Format</th>
1335 <th>Description</th>
1336 </tr>
1337
1338 <tr>
1339 <td>view_id</td>
1340 <td>40 length character array</td>
1341 <td>This is used to store the view id value of the new view change when a
1342 node add or leaves the group.
1343 </td>
1344 </tr>
1345
1346 <tr>
1347 <td>seq_number</td>
1348 <td>8 bytes integer</td>
1349 <td>Variable to identify the next sequence number to be allotted to the
1350 certified transaction.</td>
1351 </tr>
1352
1353 <tr>
1354 <td>certification_info</td>
1355 <td>variable length map to store the certification data.</td>
1356 <td>Map to store the certification info ie. the hash of write_set and the
1357 snapshot sequence value.
1358 </td>
1359 </tr>
1360
1361*/
1363 public:
1364 /**
1365 Decodes the view_change_log_event generated in case a server enters or
1366 leaves the group.
1367
1368 <pre>
1369 The buffer layout is as follows
1370 </pre>
1371
1372 @param buf Contains the serialized event.
1373 @param fde An FDE event (see Rotate_event constructor for more info).
1374 */
1375 View_change_event(const char *buf, const Format_description_event *fde);
1376
1377 explicit View_change_event(const char *raw_view_id);
1378
1379 ~View_change_event() override;
1380
1381#ifndef HAVE_MYSYS
1382 void print_event_info(std::ostream &) override {}
1383 void print_long_info(std::ostream &) override {}
1384#endif
1385
1386 protected:
1387 // The values mentioned on the next class constants is the offset where the
1388 // data that will be copied in the buffer.
1389
1390 // 40 bytes length.
1391 static const int ENCODED_VIEW_ID_OFFSET = 0;
1392 // 8 bytes length.
1393 static const int ENCODED_SEQ_NUMBER_OFFSET = 40;
1394 // 4 bytes length.
1395 static const int ENCODED_CERT_INFO_SIZE_OFFSET = 48;
1396
1397 /*
1398 The layout of the buffer is as follows
1399 +--------------------- -+-------------+----------+
1400 | View Id | seq number | map size |
1401 +-----------------------+-------------+----------+
1402 view id (40 bytes) + seq number (8 bytes) + map size (4 bytes)
1403 Sum of the length of the values at the above OFFSETS.
1404 */
1405
1406 // The values mentioned on the next class constants is the length of the data
1407 // that will be copied in the buffer.
1408
1409 // Field sizes on serialization
1410 static const int ENCODED_VIEW_ID_MAX_LEN = 40;
1412 static const int ENCODED_CERT_INFO_VALUE_LEN = 4;
1413
1415
1416 long long int seq_number;
1417
1418 std::map<std::string, std::string> certification_info;
1419};
1420
1421/**
1422 @class Heartbeat_event_v2
1423
1424 Replication event to ensure to replica that source is alive.
1425 The event is originated by source's dump thread and sent straight to
1426 replica without being logged. Slave itself does not store it in relay log
1427 but rather uses a data for immediate checks and throws away the event.
1428
1429 Two members of the class m_log_filename and m_log_position comprise
1430 @see the rpl_event_coordinates instance. The coordinates that a heartbeat
1431 instance carries correspond to the last event source has sent from
1432 its binlog.
1433
1434 Also this event will be generated only for the source server with
1435 version > 8.0.26
1436
1437 @section Heartbeat_event_v2_binary_format Binary Format
1438
1439 The Body has one component:
1440
1441 <table>
1442 <caption>Body for Heartbeat_event</caption>
1443
1444 <tr>
1445 <th>Name</th>
1446 <th>Format</th>
1447 <th>Description</th>
1448 </tr>
1449
1450 <tr>
1451 <td>m_log_filename</td>
1452 <td>String variable to store the binlog name</td>
1453 <td>Name of the current binlog being written to.</td>
1454 </tr>
1455 <tr>
1456 <td>m_log_pos</td>
1457 <td>8 byte unsigned integar</td>
1458 <td>Name of the current binlog being written to.</td>
1459 </tr>
1460 </table>
1461*/
1462
1464 public:
1465 /**
1466 Sent by a source to a replica to let the replica know that the source is
1467 still alive. Events of this type do not appear in the binary or relay logs.
1468 They are generated on a source server by the thread that dumps events and
1469 sent straight to the replica without ever being written to the binary log.
1470
1471 @param buf Contains the serialized event.
1472 @param fde An FDE event (see Rotate_event constructor for more info).
1473 */
1474 Heartbeat_event_v2(const char *buf, const Format_description_event *fde);
1475
1476 /**
1477 Creates an empty heartbeat event.
1478 */
1480
1481 virtual ~Heartbeat_event_v2() override = default;
1482
1483 // Set the binlog filename
1484 void set_log_filename(const std::string name);
1485 // Set the position
1486 void set_log_position(uint64_t position);
1487 // Return the binlog filename
1488 const std::string get_log_filename() const;
1489 // Return the position
1490 uint64_t get_log_position() const;
1491
1492 // Return the max length of an encoded packet.
1493 static uint64_t max_encoding_length();
1494#ifndef HAVE_MYSYS
1495 virtual void print_event_info(std::ostream &info) override;
1496 virtual void print_long_info(std::ostream &info) override;
1497#endif
1498 protected:
1499 std::string m_log_filename{};
1500 uint64_t m_log_position{0};
1501};
1502
1503/**
1504 @class Heartbeat_event
1505
1506 Replication event to ensure to replica that source is alive.
1507 The event is originated by source's dump thread and sent straight to
1508 replica without being logged. Slave itself does not store it in relay log
1509 but rather uses a data for immediate checks and throws away the event.
1510
1511 Two members of the class log_ident and Binary_log_event::log_pos comprise
1512 @see the rpl_event_coordinates instance. The coordinates that a heartbeat
1513 instance carries correspond to the last event source has sent from
1514 its binlog.
1515
1516 @section Heartbeat_event_binary_format Binary Format
1517
1518 The Body has one component:
1519
1520 <table>
1521 <caption>Body for Heartbeat_event</caption>
1522
1523 <tr>
1524 <th>Name</th>
1525 <th>Format</th>
1526 <th>Description</th>
1527 </tr>
1528
1529 <tr>
1530 <td>log_ident</td>
1531 <td>variable length string without trailing zero, extending to the
1532 end of the event</td>
1533 <td>Name of the current binlog being written to.</td>
1534 </tr>
1535 </table>
1536*/
1538 public:
1539 /**
1540 Sent by a source to a replica to let the replica know that the source is
1541 still alive. Events of this type do not appear in the binary or relay logs.
1542 They are generated on a source server by the thread that dumps events and
1543 sent straight to the replica without ever being written to the binary log.
1544
1545 @param buf Contains the serialized event.
1546 @param fde An FDE event (see Rotate_event constructor for more info).
1547 */
1548 Heartbeat_event(const char *buf, const Format_description_event *fde);
1549
1550 // Return the file name
1551 const char *get_log_ident() { return log_ident; }
1552 // Return the length of file name
1553 unsigned int get_ident_len() { return ident_len; }
1554
1555 protected:
1556 const char *log_ident;
1557 unsigned int ident_len; /** filename length */
1558};
1559
1560} // end namespace binary_log
1561/**
1562 @} (end of group Replication)
1563*/
1564#endif /* CONTROL_EVENTS_INCLUDED */
Contains the classes representing events occurring in the replication stream.
#define LOG_EVENT_HEADER_LEN
Definition: binlog_event.h:398
#define LOG_EVENT_MINIMAL_HEADER_LEN
Fixed header length, where 4.x and 5.0 agree.
Definition: binlog_event.h:407
#define ST_SERVER_VER_LEN
The length of the array server_version, which is used to store the version of MySQL server.
Definition: binlog_event.h:380
This is the abstract base class for binary log events.
Definition: binlog_event.h:798
For binlog version 4.
Definition: control_events.h:230
unsigned char server_version_split[ST_SERVER_VER_SPLIT_LEN]
Definition: control_events.h:272
Format_description_event(const Format_description_event &)=default
uint8_t number_of_event_types
Definition: control_events.h:316
char server_version[ST_SERVER_VER_LEN]
Definition: control_events.h:253
Format_description_event(uint8_t binlog_ver, const char *server_ver)
Format_description_event 1st constructor.
Definition: control_events.cpp:70
bool is_version_before_checksum() const
This method checks the MySQL version to determine whether checksums may be present in the events cont...
Definition: control_events.cpp:169
bool dont_set_created
Definition: control_events.h:258
bool version_is_valid() const
Definition: control_events.h:349
Format_description_event & operator=(const Format_description_event &)=default
uint8_t common_header_len
The size of the fixed header which all events have (for binlogs written by this version,...
Definition: control_events.h:266
unsigned long get_product_version() const
This method is used to find out the version of server that originated the current FD instance.
Definition: control_events.cpp:157
void calc_server_version_split()
This method populates the array server_version_split which is then used for lookups to find if the se...
Definition: control_events.cpp:148
std::vector< uint8_t > post_header_len
Definition: control_events.h:271
uint16_t binlog_version
Definition: control_events.h:252
time_t created
If this event is at the start of the first binary log since server startup 'created' should be the ti...
Definition: control_events.h:251
bool header_is_valid() const
Definition: control_events.h:344
GTID stands for Global Transaction IDentifier It is composed of two parts:
Definition: control_events.h:980
long long int sequence_number
Definition: control_events.h:989
static const int POST_HEADER_LENGTH
Total length of post header.
Definition: control_events.h:1105
static const int LOGICAL_TIMESTAMP_TYPECODE_LENGTH
Length of typecode for logical timestamps.
Definition: control_events.h:1050
static const int ENCODED_GNO_LENGTH
Definition: control_events.h:1048
static const int LOGICAL_TIMESTAMP_TYPECODE
Definition: control_events.h:1054
static const int ENCODED_SERVER_VERSION_LENGTH
Definition: control_events.h:1074
bool may_have_sbr_stmts
Transaction might have changes logged with SBR.
Definition: control_events.h:993
static const int ORIGINAL_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1057
static const int TRANSACTION_LENGTH_MIN_LENGTH
Definition: control_events.h:1064
Uuid get_uuid() const
Definition: control_events.h:1103
uint32_t original_server_version
The version of the server where the transaction was originally executed.
Definition: control_events.h:1137
unsigned long long int original_commit_timestamp
Timestamp when the transaction was committed on the originating master.
Definition: control_events.h:995
static const int ORIGINAL_SERVER_VERSION_LENGTH
Length of original_server_version.
Definition: control_events.h:1067
unsigned long long int immediate_commit_timestamp
Timestamp when the transaction was committed on the nearest master.
Definition: control_events.h:997
static const int ENCODED_SID_LENGTH
Definition: control_events.h:1047
int get_server_version_length() const
We only store the immediate_server_version if both server versions are the same.
Definition: control_events.h:1087
static const int FULL_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1059
std::int64_t get_gno() const
Definition: control_events.h:1102
static const int TRANSACTION_LENGTH_MAX_LENGTH
Definition: control_events.h:1065
static const int FULL_SERVER_VERSION_LENGTH
Length of original and immediate server version.
Definition: control_events.h:1071
gtid_info gtid_info_struct
Definition: control_events.h:1093
static const int ENCODED_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1062
static const int IMMEDIATE_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1056
uint32_t immediate_server_version
The version of the immediate server.
Definition: control_events.h:1139
Gtid_event(const char *buf, const Format_description_event *fde)
Ctor of Gtid_event.
Definition: control_events.cpp:419
int get_commit_timestamp_length() const
Definition: control_events.h:1077
static const int64_t MIN_GNO
Definition: control_events.h:1097
unsigned const char FLAG_MAY_HAVE_SBR
GTID flags constants.
Definition: control_events.h:991
bool has_commit_timestamps
Definition: control_events.h:998
long long int last_committed
Definition: control_events.h:988
Gtid_event(long long int last_committed_arg, long long int sequence_number_arg, bool may_have_sbr_stmts_arg, unsigned long long int original_commit_timestamp_arg, unsigned long long int immediate_commit_timestamp_arg, uint32_t original_server_version_arg, uint32_t immediate_server_version_arg)
Constructor.
Definition: control_events.h:1023
static const int IMMEDIATE_SERVER_VERSION_LENGTH
Length of immediate_server_version.
Definition: control_events.h:1069
static const int MAX_DATA_LENGTH
Definition: control_events.h:1118
static const int MAX_EVENT_LENGTH
Definition: control_events.h:1122
static const int ENCODED_FLAG_LENGTH
Definition: control_events.h:1046
Uuid Uuid_parent_struct
Definition: control_events.h:1094
unsigned long long int transaction_length
The length of the transaction in bytes.
Definition: control_events.h:1000
static const int LOGICAL_TIMESTAMP_LENGTH
Length of two logical timestamps.
Definition: control_events.h:1052
void set_trx_length(unsigned long long int transaction_length_arg)
Set the transaction length information.
Definition: control_events.h:1132
static const std::int64_t GNO_END
One-past-the-max value of GNO.
Definition: control_events.h:1099
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1463
void set_log_position(uint64_t position)
Definition: control_events.cpp:720
uint64_t get_log_position() const
Definition: control_events.cpp:726
uint64_t m_log_position
Definition: control_events.h:1500
static uint64_t max_encoding_length()
This member function returns the len of the event.
Definition: control_events.cpp:733
virtual ~Heartbeat_event_v2() override=default
const std::string get_log_filename() const
Definition: control_events.cpp:723
std::string m_log_filename
Definition: control_events.h:1499
Heartbeat_event_v2()
Creates an empty heartbeat event.
Definition: control_events.cpp:714
void set_log_filename(const std::string name)
Definition: control_events.cpp:717
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1537
unsigned int ident_len
Definition: control_events.h:1557
const char * log_ident
Definition: control_events.h:1556
unsigned int get_ident_len()
Definition: control_events.h:1553
const char * get_log_ident()
Definition: control_events.h:1551
Heartbeat_event(const char *buf, const Format_description_event *fde)
Sent by a source to a replica to let the replica know that the source is still alive.
Definition: control_events.cpp:679
Base class for ignorable log events.
Definition: control_events.h:665
Ignorable_event(Log_event_type type_arg=IGNORABLE_LOG_EVENT)
The minimal constructor and all it will do is set the type_code as IGNORABLE_LOG_EVENT in the header ...
Definition: control_events.h:674
Class representing an incident, an occurrence out of the ordinary, that happened on the master.
Definition: control_events.h:431
enum_incident get_incident_type()
Definition: control_events.h:445
size_t message_length
Definition: control_events.h:483
Incident_event(enum_incident incident_arg)
This will create an Incident_event with an empty message and set the type_code as INCIDENT_EVENT in t...
Definition: control_events.h:452
enum_incident incident
Definition: control_events.h:481
char * get_message()
Definition: control_events.h:446
char * message
Definition: control_events.h:482
enum_incident
Enumeration of the incidents that can occur for the server.
Definition: control_events.h:436
@ INCIDENT_LOST_EVENTS
There are possibly lost events in the replication stream.
Definition: control_events.h:440
@ INCIDENT_COUNT
Shall be last event of the enumeration.
Definition: control_events.h:442
@ INCIDENT_NONE
No incident.
Definition: control_events.h:438
Definition: control_events.h:1173
size_t buf_size
Definition: control_events.h:1201
const unsigned char * buf
Definition: control_events.h:1202
Previous_gtids_event()
This is the minimal constructor, and set the type_code as PREVIOUS_GTIDS_LOG_EVENT in the header obje...
Definition: control_events.h:1193
When a binary log file exceeds a size limit, a ROTATE_EVENT is written at the end of the file that po...
Definition: control_events.h:107
size_t ident_len
Definition: control_events.h:110
uint64_t pos
Definition: control_events.h:112
unsigned int flags
Definition: control_events.h:111
const char * new_log_ident
Definition: control_events.h:109
~Rotate_event() override
Definition: control_events.h:162
Rotate_event(const char *new_log_ident_arg, size_t ident_len_arg, unsigned int flags_arg, uint64_t pos_arg)
This is the minimal constructor, it will set the type code as ROTATE_EVENT.
Definition: control_events.h:129
@ RELAY_LOG
Definition: control_events.h:117
@ DUP_NAME
Definition: control_events.h:116
@ R_POS_OFFSET
Definition: control_events.h:122
@ R_IDENT_OFFSET
Definition: control_events.h:123
A stop event is written to the log files under these circumstances:
Definition: control_events.h:370
Stop_event()
It is the minimal constructor, and all it will do is set the type_code as STOP_EVENT in the header ob...
Definition: control_events.h:376
This class is used to combine the information of the ongoing transaction including the write set and ...
Definition: control_events.h:1261
static const int ENCODED_SNAPSHOT_VERSION_LEN_OFFSET
Definition: control_events.h:1314
uint32_t encoded_snapshot_version_length
Definition: control_events.h:1300
static const char * read_data_set(const char *pos, uint32_t set_len, std::list< const char * > *set, uint32_t remaining_buffer)
static const int ENCODED_THREAD_ID_OFFSET
Definition: control_events.h:1310
static const int ENCODED_SERVER_UUID_LEN_OFFSET
Definition: control_events.h:1308
const unsigned char * encoded_snapshot_version
Definition: control_events.h:1299
std::list< const char * > write_set
Definition: control_events.h:1301
Transaction_context_event(unsigned int thread_id_arg, bool is_gtid_specified_arg)
Definition: control_events.h:1276
static const int ENCODED_GTID_SPECIFIED_OFFSET
Definition: control_events.h:1312
static const int ENCODED_READ_WRITE_SET_ITEM_LEN
Definition: control_events.h:1322
std::list< const char * > read_set
Definition: control_events.h:1302
const char * server_uuid
Definition: control_events.h:1296
Transaction_context_event(const char *buf, const Format_description_event *fde)
Decodes the transaction_context_log_event of the ongoing transaction.
Definition: control_events.cpp:585
static const int ENCODED_READ_SET_ITEMS_OFFSET
Definition: control_events.h:1318
static void clear_set(std::list< const char * > *set)
Function to clear the memory of the write_set and the read_set.
Definition: control_events.cpp:623
uint32_t thread_id
Definition: control_events.h:1297
bool gtid_specified
Definition: control_events.h:1298
~Transaction_context_event() override
Destructor of the Transaction_context_event class.
Definition: control_events.cpp:633
static const int ENCODED_SNAPSHOT_VERSION_LEN
Definition: control_events.h:1323
static const int ENCODED_WRITE_SET_ITEMS_OFFSET
Definition: control_events.h:1316
This event is a wrapper event and encloses many other events.
Definition: control_events.h:729
uint64_t m_uncompressed_size
The size of the data uncompressed.
Definition: control_events.h:760
const char * m_payload
The raw bytes which are the data that this event contains.
Definition: control_events.h:739
static const int MAX_DATA_LENGTH
Definition: control_events.h:770
uint64_t m_payload_size
The size of the data.
Definition: control_events.h:744
static const unsigned short COMPRESSION_TYPE_MIN_LENGTH
Definition: control_events.h:763
uint64_t get_payload_size() const
Shall get the size of the payload inside this event.
Definition: control_events.h:848
static const unsigned short UNCOMPRESSED_SIZE_MAX_LENGTH
Definition: control_events.h:768
static const unsigned short PAYLOAD_SIZE_MIN_LENGTH
Definition: control_events.h:765
void set_compression_type(transaction::compression::type type)
Shall set the compression type used for the enclosed payload.
Definition: control_events.h:823
transaction::compression::type get_compression_type() const
Shall return the compression type used for the enclosed payload.
Definition: control_events.h:832
uint64_t get_uncompressed_size() const
Shall get the uncompressed size of the event.
Definition: control_events.h:862
static const unsigned short PAYLOAD_SIZE_MAX_LENGTH
Definition: control_events.h:766
const char * get_payload() const
Shall get the payload of the event.
Definition: control_events.h:876
void set_uncompressed_size(uint64_t size)
Shall set the uncompressed size of the payload.
Definition: control_events.h:855
void set_payload(const char *data)
Shall set the payload of the event.
Definition: control_events.h:869
Transaction_payload_event & operator=(const Transaction_payload_event &)=delete
static const unsigned short COMPRESSION_TYPE_MAX_LENGTH
Definition: control_events.h:764
std::string to_string() const
Shall return a textual representation of this event.
Definition: control_events.cpp:396
void set_payload_size(uint64_t size)
Shall set the size of the payload inside this event.
Definition: control_events.h:841
transaction::compression::type m_compression_type
If the data is compressed, which compression was used.
Definition: control_events.h:753
Transaction_payload_event(const Transaction_payload_event &)=delete
static const unsigned short UNCOMPRESSED_SIZE_MIN_LENGTH
Definition: control_events.h:767
~Transaction_payload_event() override
This destroys the transaction payload event.
This class is used to add view change markers in the binary log when a member of the group enters or ...
Definition: control_events.h:1362
static const int ENCODED_CERT_INFO_KEY_SIZE_LEN
Definition: control_events.h:1411
View_change_event(const char *buf, const Format_description_event *fde)
Decodes the view_change_log_event generated in case a server enters or leaves the group.
Definition: control_events.cpp:652
static const int ENCODED_SEQ_NUMBER_OFFSET
Definition: control_events.h:1393
char view_id[ENCODED_VIEW_ID_MAX_LEN]
Definition: control_events.h:1414
static const int ENCODED_CERT_INFO_SIZE_OFFSET
Definition: control_events.h:1395
static const int ENCODED_CERT_INFO_VALUE_LEN
Definition: control_events.h:1412
static const int ENCODED_VIEW_ID_MAX_LEN
Definition: control_events.h:1410
std::map< std::string, std::string > certification_info
Definition: control_events.h:1418
static const int ENCODED_VIEW_ID_OFFSET
Definition: control_events.h:1391
long long int seq_number
Definition: control_events.h:1416
~View_change_event() override
Destructor of the View_change_event class.
Definition: control_events.cpp:677
An XA_prepare event is generated for a XA prepared transaction.
Definition: control_events.h:579
MY_XID const & get_xid() const
Retrieves the content of my_xid member variable.
Definition: control_events.cpp:353
MY_XID my_xid
Definition: control_events.h:598
void * xid
Definition: control_events.h:599
XA_prepare_event(void *xid_arg, bool oph_arg)
The minimal constructor of XA_prepare_event, it initializes the instance variable xid and set the typ...
Definition: control_events.h:608
bool one_phase
Definition: control_events.h:600
static const int MY_XIDDATASIZE
Definition: control_events.h:584
static const uint16_t ser_buf_size
Definition: control_events.h:596
bool is_one_phase() const
Whether or not this XA_prepare_event represents an XA COMMIT ONE PHASE.
Definition: control_events.cpp:351
An XID event is generated for a commit of a transaction that modifies one or more tables of an XA-cap...
Definition: control_events.h:514
uint64_t xid
Definition: control_events.h:531
Xid_event(uint64_t xid_arg)
The minimal constructor of Xid_event, it initializes the instance variable xid and set the type_code ...
Definition: control_events.h:521
char * pos
Definition: do_ctype.cc:76
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
#define ST_SERVER_VER_SPLIT_LEN
Definition: binlog_event.h:76
Log info(cout, "NOTE")
The namespace contains classes representing events that can occur in a replication stream.
Log_event_type
Enumeration type for the different types of log events.
Definition: binlog_event.h:266
@ XA_PREPARE_LOG_EVENT
Definition: binlog_event.h:341
@ IGNORABLE_LOG_EVENT
In some situations, it is necessary to send over ignorable data to the slave: data that a slave can h...
Definition: binlog_event.h:323
@ PREVIOUS_GTIDS_LOG_EVENT
Definition: binlog_event.h:334
@ TRANSACTION_CONTEXT_EVENT
Definition: binlog_event.h:336
@ INCIDENT_EVENT
Something out of the ordinary happened on the master.
Definition: binlog_event.h:309
@ GTID_LOG_EVENT
Definition: binlog_event.h:331
@ ROTATE_EVENT
Definition: binlog_event.h:282
@ XID_EVENT
Definition: binlog_event.h:293
@ STOP_EVENT
Definition: binlog_event.h:281
Definition: buf0block_hint.cc:29
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2863
required string type
Definition: replication_group_member_actions.proto:33
case opt name
Definition: sslopt-case.h:32
This is a POD.
Definition: uuid.h:60
Definition: control_events.h:587
long gtrid_length
Definition: control_events.h:589
long bqual_length
Definition: control_events.h:590
char data[MY_XIDDATASIZE]
Definition: control_events.h:591
long formatID
Definition: control_events.h:588
Structure to hold the members declared in the class Gtid_log_event those member are objects of classe...
Definition: control_events.h:717
int64_t rpl_gtid_gno
Definition: control_events.h:719
int32_t rpl_gtid_sidno
Definition: control_events.h:718
Include file for Sun RPC to compile out of the box.
void bapi_free(void *ptr)
This is a wrapper function in order to free the memory allocated from the heap in the binlogevent lib...
Definition: wrapper_functions.h:189