MySQL 8.0.29
Source Code Documentation
control_events.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2021, 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 squence.
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 decription 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 occurance 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 contans 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 struct MY_XID {
590 char data[MY_XIDDATASIZE]; /* Not \0-terminated */
591 };
592
593 protected:
594 /* size of serialization buffer is explained in $MYSQL/sql/xa.h. */
595 static const uint16_t ser_buf_size =
596 8 + 2 * MY_XIDDATASIZE + 4 * sizeof(long) + 1;
598 void *xid; /* Master side only */
600
601 public:
602 /**
603 The minimal constructor of XA_prepare_event, it initializes the
604 instance variable xid and set the type_code as XID_EVENT in the
605 header object in Binary_log_event
606 */
607 XA_prepare_event(void *xid_arg, bool oph_arg)
609 xid(xid_arg),
610 one_phase(oph_arg) {}
611
612 /**
613 An XID event is generated for a commit of a transaction that modifies one or
614 more tables of an XA-capable storage engine
615 @param buf Contains the serialized event.
616 @param fde An FDE event (see Rotate_event constructor for more info).
617 */
618 XA_prepare_event(const char *buf, const Format_description_event *fde);
619#ifndef HAVE_MYSYS
620 /*
621 todo: we need to find way how to exploit server's code of
622 serialize_xid()
623 */
624 void print_event_info(std::ostream &) override {}
625 void print_long_info(std::ostream &) override {}
626#endif
627};
628
629/**
630 @class Ignorable_event
631
632 Base class for ignorable log events. Events deriving from
633 this class can be safely ignored by slaves that cannot
634 recognize them. Newer slaves, will be able to read and
635 handle them. This has been designed to be an open-ended
636 architecture, so adding new derived events shall not harm
637 the old slaves that support ignorable log event mechanism
638 (they will just ignore unrecognized ignorable events).
639
640 @note The only thing that makes an event ignorable is that it has
641 the LOG_EVENT_IGNORABLE_F flag set. It is not strictly necessary
642 that ignorable event types derive from Ignorable_event; they may
643 just as well derive from Binary_log_event and Log_event and pass
644 LOG_EVENT_IGNORABLE_F as argument to the Log_event constructor.
645
646 @section Ignoarble_event_binary_format Binary format
647
648 The Post-Header and Body for this event type are empty; it only has
649 the Common-Header.
650*/
652 public:
653 // buf is advanced in Binary_log_event constructor to point to beginning of
654 // post-header
655
656 /**
657 The minimal constructor and all it will do is set the type_code as
658 IGNORABLE_LOG_EVENT in the header object in Binary_log_event.
659 */
661 : Binary_log_event(type_arg) {}
662 /**
663 @param buf Contains the serialized event.
664 @param fde An FDE event (see Rotate_event constructor for more info).
665 */
666 Ignorable_event(const char *buf, const Format_description_event *fde);
667#ifndef HAVE_MYSYS
668 void print_event_info(std::ostream &) override {}
669 void print_long_info(std::ostream &) override {}
670#endif
671};
672
673/**
674 @struct gtid_info
675 Structure to hold the members declared in the class Gtid_log_event those
676 member are objects of classes defined in server(rpl_gtid.h). As we can not
677 move all the classes defined there(in rpl_gtid.h) in libbinlogevents so this
678 structure was created, to provide a way to map the decoded value in Gtid_event
679 ctor and the class members defined in rpl_gtid.h, these classes are also the
680 members of Gtid_log_event(subclass of this in server code)
681
682 The structure contains the following components.
683 <table>
684 <caption>Structure gtid_info</caption>
685
686 <tr>
687 <th>Name</th>
688 <th>Format</th>
689 <th>Description</th>
690 </tr>
691 <tr>
692 <td>rpl_gtid_sidno</td>
693 <td>4 bytes integer</td>
694 <td>SIDNO (source ID number, first component of GTID)</td>
695 </tr>
696 <tr>
697 <td>rpl_gtid_gno</td>
698 <td>8 bytes integer</td>
699 <td>GNO (group number, second component of GTID)</td>
700 </tr>
701 </table>
702*/
703struct gtid_info {
706};
707
708/**
709 This event is a wrapper event and encloses many other events.
710
711 It is mostly used for carrying compressed payloads as its content
712 can be compressed, in which case, its metadata shall contain
713 information about the compression metadata as well.
714 */
716 private:
718 delete;
720
721 protected:
722 /**
723 The raw bytes which are the data that this event contains.
724 */
725 const char *m_payload{nullptr};
726
727 /**
728 The size of the data.
729 */
730 uint64_t m_payload_size{0};
731
732 /**
733 If the data is compressed, which compression was used.
734
735 For now, the only compressors supported are: ZSTD or NONE.
736
737 NONE means no compression at all. ZSTD means using ZSTD compression.
738 */
741
742 /**
743 The size of the data uncompressed. This is the same as @c m_payload_size if
744 there is no compression involved.
745 */
747
748 public:
749 static const unsigned short COMPRESSION_TYPE_MIN_LENGTH = 1;
750 static const unsigned short COMPRESSION_TYPE_MAX_LENGTH = 9;
751 static const unsigned short PAYLOAD_SIZE_MIN_LENGTH = 0;
752 static const unsigned short PAYLOAD_SIZE_MAX_LENGTH = 9;
753 static const unsigned short UNCOMPRESSED_SIZE_MIN_LENGTH = 0;
754 static const unsigned short UNCOMPRESSED_SIZE_MAX_LENGTH = 9;
755
759 /**
760 Creates @c Transaction_payload_event with the given data which has the
761 given size.
762
763 @param payload the data that this event shall wrap.
764 @param payload_size the size of the payload.
765
766 The data shall not be compressed. However, there is no other validation
767 that this is the case.
768 */
769 Transaction_payload_event(const char *payload, uint64_t payload_size);
770
771 /**
772 Creates @c Transaction_payload_event with the given data which has the
773 given size. The data provided may or may not have been compressed. In
774 any case the compression_type must be set.
775
776 @param payload the data that this event shall wrap.
777 @param payload_size the size of the payload.
778 @param compression_type the compression type used for the data provided.
779 @param uncompressed_size the size of the data when uncompressed.
780
781 The data may or may not be compressed. There is no validation or check
782 that it is or that the payload matches the metadata provided.
783 */
784 Transaction_payload_event(const char *payload, uint64_t payload_size,
785 uint16_t compression_type,
786 uint64_t uncompressed_size);
787
788 /**
789 This constructor takes a raw buffer and a format descriptor event and
790 decodes the buffer. It populates this event metadata with the contents
791 of the buffer.
792
793 @param buf the buffer to decode.
794 @param fde the format description event used to decode the buffer.
795 */
796 Transaction_payload_event(const char *buf,
797 const Format_description_event *fde);
798
799 /**
800 This destroys the transaction payload event.
801 */
803
804 /**
805 Shall set the compression type used for the enclosed payload.
806
807 @param type the compression type.
808 */
811 }
812
813 /**
814 Shall return the compression type used for the enclosed payload.
815
816 @return the compression type.
817 */
819 return m_compression_type;
820 }
821
822 /**
823 Shall set the size of the payload inside this event.
824
825 @param size The payload size.
826 */
827 void set_payload_size(uint64_t size) { m_payload_size = size; }
828
829 /**
830 Shall get the size of the payload inside this event.
831
832 @return The payload size.
833 */
834 uint64_t get_payload_size() const { return m_payload_size; }
835
836 /**
837 Shall set the uncompressed size of the payload.
838
839 @param size the uncompressed size of the payload.
840 */
841 void set_uncompressed_size(uint64_t size) { m_uncompressed_size = size; }
842
843 /**
844 Shall get the uncompressed size of the event.
845
846 @return uncompressed_size.
847 */
848 uint64_t get_uncompressed_size() const { return m_uncompressed_size; }
849
850 /**
851 Shall set the payload of the event.
852
853 @param data the payload of the event.
854 */
855 void set_payload(const char *data) { m_payload = data; }
856
857 /**
858 Shall get the payload of the event.
859
860 @return the payload of the event.
861 */
862 const char *get_payload() const { return m_payload; }
863
864 /**
865 Shall return a textual representation of this event.
866
867 @return a textial representation of this event.
868 */
869 std::string to_string() const;
870
871#ifndef HAVE_MYSYS
872 virtual void print_event_info(std::ostream &) override;
873 virtual void print_long_info(std::ostream &) override;
874#endif
875};
876
877/**
878 @class Gtid_event
879 GTID stands for Global Transaction IDentifier
880 It is composed of two parts:
881 - SID for Source Identifier, and
882 - GNO for Group Number.
883 The basic idea is to
884 - Associate an identifier, the Global Transaction IDentifier or GTID,
885 to every transaction.
886 - When a transaction is copied to a slave, re-executed on the slave,
887 and written to the slave's binary log, the GTID is preserved.
888 - When a slave connects to a master, the slave uses GTIDs instead of
889 (file, offset)
890
891 @section Gtid_event_binary_format Binary Format
892
893 The Body can have up to nine components:
894
895 <table>
896 <caption>Body for Gtid_event</caption>
897
898 <tr>
899 <th>Name</th>
900 <th>Format</th>
901 <th>Description</th>
902 </tr>
903
904 <tr>
905 <td>GTID_FLAGS</td>
906 <td>1 byte</td>
907 <td>00000001 = Transaction may have changes logged with SBR.
908 In 5.6, 5.7.0-5.7.18, and 8.0.0-8.0.1, this flag is always set.
909 Starting in 5.7.19 and 8.0.2, this flag is cleared if the transaction
910 only contains row events. It is set if any part of the transaction is
911 written in statement format.</td>
912 </tr>
913 <tr>
914 <td>SID</td>
915 <td>16 byte sequence</td>
916 <td>UUID representing the SID</td>
917 </tr>
918 <tr>
919 <td>GNO</td>
920 <td>8 byte integer</td>
921 <td>Group number, second component of GTID.</td>
922 </tr>
923 <tr>
924 <td>logical clock timestamp typecode</td>
925 <td>1 byte integer</td>
926 <td>The type of logical timestamp used in the logical clock fields.</td>
927 </tr>
928 <tr>
929 <td>last_committed</td>
930 <td>8 byte integer</td>
931 <td>Store the transaction's commit parent sequence_number</td>
932 </tr>
933 <tr>
934 <td>sequence_number</td>
935 <td>8 byte integer</td>
936 <td>The transaction's logical timestamp assigned at prepare phase</td>
937 </tr>
938 <tr>
939 <td>immediate_commit_timestamp</td>
940 <td>7 byte integer</td>
941 <td>Timestamp of commit on the immediate master</td>
942 </tr>
943 <tr>
944 <td>original_commit_timestamp</td>
945 <td>7 byte integer</td>
946 <td>Timestamp of commit on the originating master</td>
947 </tr>
948 <tr>
949 <td>transaction_length</td>
950 <td>1 to 9 byte integer // See net_length_size(ulonglong num)</td>
951 <td>The packed transaction's length in bytes, including the Gtid</td>
952 </tr>
953 <tr>
954 <td>immediate_server_version</td>
955 <td>4 byte integer</td>
956 <td>Server version of the immediate server</td>
957 </tr>
958 <tr>
959 <td>original_server_version</td>
960 <td>4 byte integer</td>
961 <td>Version of the server where the transaction was originally executed</td>
962 </tr>
963 </table>
964
965*/
967 public:
968 /*
969 The transaction's logical timestamps used for MTS: see
970 Transaction_ctx::last_committed and
971 Transaction_ctx::sequence_number for details.
972 Note: Transaction_ctx is in the MySQL server code.
973 */
974 long long int last_committed;
975 long long int sequence_number;
976 /** GTID flags constants */
977 unsigned const char FLAG_MAY_HAVE_SBR = 1;
978 /** Transaction might have changes logged with SBR */
980 /** Timestamp when the transaction was committed on the originating master. */
981 unsigned long long int original_commit_timestamp;
982 /** Timestamp when the transaction was committed on the nearest master. */
983 unsigned long long int immediate_commit_timestamp;
985 /** The length of the transaction in bytes. */
986 unsigned long long int transaction_length;
987
988 public:
989 /**
990 Ctor of Gtid_event
991
992 The layout of the buffer is as follows
993 <pre>
994 +----------+---+---+-------+--------------+---------+----------+
995 |gtid flags|SID|GNO|TS_TYPE|logical ts(:s)|commit ts|trx length|
996 +----------+---+---+-------+------------------------+----------+
997 </pre>
998 TS_TYPE is from {G_COMMIT_TS2} singleton set of values
999 Details on commit timestamps in Gtid_event(const char*...)
1000
1001 @param buf Contains the serialized event.
1002 @param fde An FDE event (see Rotate_event constructor for more info).
1003 */
1004
1005 Gtid_event(const char *buf, const Format_description_event *fde);
1006 /**
1007 Constructor.
1008 */
1009 explicit Gtid_event(long long int last_committed_arg,
1010 long long int sequence_number_arg,
1011 bool may_have_sbr_stmts_arg,
1012 unsigned long long int original_commit_timestamp_arg,
1013 unsigned long long int immediate_commit_timestamp_arg,
1014 uint32_t original_server_version_arg,
1015 uint32_t immediate_server_version_arg)
1017 last_committed(last_committed_arg),
1018 sequence_number(sequence_number_arg),
1019 may_have_sbr_stmts(may_have_sbr_stmts_arg),
1020 original_commit_timestamp(original_commit_timestamp_arg),
1021 immediate_commit_timestamp(immediate_commit_timestamp_arg),
1023 original_server_version(original_server_version_arg),
1024 immediate_server_version(immediate_server_version_arg) {}
1025#ifndef HAVE_MYSYS
1026 // TODO(WL#7684): Implement the method print_event_info and print_long_info
1027 // for all the events supported in MySQL Binlog
1028 void print_event_info(std::ostream &) override {}
1029 void print_long_info(std::ostream &) override {}
1030#endif
1031 protected:
1032 static const int ENCODED_FLAG_LENGTH = 1;
1033 static const int ENCODED_SID_LENGTH = 16; // Uuid::BYTE_LENGTH;
1034 static const int ENCODED_GNO_LENGTH = 8;
1035 /// Length of typecode for logical timestamps.
1037 /// Length of two logical timestamps.
1038 static const int LOGICAL_TIMESTAMP_LENGTH = 16;
1039 // Type code used before the logical timestamps.
1040 static const int LOGICAL_TIMESTAMP_TYPECODE = 2;
1041
1044 // Length of two timestamps (from original/immediate masters)
1047 // We use 7 bytes out of which 1 bit is used as a flag.
1048 static const int ENCODED_COMMIT_TIMESTAMP_LENGTH = 55;
1049 // Minimum and maximum lengths of transaction length field.
1050 static const int TRANSACTION_LENGTH_MIN_LENGTH = 1;
1051 static const int TRANSACTION_LENGTH_MAX_LENGTH = 9;
1052 /// Length of original_server_version
1054 /// Length of immediate_server_version
1056 /// Length of original and immediate server version
1059 // We use 4 bytes out of which 1 bit is used as a flag.
1060 static const int ENCODED_SERVER_VERSION_LENGTH = 31;
1061
1062 /* We have only original commit timestamp if both timestamps are equal. */
1067 }
1068
1069 /**
1070 We only store the immediate_server_version if both server versions are the
1071 same.
1072 */
1077 }
1078
1081
1082 /* Minimum GNO expected in a serialized GTID event */
1083 static const int64_t MIN_GNO = 1;
1084 /// One-past-the-max value of GNO
1085 static const std::int64_t GNO_END = INT64_MAX;
1086
1087 public:
1088 std::int64_t get_gno() const { return gtid_info_struct.rpl_gtid_gno; }
1090 /// Total length of post header
1091 static const int POST_HEADER_LENGTH =
1092 ENCODED_FLAG_LENGTH + /* flags */
1093 ENCODED_SID_LENGTH + /* SID length */
1094 ENCODED_GNO_LENGTH + /* GNO length */
1095 LOGICAL_TIMESTAMP_TYPECODE_LENGTH + /* length of typecode */
1096 LOGICAL_TIMESTAMP_LENGTH; /* length of two logical timestamps */
1097
1098 /*
1099 We keep the commit timestamps in the body section because they can be of
1100 variable length.
1101 On the originating master, the event has only one timestamp as the two
1102 timestamps are equal. On every other server we have two timestamps.
1103 */
1107
1108 static const int MAX_EVENT_LENGTH =
1110 /**
1111 Set the transaction length information.
1112
1113 This function should be used when the full transaction length (including
1114 the Gtid event length) is known.
1115
1116 @param transaction_length_arg The transaction length.
1117 */
1118 void set_trx_length(unsigned long long int transaction_length_arg) {
1119 transaction_length = transaction_length_arg;
1120 }
1121
1122 /** The version of the server where the transaction was originally executed */
1124 /** The version of the immediate server */
1126};
1127
1128/**
1129 @class Previous_gtids_event
1130
1131 @section Previous_gtids_event_binary_format Binary Format
1132
1133 The Post-Header for this event type is empty. The Body has two
1134 components:
1135
1136 <table>
1137 <caption>Body for Previous_gtids_event</caption>
1138
1139 <tr>
1140 <th>Name</th>
1141 <th>Format</th>
1142 <th>Description</th>
1143 </tr>
1144
1145 <tr>
1146 <td>buf</td>
1147 <td>unsigned char array</td>
1148 <td>It contains the Gtids executed in the
1149 last binary log file.</td>
1150 </tr>
1151
1152 <tr>
1153 <td>buf_size</td>
1154 <td>4 byte integer</td>
1155 <td>Size of the above buffer</td>
1156 </tr>
1157 </table>
1158*/
1160 public:
1161 /**
1162 Decodes the gtid_executed in the last binlog file
1163
1164 <pre>
1165 The buffer layout is as follows
1166 +--------------------------------------------+
1167 | Gtids executed in the last binary log file |
1168 +--------------------------------------------+
1169 </pre>
1170 @param buf Contains the serialized event.
1171 @param fde An FDE event (see Rotate_event constructor for more info).
1172 */
1173 Previous_gtids_event(const char *buf, const Format_description_event *fde);
1174 /**
1175 This is the minimal constructor, and set the
1176 type_code as PREVIOUS_GTIDS_LOG_EVENT in the header object in
1177 Binary_log_event
1178 */
1180#ifndef HAVE_MYSYS
1181 // TODO(WL#7684): Implement the method print_event_info and print_long_info
1182 // for all the events supported in MySQL Binlog
1183 void print_event_info(std::ostream &) override {}
1184 void print_long_info(std::ostream &) override {}
1185#endif
1186 protected:
1187 size_t buf_size;
1188 const unsigned char *buf;
1189};
1190
1191/**
1192 @class Transaction_context_event
1193
1194 This class is used to combine the information of the ongoing transaction
1195 including the write set and other information of the thread executing the
1196 transaction.
1197
1198 <tr>
1199 <th>Name</th>
1200 <th>Format</th>
1201 <th>Description</th>
1202 </tr>
1203
1204 <tr>
1205 <td>thread_id</td>
1206 <td>4 byte integer</td>
1207 <td>The identifier for the thread executing the transaction.</td>
1208 </tr>
1209
1210 <tr>
1211 <td>gtid_specified</td>
1212 <td>bool type variable</td>
1213 <td>Variable to identify whether the Gtid have been specified for the
1214 ongoing transaction or not.
1215 </td>
1216 </tr>
1217
1218 <tr>
1219 <td>encoded_snapshot_version</td>
1220 <td>unsigned char array</td>
1221 <td>A gtid_set which is used to store the transaction set used for
1222 conflict detection.</td>
1223 </tr>
1224
1225 <tr>
1226 <td>encoded_snapshot_version_length</td>
1227 <td>4 byte integer</td>
1228 <td>Length of the above char array.</td>
1229 </tr>
1230
1231 <tr>
1232 <td>write_set</td>
1233 <td>variable length list to store the hash values. </td>
1234 <td>Used to store the hash values of the rows identifier for the rows
1235 which have changed in the ongoing transaction.
1236 </td>
1237 </tr>
1238
1239 <tr>
1240 <td>read_set</td>
1241 <td>variable length list to store the read set values. Currently empty.
1242 </td> <td>Will be used to store the read set values of the current
1243 transaction.</td>
1244 </tr>
1245
1246*/
1248 public:
1249 /**
1250 Decodes the transaction_context_log_event of the ongoing transaction.
1251
1252 <pre>
1253 The buffer layout is as follows
1254 </pre>
1255
1256 @param buf Contains the serialized event.
1257 @param fde An FDE event (see Rotate_event constructor for more info).
1258 */
1259 Transaction_context_event(const char *buf,
1260 const Format_description_event *fde);
1261
1262 Transaction_context_event(unsigned int thread_id_arg,
1263 bool is_gtid_specified_arg)
1265 thread_id(thread_id_arg),
1266 gtid_specified(is_gtid_specified_arg) {}
1267
1268 ~Transaction_context_event() override;
1269
1270 static const char *read_data_set(const char *pos, uint32_t set_len,
1271 std::list<const char *> *set,
1272 uint32_t remaining_buffer);
1273
1274 static void clear_set(std::list<const char *> *set);
1275
1276#ifndef HAVE_MYSYS
1277 void print_event_info(std::ostream &) override {}
1278 void print_long_info(std::ostream &) override {}
1279#endif
1280
1281 protected:
1282 const char *server_uuid;
1283 uint32_t thread_id;
1285 const unsigned char *encoded_snapshot_version;
1287 std::list<const char *> write_set;
1288 std::list<const char *> read_set;
1289
1290 // The values mentioned on the next class constants is the offset where the
1291 // data that will be copied in the buffer.
1292
1293 // 1 byte length.
1295 // 4 bytes length.
1296 static const int ENCODED_THREAD_ID_OFFSET = 1;
1297 // 1 byte length.
1298 static const int ENCODED_GTID_SPECIFIED_OFFSET = 5;
1299 // 4 bytes length
1301 // 4 bytes length.
1302 static const int ENCODED_WRITE_SET_ITEMS_OFFSET = 10;
1303 // 4 bytes length.
1304 static const int ENCODED_READ_SET_ITEMS_OFFSET = 14;
1305
1306 // The values mentioned on the next class's constants is the length of the
1307 // data that will be copied in the buffer.
1309 static const int ENCODED_SNAPSHOT_VERSION_LEN = 2;
1310};
1311
1312/**
1313 @class View_change_event
1314
1315 This class is used to add view change markers in the binary log when a
1316 member of the group enters or leaves the group.
1317
1318 <tr>
1319 <th>Name</th>
1320 <th>Format</th>
1321 <th>Description</th>
1322 </tr>
1323
1324 <tr>
1325 <td>view_id</td>
1326 <td>40 length character array</td>
1327 <td>This is used to store the view id value of the new view change when a
1328 node add or leaves the group.
1329 </td>
1330 </tr>
1331
1332 <tr>
1333 <td>seq_number</td>
1334 <td>8 bytes integer</td>
1335 <td>Variable to identify the next sequence number to be alloted to the
1336 certified transaction.</td>
1337 </tr>
1338
1339 <tr>
1340 <td>certification_info</td>
1341 <td>variable length map to store the certification data.</td>
1342 <td>Map to store the certification info ie. the hash of write_set and the
1343 snapshot sequence value.
1344 </td>
1345 </tr>
1346
1347*/
1349 public:
1350 /**
1351 Decodes the view_change_log_event generated incase a server enters or
1352 leaves the group.
1353
1354 <pre>
1355 The buffer layout is as follows
1356 </pre>
1357
1358 @param buf Contains the serialized event.
1359 @param fde An FDE event (see Rotate_event constructor for more info).
1360 */
1361 View_change_event(const char *buf, const Format_description_event *fde);
1362
1363 explicit View_change_event(const char *raw_view_id);
1364
1365 ~View_change_event() override;
1366
1367#ifndef HAVE_MYSYS
1368 void print_event_info(std::ostream &) override {}
1369 void print_long_info(std::ostream &) override {}
1370#endif
1371
1372 protected:
1373 // The values mentioned on the next class constants is the offset where the
1374 // data that will be copied in the buffer.
1375
1376 // 40 bytes length.
1377 static const int ENCODED_VIEW_ID_OFFSET = 0;
1378 // 8 bytes length.
1379 static const int ENCODED_SEQ_NUMBER_OFFSET = 40;
1380 // 4 bytes length.
1381 static const int ENCODED_CERT_INFO_SIZE_OFFSET = 48;
1382
1383 /*
1384 The layout of the buffer is as follows
1385 +--------------------- -+-------------+----------+
1386 | View Id | seq number | map size |
1387 +-----------------------+-------------+----------+
1388 view id (40 bytes) + seq number (8 bytes) + map size (4 bytes)
1389 Sum of the length of the values at the above OFFSETS.
1390 */
1391
1392 // The values mentioned on the next class constants is the length of the data
1393 // that will be copied in the buffer.
1394
1395 // Field sizes on serialization
1396 static const int ENCODED_VIEW_ID_MAX_LEN = 40;
1398 static const int ENCODED_CERT_INFO_VALUE_LEN = 4;
1399
1401
1402 long long int seq_number;
1403
1404 std::map<std::string, std::string> certification_info;
1405};
1406
1407/**
1408 @class Heartbeat_event_v2
1409
1410 Replication event to ensure to replica that source is alive.
1411 The event is originated by source's dump thread and sent straight to
1412 replica without being logged. Slave itself does not store it in relay log
1413 but rather uses a data for immediate checks and throws away the event.
1414
1415 Two members of the class m_log_filename and m_log_position comprise
1416 @see the rpl_event_coordinates instance. The coordinates that a heartbeat
1417 instance carries correspond to the last event source has sent from
1418 its binlog.
1419
1420 Also this event will be generated only for the source server with
1421 version > 8.0.26
1422
1423 @section Heartbeat_event_v2_binary_format Binary Format
1424
1425 The Body has one component:
1426
1427 <table>
1428 <caption>Body for Heartbeat_event</caption>
1429
1430 <tr>
1431 <th>Name</th>
1432 <th>Format</th>
1433 <th>Description</th>
1434 </tr>
1435
1436 <tr>
1437 <td>m_log_filename</td>
1438 <td>String variable to store the binlog name</td>
1439 <td>Name of the current binlog being written to.</td>
1440 </tr>
1441 <tr>
1442 <td>m_log_pos</td>
1443 <td>8 byte unsigned integar</td>
1444 <td>Name of the current binlog being written to.</td>
1445 </tr>
1446 </table>
1447*/
1448
1450 public:
1451 /**
1452 Sent by a source to a replica to let the replica know that the source is
1453 still alive. Events of this type do not appear in the binary or relay logs.
1454 They are generated on a source server by the thread that dumps events and
1455 sent straight to the replica without ever being written to the binary log.
1456
1457 @param buf Contains the serialized event.
1458 @param fde An FDE event (see Rotate_event constructor for more info).
1459 */
1460 Heartbeat_event_v2(const char *buf, const Format_description_event *fde);
1461
1462 /**
1463 Creates an empty heartbeat event.
1464 */
1466
1467 virtual ~Heartbeat_event_v2() override = default;
1468
1469 // Set the binlog filename
1470 void set_log_filename(const std::string name);
1471 // Set the position
1472 void set_log_position(uint64_t position);
1473 // Return the binlog filename
1474 const std::string get_log_filename() const;
1475 // Return the position
1476 uint64_t get_log_position() const;
1477
1478 // Return the max length of an encoded packet.
1479 static uint64_t max_encoding_length();
1480#ifndef HAVE_MYSYS
1481 virtual void print_event_info(std::ostream &info) override;
1482 virtual void print_long_info(std::ostream &info) override;
1483#endif
1484 protected:
1485 std::string m_log_filename{};
1486 uint64_t m_log_position{0};
1487};
1488
1489/**
1490 @class Heartbeat_event
1491
1492 Replication event to ensure to replica that source is alive.
1493 The event is originated by source's dump thread and sent straight to
1494 replica without being logged. Slave itself does not store it in relay log
1495 but rather uses a data for immediate checks and throws away the event.
1496
1497 Two members of the class log_ident and Binary_log_event::log_pos comprise
1498 @see the rpl_event_coordinates instance. The coordinates that a heartbeat
1499 instance carries correspond to the last event source has sent from
1500 its binlog.
1501
1502 @section Heartbeat_event_binary_format Binary Format
1503
1504 The Body has one component:
1505
1506 <table>
1507 <caption>Body for Heartbeat_event</caption>
1508
1509 <tr>
1510 <th>Name</th>
1511 <th>Format</th>
1512 <th>Description</th>
1513 </tr>
1514
1515 <tr>
1516 <td>log_ident</td>
1517 <td>variable length string without trailing zero, extending to the
1518 end of the event</td>
1519 <td>Name of the current binlog being written to.</td>
1520 </tr>
1521 </table>
1522*/
1524 public:
1525 /**
1526 Sent by a source to a replica to let the replica know that the source is
1527 still alive. Events of this type do not appear in the binary or relay logs.
1528 They are generated on a source server by the thread that dumps events and
1529 sent straight to the replica without ever being written to the binary log.
1530
1531 @param buf Contains the serialized event.
1532 @param fde An FDE event (see Rotate_event constructor for more info).
1533 */
1534 Heartbeat_event(const char *buf, const Format_description_event *fde);
1535
1536 // Return the file name
1537 const char *get_log_ident() { return log_ident; }
1538 // Return the length of file name
1539 unsigned int get_ident_len() { return ident_len; }
1540
1541 protected:
1542 const char *log_ident;
1543 unsigned int ident_len; /** filename length */
1544};
1545
1546} // end namespace binary_log
1547/**
1548 @} (end of group Replication)
1549*/
1550#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:966
long long int sequence_number
Definition: control_events.h:975
static const int POST_HEADER_LENGTH
Total length of post header.
Definition: control_events.h:1091
static const int LOGICAL_TIMESTAMP_TYPECODE_LENGTH
Length of typecode for logical timestamps.
Definition: control_events.h:1036
static const int ENCODED_GNO_LENGTH
Definition: control_events.h:1034
static const int LOGICAL_TIMESTAMP_TYPECODE
Definition: control_events.h:1040
static const int ENCODED_SERVER_VERSION_LENGTH
Definition: control_events.h:1060
bool may_have_sbr_stmts
Transaction might have changes logged with SBR.
Definition: control_events.h:979
static const int ORIGINAL_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1043
static const int TRANSACTION_LENGTH_MIN_LENGTH
Definition: control_events.h:1050
Uuid get_uuid() const
Definition: control_events.h:1089
uint32_t original_server_version
The version of the server where the transaction was originally executed.
Definition: control_events.h:1123
unsigned long long int original_commit_timestamp
Timestamp when the transaction was committed on the originating master.
Definition: control_events.h:981
static const int ORIGINAL_SERVER_VERSION_LENGTH
Length of original_server_version.
Definition: control_events.h:1053
unsigned long long int immediate_commit_timestamp
Timestamp when the transaction was committed on the nearest master.
Definition: control_events.h:983
static const int ENCODED_SID_LENGTH
Definition: control_events.h:1033
int get_server_version_length() const
We only store the immediate_server_version if both server versions are the same.
Definition: control_events.h:1073
static const int FULL_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1045
std::int64_t get_gno() const
Definition: control_events.h:1088
static const int TRANSACTION_LENGTH_MAX_LENGTH
Definition: control_events.h:1051
static const int FULL_SERVER_VERSION_LENGTH
Length of original and immediate server version.
Definition: control_events.h:1057
gtid_info gtid_info_struct
Definition: control_events.h:1079
static const int ENCODED_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1048
static const int IMMEDIATE_COMMIT_TIMESTAMP_LENGTH
Definition: control_events.h:1042
uint32_t immediate_server_version
The version of the immediate server.
Definition: control_events.h:1125
Gtid_event(const char *buf, const Format_description_event *fde)
Ctor of Gtid_event.
Definition: control_events.cpp:413
int get_commit_timestamp_length() const
Definition: control_events.h:1063
static const int64_t MIN_GNO
Definition: control_events.h:1083
unsigned const char FLAG_MAY_HAVE_SBR
GTID flags constants.
Definition: control_events.h:977
bool has_commit_timestamps
Definition: control_events.h:984
long long int last_committed
Definition: control_events.h:974
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:1009
static const int IMMEDIATE_SERVER_VERSION_LENGTH
Length of immediate_server_version.
Definition: control_events.h:1055
static const int MAX_DATA_LENGTH
Definition: control_events.h:1104
static const int MAX_EVENT_LENGTH
Definition: control_events.h:1108
static const int ENCODED_FLAG_LENGTH
Definition: control_events.h:1032
Uuid Uuid_parent_struct
Definition: control_events.h:1080
unsigned long long int transaction_length
The length of the transaction in bytes.
Definition: control_events.h:986
static const int LOGICAL_TIMESTAMP_LENGTH
Length of two logical timestamps.
Definition: control_events.h:1038
void set_trx_length(unsigned long long int transaction_length_arg)
Set the transaction length information.
Definition: control_events.h:1118
static const std::int64_t GNO_END
One-past-the-max value of GNO.
Definition: control_events.h:1085
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1449
void set_log_position(uint64_t position)
Definition: control_events.cpp:714
uint64_t get_log_position() const
Definition: control_events.cpp:720
uint64_t m_log_position
Definition: control_events.h:1486
static uint64_t max_encoding_length()
This member function returns the len of the event.
Definition: control_events.cpp:727
virtual ~Heartbeat_event_v2() override=default
const std::string get_log_filename() const
Definition: control_events.cpp:717
std::string m_log_filename
Definition: control_events.h:1485
Heartbeat_event_v2()
Creates an empty heartbeat event.
Definition: control_events.cpp:708
void set_log_filename(const std::string name)
Definition: control_events.cpp:711
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1523
unsigned int ident_len
Definition: control_events.h:1543
const char * log_ident
Definition: control_events.h:1542
unsigned int get_ident_len()
Definition: control_events.h:1539
const char * get_log_ident()
Definition: control_events.h:1537
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:673
Base class for ignorable log events.
Definition: control_events.h:651
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:660
Class representing an incident, an occurance 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:1159
size_t buf_size
Definition: control_events.h:1187
const unsigned char * buf
Definition: control_events.h:1188
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:1179
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:1247
static const int ENCODED_SNAPSHOT_VERSION_LEN_OFFSET
Definition: control_events.h:1300
uint32_t encoded_snapshot_version_length
Definition: control_events.h:1286
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:1296
static const int ENCODED_SERVER_UUID_LEN_OFFSET
Definition: control_events.h:1294
const unsigned char * encoded_snapshot_version
Definition: control_events.h:1285
std::list< const char * > write_set
Definition: control_events.h:1287
Transaction_context_event(unsigned int thread_id_arg, bool is_gtid_specified_arg)
Definition: control_events.h:1262
static const int ENCODED_GTID_SPECIFIED_OFFSET
Definition: control_events.h:1298
static const int ENCODED_READ_WRITE_SET_ITEM_LEN
Definition: control_events.h:1308
std::list< const char * > read_set
Definition: control_events.h:1288
const char * server_uuid
Definition: control_events.h:1282
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:579
static const int ENCODED_READ_SET_ITEMS_OFFSET
Definition: control_events.h:1304
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:617
uint32_t thread_id
Definition: control_events.h:1283
bool gtid_specified
Definition: control_events.h:1284
~Transaction_context_event() override
Destructor of the Transaction_context_event class.
Definition: control_events.cpp:627
static const int ENCODED_SNAPSHOT_VERSION_LEN
Definition: control_events.h:1309
static const int ENCODED_WRITE_SET_ITEMS_OFFSET
Definition: control_events.h:1302
This event is a wrapper event and encloses many other events.
Definition: control_events.h:715
uint64_t m_uncompressed_size
The size of the data uncompressed.
Definition: control_events.h:746
const char * m_payload
The raw bytes which are the data that this event contains.
Definition: control_events.h:725
static const int MAX_DATA_LENGTH
Definition: control_events.h:756
uint64_t m_payload_size
The size of the data.
Definition: control_events.h:730
static const unsigned short COMPRESSION_TYPE_MIN_LENGTH
Definition: control_events.h:749
uint64_t get_payload_size() const
Shall get the size of the payload inside this event.
Definition: control_events.h:834
static const unsigned short UNCOMPRESSED_SIZE_MAX_LENGTH
Definition: control_events.h:754
static const unsigned short PAYLOAD_SIZE_MIN_LENGTH
Definition: control_events.h:751
void set_compression_type(transaction::compression::type type)
Shall set the compression type used for the enclosed payload.
Definition: control_events.h:809
transaction::compression::type get_compression_type() const
Shall return the compression type used for the enclosed payload.
Definition: control_events.h:818
uint64_t get_uncompressed_size() const
Shall get the uncompressed size of the event.
Definition: control_events.h:848
static const unsigned short PAYLOAD_SIZE_MAX_LENGTH
Definition: control_events.h:752
const char * get_payload() const
Shall get the payload of the event.
Definition: control_events.h:862
void set_uncompressed_size(uint64_t size)
Shall set the uncompressed size of the payload.
Definition: control_events.h:841
void set_payload(const char *data)
Shall set the payload of the event.
Definition: control_events.h:855
Transaction_payload_event & operator=(const Transaction_payload_event &)=delete
static const unsigned short COMPRESSION_TYPE_MAX_LENGTH
Definition: control_events.h:750
std::string to_string() const
Shall return a textual representation of this event.
Definition: control_events.cpp:390
void set_payload_size(uint64_t size)
Shall set the size of the payload inside this event.
Definition: control_events.h:827
transaction::compression::type m_compression_type
If the data is compressed, which compression was used.
Definition: control_events.h:739
Transaction_payload_event(const Transaction_payload_event &)=delete
static const unsigned short UNCOMPRESSED_SIZE_MIN_LENGTH
Definition: control_events.h:753
~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:1348
static const int ENCODED_CERT_INFO_KEY_SIZE_LEN
Definition: control_events.h:1397
View_change_event(const char *buf, const Format_description_event *fde)
Decodes the view_change_log_event generated incase a server enters or leaves the group.
Definition: control_events.cpp:646
static const int ENCODED_SEQ_NUMBER_OFFSET
Definition: control_events.h:1379
char view_id[ENCODED_VIEW_ID_MAX_LEN]
Definition: control_events.h:1400
static const int ENCODED_CERT_INFO_SIZE_OFFSET
Definition: control_events.h:1381
static const int ENCODED_CERT_INFO_VALUE_LEN
Definition: control_events.h:1398
static const int ENCODED_VIEW_ID_MAX_LEN
Definition: control_events.h:1396
std::map< std::string, std::string > certification_info
Definition: control_events.h:1404
static const int ENCODED_VIEW_ID_OFFSET
Definition: control_events.h:1377
long long int seq_number
Definition: control_events.h:1402
~View_change_event() override
Destructor of the View_change_event class.
Definition: control_events.cpp:671
An XA_prepare event is generated for a XA prepared transaction.
Definition: control_events.h:579
MY_XID my_xid
Definition: control_events.h:597
void * xid
Definition: control_events.h:598
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:607
bool one_phase
Definition: control_events.h:599
static const int MY_XIDDATASIZE
Definition: control_events.h:584
static const uint16_t ser_buf_size
Definition: control_events.h:595
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
constexpr value_type set
Definition: classic_protocol_constants.h:274
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:586
long gtrid_length
Definition: control_events.h:588
long bqual_length
Definition: control_events.h:589
char data[MY_XIDDATASIZE]
Definition: control_events.h:590
long formatID
Definition: control_events.h:587
Structure to hold the members declared in the class Gtid_log_event those member are objects of classe...
Definition: control_events.h:703
int64_t rpl_gtid_gno
Definition: control_events.h:705
int32_t rpl_gtid_sidno
Definition: control_events.h:704
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