MySQL 9.0.0
Source Code Documentation
log_event.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/**
25 @file sql/log_event.h
26
27 @brief Binary log event definitions. This includes generic code
28 common to all types of log events, as well as specific code for each
29 type of log event.
30
31 @addtogroup Replication
32 @{
33*/
34
35#ifndef _log_event_h
36#define _log_event_h
37
38#include <atomic>
39#include <cstdint>
40#include <functional>
41#include <list>
42#include <map>
43#include <set>
44#include <string>
45#include <string_view>
46
47#include "m_string.h" // native_strncasecmp
48#include "my_bitmap.h" // MY_BITMAP
49#include "my_checksum.h" // ha_checksum
50#include "my_dbug.h"
51#include "my_inttypes.h"
52#include "my_psi_config.h"
53#include "my_sharedlib.h"
54#include "my_sys.h"
55#include "my_thread_local.h"
62#include "mysql/gtid/uuid.h"
65#include "mysql_com.h" // SERVER_VERSION_LENGTH
66#include "partition_info.h"
67#include "sql/query_options.h" // OPTION_AUTO_IS_NULL
68#include "sql/rpl_gtid.h" // enum_gtid_type
69#include "sql/rpl_utility.h" // Hash_slave_rows
70#include "sql/sql_const.h"
71#include "sql/thr_malloc.h"
72#include "sql_string.h"
73#include "string_with_len.h"
74#include "strmake.h"
75#include "typelib.h" // TYPELIB
76
77namespace mysql::binlog::event {
78class Table_id;
79} // namespace mysql::binlog::event
80
81class THD;
82struct CHARSET_INFO;
83
84enum class enum_row_image_type;
85class Basic_ostream;
86
87#ifdef MYSQL_SERVER
88#include <stdio.h>
89
90#include "my_compiler.h"
91#include "sql/changestreams/misc/replicated_columns_view.h" // ReplicatedColumnsView
92#include "sql/key.h"
93#include "sql/rpl_filter.h" // rpl_filter
94#include "sql/table.h"
95#include "sql/xa.h"
96#endif
97
98#ifndef MYSQL_SERVER
99#include "sql/rpl_tblmap.h" // table_mapping
100#endif
101
102#include <limits.h>
103#include <stdint.h>
104#include <string.h>
105#include <sys/types.h>
106#include <time.h>
107
108#ifdef HAVE_PSI_STAGE_INTERFACE
110#endif
111
112#ifndef MYSQL_SERVER
114#endif
115
119
120#if defined(MYSQL_SERVER)
121using ColumnViewPtr = std::unique_ptr<cs::util::ReplicatedColumnsView>;
122#endif
123
124using sql_mode_t = uint64_t;
126
128#if defined(MYSQL_SERVER)
129int ignored_error_code(int err_code);
130#endif
131#define PREFIX_SQL_LOAD "SQL_LOAD-"
132
133/**
134 Maximum length of the name of a temporary file
135 PREFIX LENGTH - 9
136 UUID - UUID_LENGTH
137 SEPARATORS - 2
138 SERVER ID - 10 (range of server ID 1 to (2^32)-1 = 4,294,967,295)
139 FILE ID - 10 (uint)
140 EXTENSION - 7 (Assuming that the extension is always less than 7
141 characters)
142*/
143#define TEMP_FILE_MAX_LEN UUID_LENGTH + 38
144
145/**
146 Either assert or return an error.
147
148 In debug build, the condition will be checked, but in non-debug
149 builds, the error code given will be returned instead.
150
151 @param COND Condition to check
152 @param ERRNO Error number to return in non-debug builds
153*/
154#ifdef NDEBUG
155#define ASSERT_OR_RETURN_ERROR(COND, ERRNO) \
156 do { \
157 if (!(COND)) return ERRNO; \
158 } while (0)
159#else
160#define ASSERT_OR_RETURN_ERROR(COND, ERRNO) assert(COND)
161#endif
162
163#define LOG_EVENT_OFFSET 4
164
165#define NUM_LOAD_DELIM_STRS 5
166
167/*****************************************************************************
168
169 MySQL Binary Log
170
171 This log consists of events. Each event has a fixed-length header,
172 possibly followed by a variable length data body.
173
174 The data body consists of an optional fixed length segment (post-header)
175 and an optional variable length segment.
176
177 See the #defines below for the format specifics.
178
179 The events which really update data are Query_log_event,
180 Execute_load_query_log_event and old Load_log_event and
181 Execute_load_log_event events (Execute_load_query is used together with
182 Begin_load_query and Append_block events to replicate LOAD DATA INFILE.
183 Create_file/Append_block/Execute_load (which includes Load_log_event)
184 were used to replicate LOAD DATA before the 5.0.3).
185
186 ****************************************************************************/
187
188#define MAX_LOG_EVENT_HEADER \
189 ( /* in order of Query_log_event::write */ \
190 (LOG_EVENT_HEADER_LEN + /* write_header */ \
191 mysql::binlog::event::Binary_log_event::QUERY_HEADER_LEN + /* write_data \
192 */ \
193 mysql::binlog::event::Binary_log_event:: \
194 EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN) + /*write_post_header_for_derived \
195 */ \
196 MAX_SIZE_LOG_EVENT_STATUS + /* status */ \
197 NAME_LEN + \
198 1)
199
200/* slave event post-header (this event is never written) */
202#define SL_MASTER_PORT_OFFSET 8
203#define SL_MASTER_POS_OFFSET 0
204#define SL_MASTER_HOST_OFFSET 10
205
206/* Intvar event post-header */
208/* Intvar event data */
209#define I_TYPE_OFFSET 0
210#define I_VAL_OFFSET 1
212/* 4 bytes which all binlogs should begin with */
213#define BINLOG_MAGIC "\xfe\x62\x69\x6e"
214#define BINLOG_MAGIC_SIZE 4
215
216/**
217 @addtogroup group_cs_binglog_event_header_flags Binlog Event Header Flags
218 @ingroup group_cs
219 @{
220*/
221
222/*
223 The 2 flags below were useless :
224 - the first one was never set
225 - the second one was set in all Rotate events on the master, but not used for
226 anything useful.
227 So they are now removed and their place may later be reused for other
228 flags. Then one must remember that Rotate events in 4.x have
229 LOG_EVENT_FORCED_ROTATE_F set, so one should not rely on the value of the
230 replacing flag when reading a Rotate event.
231 I keep the defines here just to remember what they were.
232
233 #define LOG_EVENT_TIME_F 0x1
234 #define LOG_EVENT_FORCED_ROTATE_F 0x2
235*/
236
237/**
238 @def LOG_EVENT_THREAD_SPECIFIC_F
239
240 If the query depends on the thread (for example: TEMPORARY TABLE).
241 Currently this is used by mysqlbinlog to know it must print
242 SET @@PSEUDO_THREAD_ID=xx; before the query (it would not hurt to print it
243 for every query but this would be slow).
244*/
245#define LOG_EVENT_THREAD_SPECIFIC_F 0x4
246
247/**
248 @def LOG_EVENT_SUPPRESS_USE_F
249
250 Suppress the generation of 'USE' statements before the actual
251 statement. This flag should be set for any events that does not need
252 the current database set to function correctly. Most notable cases
253 are 'CREATE DATABASE' and 'DROP DATABASE'.
254
255 This flags should only be used in exceptional circumstances, since
256 it introduce a significant change in behaviour regarding the
257 replication logic together with the flags --binlog-do-db and
258 --replicated-do-db.
259 */
260#define LOG_EVENT_SUPPRESS_USE_F 0x8
261
262/*
263 Note: this is a place holder for the flag
264 LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F (0x10), which is not used any
265 more, please do not reused this value for other flags.
266 */
267
268/**
269 @def LOG_EVENT_ARTIFICIAL_F
270
271 Artificial events are created arbitrarily and not written to binary
272 log
273
274 These events should not update the master log position when slave
275 SQL thread executes them.
276*/
277#define LOG_EVENT_ARTIFICIAL_F 0x20
278
279/**
280 @def LOG_EVENT_RELAY_LOG_F
281
282 Events with this flag set are created by slave IO thread and written
283 to relay log
284*/
285#define LOG_EVENT_RELAY_LOG_F 0x40
286
287/**
288 @def LOG_EVENT_IGNORABLE_F
289
290 For an event, 'e', carrying a type code, that a slave,
291 's', does not recognize, 's' will check 'e' for
292 LOG_EVENT_IGNORABLE_F, and if the flag is set, then 'e'
293 is ignored. Otherwise, 's' acknowledges that it has
294 found an unknown event in the relay log.
295*/
296#define LOG_EVENT_IGNORABLE_F 0x80
297
298/**
299 @def LOG_EVENT_NO_FILTER_F
300
301 Events with this flag are not filtered (e.g. on the current
302 database) and are always written to the binary log regardless of
303 filters.
304*/
305#define LOG_EVENT_NO_FILTER_F 0x100
306
307/**
308 MTS: group of events can be marked to force its execution
309 in isolation from any other Workers.
310 So it's a marker for Coordinator to memorize and perform necessary
311 operations in order to guarantee no interference from other Workers.
312 The flag can be set ON only for an event that terminates its group.
313 Typically that is done for a transaction that contains
314 a query accessing more than OVER_MAX_DBS_IN_EVENT_MTS databases.
315*/
316#define LOG_EVENT_MTS_ISOLATE_F 0x200
317
318/** @}*/
319
320/**
321 @def OPTIONS_WRITTEN_TO_BIN_LOG
322
323 OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must
324 be written to the binlog. OPTIONS_WRITTEN_TO_BIN_LOG could be
325 written into the Format_description_log_event, so that if later we
326 don't want to replicate a variable we did replicate, or the
327 contrary, it's doable. But it should not be too hard to decide once
328 for all of what we replicate and what we don't, among the fixed 32
329 bits of thd->options.
330
331 I (Guilhem) have read through every option's usage, and it looks
332 like OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only
333 ones which alter how the query modifies the table. It's good to
334 replicate OPTION_RELAXED_UNIQUE_CHECKS too because otherwise, the
335 slave may insert data slower than the master, in InnoDB.
336 OPTION_BIG_SELECTS is not needed (the slave thread runs with
337 max_join_size=HA_POS_ERROR) and OPTION_BIG_TABLES is not needed
338 either, as the manual says (because a too big in-memory temp table
339 is automatically written to disk).
340*/
341#define OPTIONS_WRITTEN_TO_BIN_LOG \
342 (OPTION_AUTO_IS_NULL | OPTION_NO_FOREIGN_KEY_CHECKS | \
343 OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NOT_AUTOCOMMIT)
345/* Shouldn't be defined before */
346#define EXPECTED_OPTIONS \
347 ((1ULL << 14) | (1ULL << 26) | (1ULL << 27) | (1ULL << 19))
348
349#if OPTIONS_WRITTEN_TO_BIN_LOG != EXPECTED_OPTIONS
350#error OPTIONS_WRITTEN_TO_BIN_LOG must NOT change their values!
351#endif
352#undef EXPECTED_OPTIONS /* You shouldn't use this one */
353
354/**
355 Maximum value of binlog logical timestamp.
356*/
357const int64 SEQ_MAX_TIMESTAMP = LLONG_MAX;
358
359/**
360 This method is used to extract the partition_id
361 from a partitioned table.
362
363 @param part_info an object of class partition_info it will be used
364 to call the methods responsible for returning the
365 value of partition_id
366
367 @retval The return value is the partition_id.
368
369*/
370int get_rpl_part_id(partition_info *part_info);
371
372#ifdef MYSQL_SERVER
373class Item;
374class Protocol;
376class Slave_worker;
377class sql_exchange;
378template <class T>
379class List;
380#endif
381
382class Relay_log_info;
383class Gtid_log_event;
384
385#ifndef MYSQL_SERVER
386enum enum_base64_output_mode {
387 BASE64_OUTPUT_NEVER = 0,
388 BASE64_OUTPUT_AUTO = 1,
389 BASE64_OUTPUT_UNSPEC = 2,
390 BASE64_OUTPUT_DECODE_ROWS = 3,
391 /* insert new output modes here */
392 BASE64_OUTPUT_MODE_COUNT
393};
394
395/*
396 A structure for mysqlbinlog to know how to print events
397
398 This structure is passed to the event's print() methods,
399
400 There are two types of settings stored here:
401 1. Last db, flags2, sql_mode etc comes from the last printed event.
402 They are stored so that only the necessary USE and SET commands
403 are printed.
404 2. Other information on how to print the events, e.g. short_form,
405 hexdump_from. These are not dependent on the last event.
406*/
407struct PRINT_EVENT_INFO {
408 /*
409 Settings for database, sql_mode etc that comes from the last event
410 that was printed. We cache these so that we don't have to print
411 them if they are unchanged.
412 */
413 // TODO: have the last catalog here ??
414 char db[FN_REFLEN + 1]; // TODO: make this a LEX_STRING when thd->db is
415 bool flags2_inited;
416 uint32 flags2;
417 bool sql_mode_inited;
418 sql_mode_t sql_mode; /* must be same as THD.variables.sql_mode */
419 ulong auto_increment_increment, auto_increment_offset;
420 bool charset_inited;
421 char charset[6]; // 3 variables, each of them storable in 2 bytes
422 char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH];
423 uint lc_time_names_number;
424 uint charset_database_number;
425 uint default_collation_for_utf8mb4_number;
426 uint8_t sql_require_primary_key;
428 bool thread_id_printed;
429 uint8_t default_table_encryption;
430
431 PRINT_EVENT_INFO();
432
433 ~PRINT_EVENT_INFO() {
434 close_cached_file(&head_cache);
435 close_cached_file(&body_cache);
436 close_cached_file(&footer_cache);
437 }
438 bool init_ok() /* tells if construction was successful */
439 {
440 return my_b_inited(&head_cache) && my_b_inited(&body_cache) &&
441 my_b_inited(&footer_cache);
442 }
443
444 /* Settings on how to print the events */
445 // True if the --short-form flag was specified
446 bool short_form;
447 // The X in --base64-output=X
448 enum_base64_output_mode base64_output_mode;
449 // True if the --skip-gtids flag was specified.
450 bool skip_gtids;
451
452 /*
453 This is set whenever a Format_description_event is printed.
454 Later, when an event is printed in base64, this flag is tested: if
455 no Format_description_event has been seen, it is unsafe to print
456 the base64 event, so an error message is generated.
457 */
458 bool printed_fd_event;
459 my_off_t hexdump_from;
460 uint8 common_header_len;
461 char delimiter[16];
462
463 uint verbose;
464 table_mapping m_table_map;
465 table_mapping m_table_map_ignored;
466
467 /*
468 These three caches are used by the row-based replication events to
469 collect the header information and the main body of the events
470 making up a statement and in footer section any verbose related details
471 or comments related to the statement.
472 */
473 IO_CACHE head_cache;
474 IO_CACHE body_cache;
475 IO_CACHE footer_cache;
476 /* Indicate if the body cache has unflushed events */
477 bool have_unflushed_events;
478
479 /*
480 True if an event was skipped while printing the events of
481 a transaction and no COMMIT statement or XID event was ever
482 output (ie, was filtered out as well). This can be triggered
483 by the --database option of mysqlbinlog.
484
485 False, otherwise.
486 */
487 bool skipped_event_in_transaction;
488
489 bool print_table_metadata;
490
491 /**
492 True if --require_row_format is passed.
493 If true
494 It prints at start SET @@session.require_row_format = 1
495 It omits the SET @@session.pseudo_thread_id printed on Query events
496 */
497 bool require_row_format;
498
499 /**
500 The version of the last server that sent the transaction
501 */
502 uint32_t immediate_server_version;
503};
504#endif
505
506/*
507 A specific to the database-scheduled MTS type.
510 const char *name[MAX_DBS_IN_EVENT_MTS]{nullptr};
511 int num{0};
512
513 Mts_db_names() = default;
514
515 void reset_and_dispose() {
516 for (int i = 0; i < MAX_DBS_IN_EVENT_MTS; i++) {
517 free(const_cast<char *>(name[i]));
518 name[i] = nullptr;
519 }
520 num = 0;
521 }
522};
523
524/**
525 @class Log_event
526
527 This is the abstract base class for binary log events.
528
529 @section Log_event_binary_format Binary Format
530
531 The format of the event is described @ref Binary_log_event_format "here".
532
533 @subsection Log_event_format_of_atomic_primitives Format of Atomic Primitives
534
535 - All numbers, whether they are 16-, 24-, 32-, or 64-bit numbers,
536 are stored in little endian, i.e., the least significant byte first,
537 unless otherwise specified.
539*/
540class Log_event {
541 public:
542 /**
543 Enumeration of what kinds of skipping (and non-skipping) that can
544 occur when the slave executes an event.
545
546 @see shall_skip
547 @see do_shall_skip
548 */
549 enum enum_skip_reason {
550 /**
551 Don't skip event.
552 */
554
555 /**
556 Skip event by ignoring it.
557
558 This means that the slave skip counter will not be changed.
559 */
561
562 /**
563 Skip event and decrease skip counter.
564 */
566 };
568 protected:
571 /*
572 If possible the event should use a non-transactional cache before
573 being flushed to the binary log. This means that it must be flushed
574 right after its correspondent statement is completed.
575 */
577 /*
578 The event should use a transactional cache before being flushed to
579 the binary log. This means that it must be flushed upon commit or
580 rollback.
581 */
583 /*
584 The event must be written directly to the binary log without going
585 through any cache.
586 */
588 /*
589 If there is a need for different types, introduce them before this.
590 */
592 };
596 /*
597 The event must be written to a cache and upon commit or rollback
598 written to the binary log.
599 */
601 /*
602 The event must be written to an empty cache and immediately written
603 to the binary log without waiting for any other event.
604 */
606 /*
607 If there is a need for different types, introduce them before this.
608 */
610 };
611
612 /**
613 Writes the common header of this event to the given memory buffer.
614
615 This does not update the checksum.
616
617 @note This has the following form:
618
619 +---------+---------+---------+------------+-----------+-------+
620 |timestamp|type code|server_id|event_length|end_log_pos|flags |
621 |4 bytes |1 byte |4 bytes |4 bytes |4 bytes |2 bytes|
622 +---------+---------+---------+------------+-----------+-------+
623
624 @param buf Memory buffer to write to. This must be at least
625 LOG_EVENT_HEADER_LEN bytes long.
626
627 @return The number of bytes written, i.e., always
628 LOG_EVENT_HEADER_LEN.
629 */
631 /**
632 Writes the common-header of this event to the given output stream and
633 updates the checksum.
634
635 @param ostream The event will be written to this output stream.
636
637 @param data_length The length of the post-header section plus the
638 length of the data section; i.e., the length of the event minus
639 the common-header and the checksum.
640 */
641 bool write_header(Basic_ostream *ostream, size_t data_length);
642 bool write_footer(Basic_ostream *ostream);
643 bool need_checksum();
644
645 public:
646 /*
647 A temp buffer for read_log_event; it is later analysed according to the
648 event's type, and its content is distributed in the event-specific fields.
649 */
650 char *temp_buf;
651
652 /*
653 This variable determines whether the event is responsible for deallocating
654 the memory pointed by temp_buf. When set to true temp_buf is deallocated
655 and when it is set to false just make temp_buf point to NULL.
656 */
659 /* The number of seconds the query took to run on the master. */
660 ulong exec_time;
661
662 /*
663 The master's server id (is preserved in the relay log; used to
664 prevent from infinite loops in circular replication).
665 */
667
668 /**
669 A storage to cache the global system variable's value.
670 Handling of a separate event will be governed its member.
671 */
672 ulong rbr_exec_mode;
673
674 /**
675 Defines the type of the cache, if any, where the event will be
676 stored before being flushed to disk.
677 */
679
680 /**
681 Defines when information, i.e. event or cache, will be flushed
682 to disk.
683 */
685 /**
686 Placeholder for event checksum while writing to binlog.
687 */
689 /**
690 Index in @c rli->gaq array to indicate a group that this event is
691 purging. The index is set by Coordinator to a group terminator
692 event is checked by Worker at the event execution. The indexed
693 data represent the Worker progress status.
694 */
695 ulong mts_group_idx;
696
697 /**
698 The Log_event_header class contains the variable present
699 in the common header
700 */
702
703 /**
704 The Log_event_footer class contains the variable present
705 in the common footer. Currently, footer contains only the checksum_alg.
706 */
708 /**
709 MTS: associating the event with either an assigned Worker or Coordinator.
710 Additionally the member serves to tag deferred (IRU) events to avoid
711 the event regular time destruction.
712 */
714
715 /**
716 A copy of the main rli value stored into event to pass to MTS worker rli
717 */
720#ifdef MYSQL_SERVER
721 THD *thd;
722 /**
723 Partition info associate with event to deliver to MTS event applier
724 */
726
729 enum_event_cache_type cache_type_arg,
730 enum_event_logging_type logging_type_arg);
731 Log_event(THD *thd_arg, uint16 flags_arg,
732 enum_event_cache_type cache_type_arg,
733 enum_event_logging_type logging_type_arg,
736 /*
737 init_show_field_list() prepares the column names and types for the
738 output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
739 EVENTS.
740 */
741 static void init_show_field_list(mem_root_deque<Item *> *field_list);
742
743 int net_send(Protocol *protocol, const char *log_name, my_off_t pos);
744
745 /**
746 Stores a string representation of this event in the Protocol.
747 This is used by SHOW BINLOG EVENTS.
748
749 @retval 0 success
750 @retval nonzero error
751 */
752 virtual int pack_info(Protocol *protocol);
753
754 virtual const char *get_db();
755#else // ifdef MYSQL_SERVER
756 /* print*() functions are used by mysqlbinlog */
757 virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const = 0;
758 void print_timestamp(IO_CACHE *file, time_t *ts) const;
759 void print_header(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info,
760 bool is_more) const;
761 void print_base64(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info,
762 bool is_more) const;
763#endif // ifdef MYSQL_SERVER ... else
764
765 void *operator new(size_t size);
766
767 static void operator delete(void *ptr, size_t) { my_free(ptr); }
769 /* Placement version of the above operators */
770 static void *operator new(size_t, void *ptr) { return ptr; }
771 static void operator delete(void *, void *) {}
772 /**
773 Write the given buffer to the given output stream, updating the
774 checksum if checksums are enabled.
775
776 @param ostream The output stream to write to.
777 @param buf The buffer to write.
778 @param data_length The number of bytes to write.
779
780 @retval false Success.
781 @retval true Error.
782 */
783 bool wrapper_my_b_safe_write(Basic_ostream *ostream, const uchar *buf,
784 size_t data_length);
786#ifdef MYSQL_SERVER
787 virtual bool write(Basic_ostream *ostream) {
788 return (write_header(ostream, get_data_size()) ||
789 write_data_header(ostream) || write_data_body(ostream) ||
790 write_footer(ostream));
791 }
792
793 time_t get_time();
795 virtual bool write_data_header(Basic_ostream *) { return false; }
796 virtual bool write_data_body(Basic_ostream *) { return false; }
797#endif
798
800 return common_header->type_code;
801 }
802
803 /**
804 Return true if the event has to be logged using SBR for DMLs.
805 */
806 virtual bool is_sbr_logging_format() const { return false; }
807 /**
808 Return true if the event has to be logged using RBR for DMLs.
809 */
810 virtual bool is_rbr_logging_format() const { return false; }
811
812 /*
813 is_valid is event specific sanity checks to determine that the
814 object is correctly initialized.
815 */
816 bool is_valid();
817 void set_artificial_event() {
819 /*
820 Artificial events are automatically generated and do not exist
821 in master's binary log, so log_pos should be set to 0.
822 */
826 bool is_artificial_event() const {
828 }
829 bool is_relay_log_event() const {
831 }
832 bool is_ignorable_event() const {
834 }
835 bool is_no_filter_event() const {
837 }
838 inline bool is_using_trans_cache() const {
840 }
841 inline bool is_using_stmt_cache() const {
843 }
844 inline bool is_using_immediate_logging() const {
846 }
847
848 /*
849 For the events being decoded in BAPI, common_header should
850 point to the header object which is contained within the class
851 Binary_log_event.
852 */
855
856 /**
857 Allow thread to CLAIM or DISCLAIM the ownership of this object
858 depends on the parameter value passed
859
860 @param claim
861 True - claim ownership of the memory
862 False - disclaim ownership of the memory
863 */
864 virtual void claim_memory_ownership([[maybe_unused]] bool claim) {}
866 virtual ~Log_event() { free_temp_buf(); }
867 void register_temp_buf(char *buf, bool free_in_destructor = true) {
868 m_free_temp_buf_in_destructor = free_in_destructor;
870 }
871 void free_temp_buf() {
872 if (temp_buf) {
874 temp_buf = nullptr;
875 }
876 }
877 /*
878 Get event length for simple events. For complicated events the length
879 is calculated during write()
880 */
881 virtual size_t get_data_size() { return 0; }
882 /**
883 Returns the human readable name of the given event type.
884 */
886 /// Get the name of an event type, or "Unknown" if out of range.
887 /// @param type The type as an int
888 /// @retval name of an event type, if it is one
889 /// @retval "Unknown" if the value is out of range
890 static const char *get_type_str(uint type);
891 /**
892 Returns the human readable name of this event's type.
893 */
894 const char *get_type_str() const;
895 /* Return start of query time or current time */
896
897#if defined(MYSQL_SERVER)
898 /**
899 Is called from get_mts_execution_mode() to
900
901 @return true if the event needs applying with synchronization
902 against Workers, otherwise
903 false
904
905 @note There are incompatile combinations such as referred further events
906 are wrapped with BEGIN/COMMIT. Such cases should be identified
907 by the caller and treats correspondingly.
908
909 todo: to mts-support Old master Load-data related events
910 */
912 switch (get_type_code()) {
918 return true;
919 default:
920 return false;
921 }
922 }
923
924 private:
925 /*
926 possible decisions by get_mts_execution_mode().
927 The execution mode can be PARALLEL or not (thereby sequential
928 unless impossible at all). When it's sequential it further breaks into
929 ASYNChronous and SYNChronous.
930 */
932 /*
933 Event is run by a Worker.
934 */
936 /*
937 Event is run by Coordinator.
938 */
940 /*
941 Event is run by Coordinator and requires synchronization with Workers.
942 */
944 /*
945 Event can't be executed neither by Workers nor Coordinator.
946 */
948 };
949
950 /**
951 MTS Coordinator finds out a way how to execute the current event.
952
953 Besides the parallelizable case, some events have to be applied by
954 Coordinator concurrently with Workers and some to require synchronization
955 with Workers (@c see wait_for_workers_to_finish) before to apply them.
956
957 @param mts_in_group the being group parsing status, true
958 means inside the group
959
960 @retval EVENT_EXEC_PARALLEL if event is executed by a Worker
961 @retval EVENT_EXEC_ASYNC if event is executed by Coordinator
962 @retval EVENT_EXEC_SYNC if event is executed by Coordinator
963 with synchronization against the Workers
964 */
965 enum enum_mts_event_exec_mode get_mts_execution_mode(bool mts_in_group) {
966 /*
967 Slave workers are unable to handle Format_description_log_event,
968 Rotate_log_event and Previous_gtids_log_event correctly.
969 However, when a transaction spans multiple relay logs, these
970 events occur in the middle of a transaction. The way we handle
971 this is by marking the events as 'ASYNC', meaning that the
972 coordinator thread will handle the events without stopping the
973 worker threads.
974
975 @todo Refactor this: make Log_event::get_slave_worker handle
976 transaction boundaries in a more robust way, so that it is able
977 to process Format_description_log_event, Rotate_log_event, and
978 Previous_gtids_log_event. Then, when these events occur in the
979 middle of a transaction, make them part of the transaction so
980 that the worker that handles the transaction handles these
981 events too. /Sven
982 */
983 if (
984 /*
985 When a Format_description_log_event occurs in the middle of
986 a transaction, it either has the slave's server_id, or has
987 end_log_pos==0.
988
989 @todo This does not work when master and slave have the same
990 server_id and replicate-same-server-id is enabled, since
991 events that are not in the middle of a transaction will be
992 executed in ASYNC mode in that case.
993 */
995 ((server_id == (uint32)::server_id) ||
996 (common_header->log_pos == 0))) ||
997 /*
998 All Previous_gtids_log_events in the relay log are generated
999 by the slave. They don't have any meaning to the applier, so
1000 they can always be ignored by the applier. So we can process
1001 them asynchronously by the coordinator. It is also important
1002 to not feed them to workers because that confuses
1003 get_slave_worker.
1004 */
1006 /*
1007 Rotate_log_event can occur in the middle of a transaction.
1008 When this happens, either it is a Rotate event generated on
1009 the slave which has the slave's server_id, or it is a Rotate
1010 event that originates from a master but has end_log_pos==0.
1011 */
1013 ((server_id == (uint32)::server_id) ||
1014 (common_header->log_pos == 0 && mts_in_group))))
1015 return EVENT_EXEC_ASYNC;
1016 else if (is_mts_sequential_exec())
1017 return EVENT_EXEC_SYNC;
1018 else
1019 return EVENT_EXEC_PARALLEL;
1020 }
1021
1022 /**
1023 @return index in [0, M] range to indicate
1024 to be assigned worker;
1025 M is the max index of the worker pool.
1026 */
1028
1029 /*
1030 Group of events can be marked to force its execution
1031 in isolation from any other Workers.
1032 Typically that is done for a transaction that contains
1033 a query accessing more than OVER_MAX_DBS_IN_EVENT_MTS databases.
1034 Factually that's a sequential mode where a Worker remains to
1035 be the applier.
1036 */
1037 virtual void set_mts_isolate_group() {
1038 assert(ends_group() ||
1042 }
1043
1044 public:
1045 /**
1046 The method fills in pointers to event's database name c-strings
1047 to a supplied array.
1048 In other than Query-log-event case the returned array contains
1049 just one item.
1050 @param[out] arg pointer to a struct containing char* array
1051 pointers to be filled in and the number
1052 of filled instances.
1053 @param rpl_filter pointer to a replication filter.
1054
1055 @return number of the filled instances indicating how many
1056 databases the event accesses.
1057 */
1058 virtual uint8 get_mts_dbs(Mts_db_names *arg,
1059 Rpl_filter *rpl_filter [[maybe_unused]]) {
1060 arg->name[0] = get_db();
1061
1062 return arg->num = mts_number_dbs();
1063 }
1064
1065 /**
1066 @return true if events carries partitioning data (database names).
1067 */
1068 bool contains_partition_info(bool);
1069
1070 /*
1071 @return the number of updated by the event databases.
1072
1073 @note In other than Query-log-event case that's one.
1074 */
1075 virtual uint8 mts_number_dbs() { return 1; }
1076
1077 /**
1078 @return true if the terminal event of a group is marked to
1079 execute in isolation from other Workers,
1080 false otherwise
1081 */
1082 bool is_mts_group_isolated() {
1084 }
1085
1086 /**
1087 Events of a certain type can start or end a group of events treated
1088 transactionally wrt binlog.
1089
1090 Public access is required by implementation of recovery + skip.
1091
1092 @return true if the event starts a group (transaction)
1093 false otherwise
1095#endif
1096 virtual bool starts_group() const { return false; }
1097 /**
1098 @return true if the event ends a group (transaction)
1099 false otherwise
1100 */
1101 virtual bool ends_group() const { return false; }
1102#ifdef MYSQL_SERVER
1103 /**
1104 Apply the event to the database.
1105
1106 This function represents the public interface for applying an
1107 event.
1108
1109 @see do_apply_event
1110 */
1111 int apply_event(Relay_log_info *rli);
1112
1113 /**
1114 Apply the GTID event in curr_group_data to the database.
1115
1116 @param rli Pointer to coordinato's relay log info.
1117
1118 @retval 0 success
1119 @retval 1 error
1120 */
1121 inline int apply_gtid_event(Relay_log_info *rli);
1122
1123 /**
1124 Update the relay log position.
1125
1126 This function represents the public interface for "stepping over"
1127 the event and will update the relay log information.
1128
1129 @see do_update_pos
1130 */
1131 int update_pos(Relay_log_info *rli) { return do_update_pos(rli); }
1132
1133 /**
1134 Decide if the event shall be skipped, and the reason for skipping
1135 it.
1136
1137 @see do_shall_skip
1138 */
1140 DBUG_TRACE;
1142 DBUG_PRINT("info", ("skip reason=%d=%s", ret,
1143 ret == EVENT_SKIP_NOT
1144 ? "NOT"
1145 : ret == EVENT_SKIP_IGNORE ? "IGNORE" : "COUNT"));
1146 return ret;
1147 }
1148
1149 /**
1150 Primitive to apply an event to the database.
1151
1152 This is where the change to the database is made.
1153
1154 @note The primitive is protected instead of private, since there
1155 is a hierarchy of actions to be performed in some cases.
1156
1157 @see Format_description_log_event::do_apply_event()
1158
1159 @param rli Pointer to relay log info structure
1160
1161 @retval 0 Event applied successfully
1162 @retval errno Error code if event application failed
1163 */
1164 virtual int do_apply_event(Relay_log_info const *rli [[maybe_unused]]) {
1165 return 0; /* Default implementation does nothing */
1166 }
1167
1168 virtual int do_apply_event_worker(Slave_worker *w);
1169
1170 protected:
1171 /**
1172 Helper function to ignore an event w.r.t. the slave skip counter.
1173
1174 This function can be used inside do_shall_skip() for functions
1175 that cannot end a group. If the slave skip counter is 1 when
1176 seeing such an event, the event shall be ignored, the counter
1177 left intact, and processing continue with the next event.
1178
1179 A typical usage is:
1180 @code
1181 enum_skip_reason do_shall_skip(Relay_log_info *rli) {
1182 return continue_group(rli);
1183 }
1184 @endcode
1185
1186 @return Skip reason
1187 */
1189
1190 /**
1191 Advance relay log coordinates.
1192
1193 This function is called to advance the relay log coordinates to
1194 just after the event. It is essential that both the relay log
1195 coordinate and the group log position is updated correctly, since
1196 this function is used also for skipping events.
1197
1198 Normally, each implementation of do_update_pos() shall:
1199
1200 - Update the event position to refer to the position just after
1201 the event.
1202
1203 - Update the group log position to refer to the position just
1204 after the event <em>if the event is last in a group</em>
1205
1206 @param rli Pointer to relay log info structure
1207
1208 @retval 0 Coordinates changed successfully
1209 @retval errno Error code if advancing failed (usually just
1210 1). Observe that handler errors are returned by the
1211 do_apply_event() function, and not by this one.
1212 */
1213 virtual int do_update_pos(Relay_log_info *rli);
1214
1215 /**
1216 Decide if this event shall be skipped or not and the reason for
1217 skipping it.
1218
1219 The default implementation decide that the event shall be skipped
1220 if either:
1221
1222 - the server id of the event is the same as the server id of the
1223 server and <code>rli->replicate_same_server_id</code> is true,
1224 or
1225
1226 - if <code>rli->slave_skip_counter</code> is greater than zero.
1227
1228 @see do_apply_event
1229 @see do_update_pos
1230
1231 @retval Log_event::EVENT_SKIP_NOT
1232 The event shall not be skipped and should be applied.
1233
1234 @retval Log_event::EVENT_SKIP_IGNORE
1235 The event shall be skipped by just ignoring it, i.e., the slave
1236 skip counter shall not be changed. This happends if, for example,
1237 the originating server id of the event is the same as the server
1238 id of the slave.
1239
1240 @retval Log_event::EVENT_SKIP_COUNT
1241 The event shall be skipped because the slave skip counter was
1242 non-zero. The caller shall decrease the counter by one.
1243 */
1245#endif
1246};
1247
1248/*
1249 One class for each type of event.
1250 Two constructors for each class:
1251 - one to create the event for logging (when the server acts as a master),
1252 called after an update to the database is done,
1253 which accepts parameters like the query, the database, the options for LOAD
1254 DATA INFILE...
1255 - one to create the event from a packet (when the server acts as a slave),
1256 called before reproducing the update, which accepts parameters (like a
1257 buffer). Used to read from the master, from the relay log, and in
1258 mysqlbinlog. This constructor must be format-tolerant.
1259*/
1260
1261/**
1262 A Query event is written to the binary log whenever the database is
1263 modified on the master, unless row based logging is used.
1264
1265 Query_log_event is created for logging, and is called after an update to the
1266 database is done. It is used when the server acts as the master.
1267
1268 Virtual inheritance is required here to handle the diamond problem in
1269 the class @c Execute_load_query_log_event.
1270 The diamond structure is explained in @c Excecute_load_query_log_event
1271
1272 @internal
1273 The inheritance structure is as follows:
1274
1275 Binary_log_event
1276 ^
1277 |
1278 |
1279 Query_event Log_event
1280 \ /
1281 <<virtual>>\ /
1282 \ /
1283 Query_log_event
1284 @endinternal
1285*/
1287 public Log_event {
1288 protected:
1290
1291 public:
1292 // disable copy-move semantics
1293 Query_log_event(Query_log_event &&) noexcept = delete;
1294 Query_log_event &operator=(Query_log_event &&) noexcept = delete;
1295 Query_log_event(const Query_log_event &) = delete;
1296 Query_log_event &operator=(const Query_log_event &) = delete;
1297
1298 /*
1299 For events created by Query_log_event::do_apply_event (and
1300 Load_log_event::do_apply_event()) we need the *original* thread
1301 id, to be able to log the event with the original (=master's)
1302 thread id (fix for BUG#1686).
1303 */
1305
1306 /**
1307 True if this is a ROLLBACK event injected by the mts coordinator to finish a
1308 group corresponding to a partial transaction in the relay log.
1309 False otherwise and by default, as it must be explicitly set to true by the
1310 coordinator.
1311 */
1312 bool rollback_injected_by_coord = false;
1313
1314 /**
1315 The flag indicates whether the DDL query has been (already)
1316 committed or not. It's initialized as OFF at the event instantiation,
1317 flips ON when the DDL transaction has been committed with
1318 all its possible extra statement due to replication or GTID.
1319
1320 The flag status is also checked in few places to catch uncommitted
1321 transactions which can normally happen due to filtering out. In
1322 such a case the commit is deferred to @c Log_event::do_update_pos().
1323 */
1324 bool has_ddl_committed;
1325
1326#ifdef MYSQL_SERVER
1327
1328 /**
1329 Instructs the applier to skip temporary tables handling.
1330 */
1332
1336
1339 }
1340
1341 Query_log_event(THD *thd_arg, const char *query_arg, size_t query_length,
1342 bool using_trans, bool immediate, bool suppress_use,
1343 int error, bool ignore_command = false);
1344 const char *get_db() override { return db; }
1345
1346 /**
1347 @param[out] arg pointer to a struct containing char* array
1348 pointers be filled in and the number of
1349 filled instances.
1350 In case the number exceeds MAX_DBS_IN_EVENT_MTS,
1351 the overfill is indicated with assigning the number to
1352 OVER_MAX_DBS_IN_EVENT_MTS.
1353 @param rpl_filter pointer to a replication filter.
1354
1355 @return number of databases in the array or OVER_MAX_DBS_IN_EVENT_MTS.
1356 */
1359 // the empty string db name is special to indicate sequential applying
1360 mts_accessed_db_names[0][0] = 0;
1361 } else {
1362 for (uchar i = 0; i < mts_accessed_dbs; i++) {
1363 const char *db_name = mts_accessed_db_names[i];
1364
1365 // Only default database is rewritten.
1366 if (!rpl_filter->is_rewrite_empty() && !strcmp(get_db(), db_name)) {
1367 size_t dummy_len;
1368 const char *db_filtered =
1369 rpl_filter->get_rewrite_db(db_name, &dummy_len);
1370 // db_name != db_filtered means that db_name is rewritten.
1371 if (strcmp(db_name, db_filtered)) db_name = db_filtered;
1372 }
1373 arg->name[i] = db_name;
1374 }
1375 }
1376 return arg->num = mts_accessed_dbs;
1377 }
1378
1381
1382 uchar mts_number_dbs() override { return mts_accessed_dbs; }
1383
1384 int pack_info(Protocol *protocol) override;
1385#else
1386 void print_query_header(IO_CACHE *file,
1387 PRINT_EVENT_INFO *print_event_info) const;
1388 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1389 static bool rewrite_db_in_buffer(
1390 char **buf, ulong *event_len,
1392#endif
1393
1395
1397 const char *buf,
1400 ~Query_log_event() override {
1402 }
1403
1404 void claim_memory_ownership(bool claim) override;
1405
1406#ifdef MYSQL_SERVER
1407 bool write(Basic_ostream *ostream) override;
1408 virtual bool write_post_header_for_derived(Basic_ostream *) { return false; }
1409#endif
1410
1411 /*
1412 Returns number of bytes additionally written to post header by derived
1413 events (so far it is only Execute_load_query event).
1414 */
1415 virtual ulong get_post_header_size_for_derived() { return 0; }
1416 /* Writes derived event-specific part of post header. */
1417
1418 public: /* !!! Public in this patch to allow old usage */
1419#if defined(MYSQL_SERVER)
1421 int do_apply_event(Relay_log_info const *rli) override;
1422 int do_update_pos(Relay_log_info *rli) override;
1423
1424 int do_apply_event(Relay_log_info const *rli, const char *query_arg,
1425 size_t q_len_arg);
1426#endif /* MYSQL_SERVER */
1427 /*
1428 If true, the event always be applied by slave SQL thread or be printed by
1429 mysqlbinlog
1430 */
1431 bool is_trans_keyword() const {
1432 /*
1433 Before the patch for bug#50407, The 'SAVEPOINT and ROLLBACK TO'
1434 queries input by user was written into log events directly.
1435 So the keywords can be written in both upper case and lower case
1436 together, strncasecmp is used to check both cases. they also could be
1437 binlogged with comments in the front of these keywords. for examples:
1438 / * bla bla * / SAVEPOINT a;
1439 / * bla bla * / ROLLBACK TO a;
1440 but we don't handle these cases and after the patch, both quiries are
1441 binlogged in upper case with no comments.
1442 */
1443 return !strncmp(query, "BEGIN", q_len) ||
1444 !strncmp(query, "COMMIT", q_len) ||
1445 !native_strncasecmp(query, "SAVEPOINT", 9) ||
1446 !native_strncasecmp(query, "ROLLBACK", 8) ||
1447 !native_strncasecmp(query, STRING_WITH_LEN("XA START")) ||
1449 !native_strncasecmp(query, STRING_WITH_LEN("XA PREPARE")) ||
1450 !native_strncasecmp(query, STRING_WITH_LEN("XA COMMIT")) ||
1451 !native_strncasecmp(query, STRING_WITH_LEN("XA ROLLBACK"));
1452 }
1453
1454 /**
1455 When a query log event contains a non-transaction control statement, we
1456 assume that it is changing database content (DML) and was logged using
1457 binlog_format=statement.
1458
1459 @return True the event represents a statement that was logged using SBR
1460 that can change database content.
1461 False for transaction control statements.
1462 */
1463 bool is_sbr_logging_format() const override { return !is_trans_keyword(); }
1464
1465 /**
1466 Notice, DDL queries are logged without BEGIN/COMMIT parentheses
1467 and identification of such single-query group
1468 occurs within logics of @c get_slave_worker().
1470
1471 bool starts_group() const override {
1472 return !strncmp(query, "BEGIN", q_len) ||
1473 !strncmp(query, STRING_WITH_LEN("XA START"));
1475
1476 bool ends_group() const override {
1477 return !strncmp(query, "COMMIT", q_len) ||
1478 (!native_strncasecmp(query, STRING_WITH_LEN("ROLLBACK")) &&
1479 native_strncasecmp(query, STRING_WITH_LEN("ROLLBACK TO "))) ||
1480 !strncmp(query, STRING_WITH_LEN("XA ROLLBACK"));
1481 }
1482 static size_t get_query(
1483 const char *buf, size_t length,
1485 const char **query_arg);
1486
1487 bool is_query_prefix_match(const char *pattern, uint p_len) {
1488 return !strncmp(query, pattern, p_len);
1489 }
1490
1491 /** Whether or not the statement represented by this event requires
1492 `Q_SQL_REQUIRE_PRIMARY_KEY` to be logged along aside. */
1493 bool need_sql_require_primary_key{false};
1494
1495 /** Whether or not the statement represented by this event requires
1496 `Q_DEFAULT_TABLE_ENCRYPTION` to be logged along aside. */
1498};
1499
1500/**
1501 @class Format_description_log_event
1502
1503 For binlog version 4.
1504 This event is saved by threads which read it, as they need it for future
1505 use (to decode the ordinary events).
1506 This is the subclass of Format_description_event
1507
1508 @internal
1509 The inheritance structure in the current design for the classes is
1510 as follows:
1511
1512 Binary_log_event
1513 ^
1514 |
1515 |
1516 Format_description_event Log_event
1517 \ /
1518 \ /
1519 \ /
1520 Format_description_log_event
1521 @endinternal
1522 @section Format_description_log_event_binary_format Binary Format
1524
1527 public Log_event {
1528 public:
1529 /*
1530 MTS Workers and Coordinator share the event and that affects its
1531 destruction. Instantiation is always done by Coordinator/SQL thread.
1532 Workers are allowed to destroy only "obsolete" instances, those
1533 that are not actual for Coordinator anymore but needed to Workers
1534 that are processing queued events depending on the old instance.
1535 The counter of a new FD is incremented by Coordinator or Worker at
1536 time of {Relay_log_info,Slave_worker}::set_rli_description_event()
1537 execution.
1538 In the same methods the counter of the "old" FD event is decremented
1539 and when it drops to zero the old FD is deleted.
1540 The latest read from relay-log event is to be
1541 destroyed by Coordinator/SQL thread at its thread exit.
1542 Notice the counter is processed even in the single-thread mode where
1543 decrement and increment are done by the single SQL thread.
1544 */
1545 std::atomic<int32> atomic_usage_counter{0};
1546
1549 const char *buf,
1550 const mysql::binlog::event::Format_description_event *description_event);
1551#ifdef MYSQL_SERVER
1552 bool write(Basic_ostream *ostream) override;
1553 int pack_info(Protocol *protocol) override;
1554#else
1555 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1556#endif
1557
1558 size_t get_data_size() override {
1559 /*
1560 The vector of post-header lengths is considered as part of the
1561 post-header, because in a given version it never changes (contrary to the
1562 query in a Query_log_event).
1563 */
1566 }
1567
1568 void claim_memory_ownership(bool claim) override;
1569
1570 protected:
1571#if defined(MYSQL_SERVER)
1572 int do_apply_event(Relay_log_info const *rli) override;
1573 int do_update_pos(Relay_log_info *rli) override;
1575#endif
1576};
1577
1578/**
1579 @class Intvar_log_event
1580
1581 The class derives from the class Intvar_event in Binlog API,
1582 defined in the header binlog_event.h. An Intvar_log_event is
1583 created just before a Query_log_event, if the query uses one
1584 of the variables LAST_INSERT_ID or INSERT_ID. This class is used
1585 by the slave for applying the event.
1586
1587 @internal
1588 The inheritance structure in the current design for the classes is
1589 as follows:
1590
1591 Binary_log_event
1592 ^
1593 |
1594 |
1595 Intvar_event Log_event
1596 \ /
1597 \ /
1598 \ /
1599 Intvar_log_event
1600 @endinternal
1601*/
1603 public Log_event {
1604 public:
1605 // disable copy-move semantics
1606 Intvar_log_event(Intvar_log_event &&) noexcept = delete;
1607 Intvar_log_event &operator=(Intvar_log_event &&) noexcept = delete;
1608 Intvar_log_event(const Intvar_log_event &) = delete;
1609 Intvar_log_event &operator=(const Intvar_log_event &) = delete;
1611#ifdef MYSQL_SERVER
1612 Intvar_log_event(THD *thd_arg, uchar type_arg, ulonglong val_arg,
1613 enum_event_cache_type cache_type_arg,
1614 enum_event_logging_type logging_type_arg)
1615 : mysql::binlog::event::Intvar_event(type_arg, val_arg),
1616 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1617 footer()) {
1619 }
1620 int pack_info(Protocol *protocol) override;
1621#else
1622 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1623#endif
1624
1626 const char *buf,
1627 const mysql::binlog::event::Format_description_event *description_event);
1628 ~Intvar_log_event() override = default;
1629
1630 void claim_memory_ownership(bool claim) override;
1631
1632 size_t get_data_size() override {
1633 return 9; /* sizeof(type) + sizeof(val) */
1634 ;
1635 }
1636#ifdef MYSQL_SERVER
1637 bool write(Basic_ostream *ostream) override;
1638#endif
1639
1640 bool is_sbr_logging_format() const override { return true; }
1641
1642 private:
1643#if defined(MYSQL_SERVER)
1644 int do_apply_event(Relay_log_info const *rli) override;
1645 int do_update_pos(Relay_log_info *rli) override;
1647#endif
1648};
1649
1650/**
1651 @class Rand_log_event
1652
1653 Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
1654 4.1.1 does not need it (it's repeatable again) so this event needn't be
1655 written in 4.1.1 for PASSWORD() (but the fact that it is written is just a
1656 waste, it does not cause bugs).
1657
1658 The state of the random number generation consists of 128 bits,
1659 which are stored internally as two 64-bit numbers.
1660
1661 @internal
1662 The inheritance structure in the current design for the classes is
1663 as follows:
1664 Binary_log_event
1665 ^
1666 |
1667 |
1668 Rand_event Log_event
1669 \ /
1670 \ /
1671 \ /
1672 Rand_log_event
1673 @endinternal
1674*/
1676 public Log_event {
1677 public:
1678 // disable copy-move semantics
1679 Rand_log_event(Rand_log_event &&) noexcept = delete;
1680 Rand_log_event &operator=(Rand_log_event &&) noexcept = delete;
1681 Rand_log_event(const Rand_log_event &) = delete;
1682 Rand_log_event &operator=(const Rand_log_event &) = delete;
1684#ifdef MYSQL_SERVER
1685 Rand_log_event(THD *thd_arg, ulonglong seed1_arg, ulonglong seed2_arg,
1686 enum_event_cache_type cache_type_arg,
1687 enum_event_logging_type logging_type_arg)
1688 : mysql::binlog::event::Rand_event(seed1_arg, seed2_arg),
1689 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1690 footer()) {
1692 }
1693 int pack_info(Protocol *protocol) override;
1694#else
1695 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1696#endif
1697
1699 const char *buf,
1700 const mysql::binlog::event::Format_description_event *description_event);
1701 ~Rand_log_event() override = default;
1702
1703 void claim_memory_ownership(bool claim) override;
1704
1705 size_t get_data_size() override { return 16; /* sizeof(ulonglong) * 2*/ }
1706#ifdef MYSQL_SERVER
1707 bool write(Basic_ostream *ostream) override;
1708#endif
1709
1710 bool is_sbr_logging_format() const override { return true; }
1711
1712 private:
1713#if defined(MYSQL_SERVER)
1714 int do_apply_event(Relay_log_info const *rli) override;
1715 int do_update_pos(Relay_log_info *rli) override;
1717#endif
1718};
1719
1720/**
1721 @class Xid_log_event
1722
1723 This is the subclass of Xid_event defined in libbinlogevent,
1724 An XID event is generated for a commit of a transaction that modifies one or
1725 more tables of an XA-capable storage engine
1726 Logs xid of the transaction-to-be-committed in the 2pc protocol.
1727 Has no meaning in replication, slaves ignore it
1728 The inheritance structure in the current design for the classes is
1729 as follows
1730
1731 @internal
1732 The inheritance structure in the current design for the classes is
1733 as follows:
1734 Binary_log_event
1735 ^
1736 |
1737 |
1738 Xid_event Log_event
1739 \ /
1740 \ /
1741 \ /
1742 Xid_log_event
1743 @endinternal
1744*/
1745#ifndef MYSQL_SERVER
1746typedef ulonglong my_xid; // this line is the same as in handler.h
1747#endif
1748
1749class Xid_apply_log_event : public Log_event {
1750 protected:
1751#ifdef MYSQL_SERVER
1752 Xid_apply_log_event(THD *thd_arg,
1756 Log_event::EVENT_NORMAL_LOGGING, header_arg, footer_arg) {}
1757#endif
1760 : Log_event(header_arg, footer_arg) {}
1761 ~Xid_apply_log_event() override = default;
1762 bool ends_group() const override { return true; }
1763#if defined(MYSQL_SERVER)
1765 int do_apply_event(Relay_log_info const *rli) override;
1766 int do_apply_event_worker(Slave_worker *rli) override;
1767 virtual bool do_commit(THD *thd_arg) = 0;
1768#endif
1770
1772 public Xid_apply_log_event {
1773 public:
1774 // disable copy-move semantics
1775 Xid_log_event(Xid_log_event &&) noexcept = delete;
1776 Xid_log_event &operator=(Xid_log_event &&) noexcept = delete;
1777 Xid_log_event(const Xid_log_event &) = delete;
1778 Xid_log_event &operator=(const Xid_log_event &) = delete;
1780#ifdef MYSQL_SERVER
1781 Xid_log_event(THD *thd_arg, my_xid x)
1782 : mysql::binlog::event::Xid_event(x),
1783 Xid_apply_log_event(thd_arg, header(), footer()) {
1785 }
1786 int pack_info(Protocol *protocol) override;
1787#else
1788 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1789#endif
1790
1792 const char *buf,
1793 const mysql::binlog::event::Format_description_event *description_event);
1794 ~Xid_log_event() override = default;
1795
1796 void claim_memory_ownership(bool claim) override;
1797
1798 size_t get_data_size() override { return sizeof(xid); }
1799#ifdef MYSQL_SERVER
1800 bool write(Basic_ostream *ostream) override;
1801#endif
1802 private:
1803#if defined(MYSQL_SERVER)
1804 bool do_commit(THD *thd_arg) override;
1805#endif
1806};
1807
1808/**
1809 @class XA_prepare_log_event
1810
1811 Similar to Xid_log_event except that
1812 - it is specific to XA transaction
1813 - it carries out the prepare logics rather than the final committing
1814 when @c one_phase member is off.
1815 From the groupping perspective the event finalizes the current "prepare" group
1816 started with XA START Query-log-event.
1817 When @c one_phase is false Commit of Rollback for XA transaction are
1818 logged separately to the prepare-group events so being a groups of
1819 their own.
1821
1823 public Xid_apply_log_event {
1824 private:
1825 /* Total size of buffers to hold serialized members of XID struct */
1826 static const int xid_bufs_size = 12;
1827
1828 public:
1829#ifdef MYSQL_SERVER
1830 XA_prepare_log_event(THD *thd_arg, XID *xid_arg, bool one_phase_arg = false)
1831 : mysql::binlog::event::XA_prepare_event((void *)xid_arg, one_phase_arg),
1833#endif
1835 const char *buf,
1836 const mysql::binlog::event::Format_description_event *description_event)
1837 : mysql::binlog::event::XA_prepare_event(buf, description_event),
1839 DBUG_TRACE;
1840 xid = nullptr;
1841 return;
1842 }
1845 }
1846 size_t get_data_size() override {
1847 return xid_bufs_size + my_xid.gtrid_length + my_xid.bqual_length;
1848 }
1849
1850 void claim_memory_ownership(bool claim) override;
1851
1852#ifdef MYSQL_SERVER
1853 bool write(Basic_ostream *ostream) override;
1854#else
1855 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1856#endif
1857#if defined(MYSQL_SERVER)
1858 int pack_info(Protocol *protocol) override;
1859 bool do_commit(THD *thd) override;
1860#endif
1861};
1862
1863/**
1864 @class User_var_log_event
1865
1866 Every time a query uses the value of a user variable, a User_var_log_event is
1867 written before the Query_log_event, to set the user variable.
1868
1869 @internal
1870 The inheritance structure in the current design for the classes is
1871 as follows:
1872 Binary_log_event
1873 ^
1874 |
1875 |
1876 User_var_event Log_event
1877 \ /
1878 \ /
1879 \ /
1880 User_var_log_event
1881 @endinternal
1882*/
1884 public Log_event {
1885 public:
1886 // disable copy-move semantics
1888 User_var_log_event &operator=(User_var_log_event &&) noexcept = delete;
1889 User_var_log_event(const User_var_log_event &) = delete;
1890 User_var_log_event &operator=(const User_var_log_event &) = delete;
1892#ifdef MYSQL_SERVER
1895 User_var_log_event(THD *thd_arg, const char *name_arg, uint name_len_arg,
1896 char *val_arg, ulong val_len_arg, Item_result type_arg,
1897 uint charset_number_arg, uchar flags_arg,
1898 enum_event_cache_type cache_type_arg,
1899 enum_event_logging_type logging_type_arg)
1900 : mysql::binlog::event::User_var_event(name_arg, name_len_arg, val_arg,
1901 val_len_arg, type_arg,
1902 charset_number_arg, flags_arg),
1903 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1904 footer()),
1905 deferred(false) {
1906 common_header->set_is_valid(name != nullptr);
1907 }
1908 int pack_info(Protocol *protocol) override;
1909#else
1910 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1911#endif
1912
1914 const char *buf,
1915 const mysql::binlog::event::Format_description_event *description_event);
1916 ~User_var_log_event() override = default;
1917
1918 void claim_memory_ownership(bool claim) override;
1919
1920#ifdef MYSQL_SERVER
1921 bool write(Basic_ostream *ostream) override;
1922 /*
1923 Getter and setter for deferred User-event.
1924 Returns true if the event is not applied directly
1925 and which case the applier adjusts execution path.
1926 */
1927 bool is_deferred() { return deferred; }
1928 /*
1929 In case of the deferred applying the variable instance is flagged
1930 and the parsing time query id is stored to be used at applying time.
1931 */
1932 void set_deferred(query_id_t qid) {
1933 deferred = true;
1934 query_id = qid;
1935 }
1936#endif
1937
1938 bool is_sbr_logging_format() const override { return true; }
1939
1940 private:
1941#if defined(MYSQL_SERVER)
1942 int do_apply_event(Relay_log_info const *rli) override;
1943 int do_update_pos(Relay_log_info *rli) override;
1945#endif
1946};
1947
1948/**
1949 @class Stop_log_event
1951*/
1953 public Log_event {
1954 public:
1955 // disable copy-move semantics
1956 Stop_log_event(Stop_log_event &&) noexcept = delete;
1957 Stop_log_event &operator=(Stop_log_event &&) noexcept = delete;
1958 Stop_log_event(const Stop_log_event &) = delete;
1959 Stop_log_event &operator=(const Stop_log_event &) = delete;
1961#ifdef MYSQL_SERVER
1966 }
1967
1968#else
1969 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1970#endif
1971
1973 const char *buf,
1974 const mysql::binlog::event::Format_description_event *description_event)
1975 : mysql::binlog::event::Stop_event(buf, description_event),
1976 Log_event(header(), footer()) {
1977 DBUG_TRACE;
1978 return;
1981 ~Stop_log_event() override = default;
1984 }
1985
1986 void claim_memory_ownership(bool claim) override;
1987
1988 private:
1989#if defined(MYSQL_SERVER)
1990 int do_update_pos(Relay_log_info *rli) override;
1992 /*
1993 Events from ourself should be skipped, but they should not
1994 decrease the slave skip counter.
1995 */
1996 if (this->server_id == ::server_id)
1998 else
2000 }
2001#endif
2002};
2003
2004/**
2005 @class Rotate_log_event
2006
2007 This will be deprecated when we move to using sequence ids.
2008 This class is a subclass of Rotate_event, defined in binlogevent, and is used
2009 by the slave for updating the position in the relay log.
2010
2011 It is used by the master inorder to write the rotate event in the binary log.
2012
2013 @internal
2014 The inheritance structure in the current design for the classes is
2015 as follows:
2016
2017 Binary_log_event
2018 ^
2019 |
2020 |
2021 Rotate_event Log_event
2022 \ /
2023 \ /
2024 \ /
2025 Rotate_log_event
2026 @endinternal
2027*/
2029 public Log_event {
2030 public:
2031 // disable copy-move semantics
2032 Rotate_log_event(Rotate_log_event &&) noexcept = delete;
2033 Rotate_log_event &operator=(Rotate_log_event &&) noexcept = delete;
2034 Rotate_log_event(const Rotate_log_event &) = delete;
2035 Rotate_log_event &operator=(const Rotate_log_event &) = delete;
2036
2037#ifdef MYSQL_SERVER
2038 Rotate_log_event(const char *new_log_ident_arg, size_t ident_len_arg,
2039 ulonglong pos_arg, uint flags);
2040 int pack_info(Protocol *protocol) override;
2041#else
2042 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2043#endif
2044
2046 const char *buf,
2048 ~Rotate_log_event() override = default;
2049 size_t get_data_size() override {
2050 return ident_len +
2052 }
2053
2054 void claim_memory_ownership(bool claim) override;
2055
2056#ifdef MYSQL_SERVER
2057 bool write(Basic_ostream *ostream) override;
2058#endif
2059
2060 private:
2061#if defined(MYSQL_SERVER)
2062 int do_update_pos(Relay_log_info *rli) override;
2064#endif
2065};
2066
2067/**
2068 @class Append_block_log_event
2069
2070 This event is created to contain the file data. One LOAD_DATA_INFILE
2071 can have 0 or more instances of this event written to the binary log
2072 depending on the size of the file.
2073
2074 @internal
2075 The inheritance structure is as follows
2076
2077 Binary_log_event
2078 ^
2079 |
2080 |
2081 B_l:A_B_E Log_event
2082 \ /
2083 \ /
2084 <<vir>>\ /
2085 \ /
2086 Append_block_log_event
2087 B_l: Namespace Binary_log
2088 A_B_E: class Append_block_event
2089 @endinternal
2091*/
2094 public Log_event {
2095 public:
2096 // disable copy-move semantics
2097 Append_block_log_event(Append_block_log_event &&) noexcept = delete;
2099 delete;
2101 Append_block_log_event &operator=(const Append_block_log_event &) = delete;
2102
2103#ifdef MYSQL_SERVER
2104 Append_block_log_event(THD *thd, const char *db_arg, uchar *block_arg,
2105 uint block_len_arg, bool using_trans);
2106 int pack_info(Protocol *protocol) override;
2107 virtual int get_create_or_append() const;
2108#else
2109 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2110#endif
2111
2113 const char *buf,
2114 const mysql::binlog::event::Format_description_event *description_event);
2115 ~Append_block_log_event() override = default;
2116
2117 void claim_memory_ownership(bool claim) override;
2118
2119 size_t get_data_size() override {
2120 return block_len +
2122 }
2123#ifdef MYSQL_SERVER
2124 bool write(Basic_ostream *ostream) override;
2125 const char *get_db() override { return db; }
2126#endif
2127
2128 bool is_sbr_logging_format() const override { return true; }
2129
2130 private:
2131#if defined(MYSQL_SERVER)
2132 int do_apply_event(Relay_log_info const *rli) override;
2133#endif
2134};
2135
2136/**
2137 @class Delete_file_log_event
2138
2139 Delete_file_log_event is created when the LOAD_DATA query fails on the
2140 master for some reason, and the slave should be notified to abort the
2141 load. The event is required since the master starts writing the loaded
2142 block into the binary log before the statement ends. In case of error,
2143 the slave should abort, and delete any temporary file created while
2144 applying the (NEW_)LOAD_EVENT.
2145
2146 @internal
2147 The inheritance structure is as follows
2148
2149 Binary_log_event
2150 ^
2151 |
2152 |
2153 B_l:D_F_E Log_event
2154 \ /
2155 \ /
2156 \ /
2157 \ /
2158 Delete_file_log_event
2159
2160 B_l: Namespace Binary_log
2161 D_F_E: class Delete_file_event
2162 @endinternal
2164*/
2166 public Log_event {
2167 public:
2168 // disable copy-move semantics
2170 Delete_file_log_event &operator=(Delete_file_log_event &&) noexcept = delete;
2172 Delete_file_log_event &operator=(const Delete_file_log_event &) = delete;
2173
2174#ifdef MYSQL_SERVER
2175 Delete_file_log_event(THD *thd, const char *db_arg, bool using_trans);
2176 int pack_info(Protocol *protocol) override;
2177#else
2178 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2179 void print(FILE *file, PRINT_EVENT_INFO *print_event_info, bool enable_local);
2180#endif
2181
2183 const char *buf,
2184 const mysql::binlog::event::Format_description_event *description_event);
2185 ~Delete_file_log_event() override = default;
2186
2187 void claim_memory_ownership(bool claim) override;
2188
2189 size_t get_data_size() override {
2191 }
2192#ifdef MYSQL_SERVER
2193 bool write(Basic_ostream *ostream) override;
2194 const char *get_db() override { return db; }
2195#endif
2196
2197 bool is_sbr_logging_format() const override { return true; }
2198
2199 private:
2200#if defined(MYSQL_SERVER)
2201 int do_apply_event(Relay_log_info const *rli) override;
2202#endif
2203};
2204
2205/**
2206 @class Begin_load_query_log_event
2207
2208 Event for the first block of file to be loaded, its only difference from
2209 Append_block event is that this event creates or truncates existing file
2210 before writing data.
2211
2212 @internal
2213 The inheritance structure is as follows
2214
2215 Binary_log_event
2216 ^
2217 |
2218 |
2219 |
2220 Log_event B_l:A_B_E
2221 ^ /\
2222 | / \
2223 | <<vir>>/ \ <<vir>>
2224 | / \
2225 | / \
2226 | / \
2227 Append_block_log_event B_l:B_L_Q_E
2228 \ /
2229 \ /
2230 \ /
2231 \ /
2232 \ /
2233 Begin_load_query_log_event
2234
2235 B_l: Namespace Binary_log
2236 A_B_E: class Append_block_event
2237 B_L_Q_E: Begin_load_query_event
2238 @endinternal
2239
2240 @section Begin_load_query_log_event_binary_format Binary Format
2241*/
2243 : public Append_block_log_event,
2245 public:
2246 // disable copy-move semantics
2249 Begin_load_query_log_event &&) noexcept = delete;
2252 delete;
2253
2254#ifdef MYSQL_SERVER
2255 Begin_load_query_log_event(THD *thd_arg, const char *db_arg, uchar *block_arg,
2256 uint block_len_arg, bool using_trans);
2258 int get_create_or_append() const override;
2259#endif
2261 const char *buf,
2262 const mysql::binlog::event::Format_description_event *description_event);
2263 ~Begin_load_query_log_event() override = default;
2264
2265 void claim_memory_ownership(bool claim) override;
2266
2267 private:
2268#if defined(MYSQL_SERVER)
2270#endif
2271};
2272
2273/**
2274 @class Execute_load_query_log_event
2275
2276 Event responsible for LOAD DATA execution, it similar to Query_log_event
2277 but before executing the query it substitutes original filename in LOAD DATA
2278 query with name of temporary file.
2279
2280 @internal
2281 The inheritance structure is as follows:
2282
2283 Binary_log_event
2284 ^
2285 |
2286 |
2287 |
2288 Log_event B_l:Query_event
2289 ^ /\
2290 | / \
2291 | <<vir>>/ \ <<vir>>
2292 | / \
2293 | / \
2294 | / \
2295 Query_log_event B_l:E_L_Q_E
2296 \ /
2297 \ /
2298 \ /
2299 \ /
2300 \ /
2301 Execute_load_query_log_event
2302
2303 B_l: Namespace Binary_log
2304 E_L_Q_E: class Execute_load_query
2305 @endinternal
2306
2307 @section Execute_load_query_log_event_binary_format Binary Format
2308*/
2310 : public Query_log_event,
2312 public:
2313#ifdef MYSQL_SERVER
2315 THD *thd, const char *query_arg, ulong query_length,
2316 uint fn_pos_start_arg, uint fn_pos_end_arg,
2318 bool using_trans, bool immediate, bool suppress_use, int errcode);
2319 int pack_info(Protocol *protocol) override;
2320#else
2321 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2322 /* Prints the query as LOAD DATA LOCAL and with rewritten filename */
2323 void print(FILE *file, PRINT_EVENT_INFO *print_event_info,
2324 const char *local_fname) const;
2325#endif
2327 const char *buf,
2328 const mysql::binlog::event::Format_description_event *description_event);
2329 ~Execute_load_query_log_event() override = default;
2330
2331 ulong get_post_header_size_for_derived() override;
2332#ifdef MYSQL_SERVER
2333 bool write_post_header_for_derived(Basic_ostream *ostream) override;
2334#endif
2335
2336 bool is_sbr_logging_format() const override { return true; }
2337
2338 void claim_memory_ownership(bool claim) override;
2339
2340 private:
2341#if defined(MYSQL_SERVER)
2342 int do_apply_event(Relay_log_info const *rli) override;
2343#endif
2344};
2346#if defined MYSQL_SERVER
2348 public:
2349 Load_query_generator(THD *thd_arg, const sql_exchange *ex, const char *db_arg,
2350 const char *table_name_arg, bool is_concurrent_arg,
2351 bool replace, bool ignore);
2352
2353 const String *generate(size_t *fn_start, size_t *fn_end);
2355 private:
2356 const size_t BUF_SIZE = 2048;
2357 String str;
2358 char *buf[2048];
2362 const char *db;
2363 const char *table_name;
2364 const char *fname;
2367 bool has_replace;
2368 bool has_ignore;
2369};
2370#endif
2371#ifndef MYSQL_SERVER
2372/**
2373 @class Unknown_log_event
2374
2375*/
2376class Unknown_log_event : public mysql::binlog::event::Unknown_event,
2377 public Log_event {
2378 public:
2379 // disable copy-move semantics
2380 Unknown_log_event(Unknown_log_event &&) noexcept = delete;
2381 Unknown_log_event &operator=(Unknown_log_event &&) noexcept = delete;
2382 Unknown_log_event(const Unknown_log_event &) = delete;
2383 Unknown_log_event &operator=(const Unknown_log_event &) = delete;
2384
2385 /**
2386 Even if this is an unknown event, we still pass description_event to
2387 Log_event's ctor, this way we can extract maximum information from the
2388 event's header (the unique ID for example).
2389 */
2390 Unknown_log_event(
2391 const char *buf,
2392 const mysql::binlog::event::Format_description_event *description_event)
2393 : mysql::binlog::event::Unknown_event(buf, description_event),
2394 Log_event(header(), footer()) {
2395 DBUG_TRACE;
2396 if (!is_valid()) return;
2397 common_header->set_is_valid(true);
2398 return;
2399 }
2400
2401 ~Unknown_log_event() override = default;
2402 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2405 }
2406};
2407#endif
2408char *str_to_hex(char *to, const char *from, size_t len);
2409
2410/**
2411 @class Table_map_log_event
2412
2413 Table_map_log_event which maps a table definition to a number.
2414
2415 @internal
2416 The inheritance structure in the current design for the classes is
2417 as follows:
2418
2419 Binary_log_event
2420 ^
2421 |
2422 |
2423 Table_map_event Log_event
2424 \ /
2425 \ /
2426 \ /
2427 Table_map_log_event
2428 @endinternal
2429*/
2431 public Log_event {
2432 public:
2433 // disable copy-move semantics
2435 Table_map_log_event &operator=(Table_map_log_event &&) noexcept = delete;
2436 Table_map_log_event(const Table_map_log_event &) = delete;
2437 Table_map_log_event &operator=(const Table_map_log_event &) = delete;
2439 /** Constants */
2441
2442 /**
2443 Enumeration of the errors that can be returned.
2446 ERR_OPEN_FAILURE = -1, /**< Failure to open table */
2447 ERR_OK = 0, /**< No error */
2448 ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
2449 ERR_OUT_OF_MEM = 2, /**< Out of memory */
2450 ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
2451 ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
2453
2454 enum enum_flag {
2455 /**
2456 Nothing here right now, but the flags support is there in
2457 preparation for changes that are coming. Need to add a
2458 constant to make it compile under HP-UX: aCC does not like
2459 empty enumerations.
2462 };
2463
2464 /** Special constants representing sets of flags */
2465 enum {
2467 TM_BIT_LEN_EXACT_F = (1U << 0),
2468 TM_REFERRED_FK_DB_F = (1U << 1),
2469 /**
2470 Table has generated invisible primary key. MySQL generates primary key
2471 while creating a table if sql_generate_invisible_primary_key is "ON" and
2472 table is PK-less.
2474 TM_GENERATED_INVISIBLE_PK_F = (1U << 2)
2476
2477 flag_set get_flags(flag_set flag) const { return m_flags & flag; }
2478
2479#ifdef MYSQL_SERVER
2480 Table_map_log_event(THD *thd_arg, TABLE *tbl,
2482 bool using_trans);
2483#endif
2485 const char *buf,
2486 const mysql::binlog::event::Format_description_event *description_event);
2487
2488 void claim_memory_ownership(bool claim) override;
2489
2490 ~Table_map_log_event() override;
2491
2492#ifndef MYSQL_SERVER
2493 table_def *create_table_def() {
2494 assert(m_colcnt > 0);
2495 uint vector_column_count =
2497 std::vector<unsigned int> vector_dimensionality;
2498 if (vector_column_count > 0) {
2501 vector_dimensionality = fields.m_vector_dimensionality;
2502 }
2505 vector_dimensionality);
2506 }
2507 static bool rewrite_db_in_buffer(
2508 char **buf, ulong *event_len,
2510#endif
2514 const char *get_table_name() const { return m_tblnam.c_str(); }
2515 const char *get_db_name() const { return m_dbnam.c_str(); }
2516
2517 size_t get_data_size() override { return m_data_size; }
2518#ifdef MYSQL_SERVER
2519 virtual int save_field_metadata();
2520 bool write_data_header(Basic_ostream *ostream) override;
2521 bool write_data_body(Basic_ostream *ostream) override;
2522 const char *get_db() override { return m_dbnam.c_str(); }
2523 uint8 mts_number_dbs() override {
2525 }
2526 /**
2527 @param[out] arg pointer to a struct containing char* array
2528 pointers be filled in and the number of filled instances.
2529 @param rpl_filter pointer to a replication filter.
2530
2531 @return number of databases in the array: either one or
2532 OVER_MAX_DBS_IN_EVENT_MTS, when the Table map event reports
2533 foreign keys constraint.
2534 */
2536 const char *db_name = get_db();
2537
2539 size_t dummy_len;
2540 const char *db_filtered = rpl_filter->get_rewrite_db(db_name, &dummy_len);
2541 // db_name != db_filtered means that db_name is rewritten.
2542 if (strcmp(db_name, db_filtered)) db_name = db_filtered;
2543 }
2544
2545 if (!get_flags(TM_REFERRED_FK_DB_F)) arg->name[0] = db_name;
2546
2547 return arg->num = mts_number_dbs();
2548 }
2549
2550#endif
2551
2552#if defined(MYSQL_SERVER)
2553 int pack_info(Protocol *protocol) override;
2554#endif
2555
2556#ifndef MYSQL_SERVER
2557 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2558
2559 /**
2560 Print column metadata. Its format looks like:
2561 # Columns(colume_name type, colume_name type, ...)
2562 if colume_name field is not logged into table_map_log_event, then
2563 only type is printed.
2564
2565 @param[out] file the place where colume metadata is printed
2566 @param[in] fields The metadata extracted from optional metadata fields
2567 */
2568 void print_columns(IO_CACHE *file,
2569 const Optional_metadata_fields &fields) const;
2570 /**
2571 Print primary information. Its format looks like:
2572 # Primary Key(colume_name, column_name(prifix), ...)
2573 if colume_name field is not logged into table_map_log_event, then
2574 colume index is printed.
2575
2576 @param[out] file the place where primary key is printed
2577 @param[in] fields The metadata extracted from optional metadata fields
2578 */
2579 void print_primary_key(IO_CACHE *file,
2580 const Optional_metadata_fields &fields) const;
2581#endif
2582
2584
2585 bool is_rbr_logging_format() const override { return true; }
2586
2587 private:
2588#if defined(MYSQL_SERVER)
2589 int do_apply_event(Relay_log_info const *rli) override;
2590 int do_update_pos(Relay_log_info *rli) override;
2592#endif
2594#ifdef MYSQL_SERVER
2595 TABLE *m_table;
2597 // Metadata fields buffer
2599
2600 /**
2601 Wrapper around `TABLE *m_table` that abstracts the table field set iteration
2602 logic, since it is not mandatory that all table fields are to be
2603 replicated. For details, @see ReplicatedColumnsView class documentation.
2604
2605 A smart pointer is used here as the developer might want to instantiate the
2606 view using different classes in runtime depending on the given context.
2607 As of now the column view is only used on outbound scenarios
2608 */
2610
2611 /**
2612 Capture the optional metadata fields which should be logged into
2613 table_map_log_event and serialize them into m_metadata_buf.
2614 */
2615 void init_metadata_fields();
2616 bool init_signedness_field();
2617 /**
2618 Capture and serialize character sets. Character sets for
2619 character columns (TEXT etc) and character sets for ENUM and SET
2620 columns are stored in different metadata fields. The reason is
2621 that TEXT character sets are included even when
2622 binlog_row_metadata=MINIMAL, whereas ENUM and SET character sets
2623 are included only when binlog_row_metadata=FULL.
2624
2625 @param include_type Predicate to determine if a given Field object
2626 is to be included in the metadata field.
2627
2628 @param default_charset_type Type code when storing in "default
2629 charset" format. (See comment above Table_maps_log_event in
2630 mysql/binlog/event/rows_event.h)
2631
2632 @param column_charset_type Type code when storing in "column
2633 charset" format. (See comment above Table_maps_log_event in
2634 mysql/binlog/event/rows_event.h)
2635 */
2636 bool init_charset_field(std::function<bool(const Field *)> include_type,
2637 Optional_metadata_field_type default_charset_type,
2638 Optional_metadata_field_type column_charset_type);
2646#endif
2647
2648#ifndef MYSQL_SERVER
2649 class Charset_iterator;
2650 class Default_charset_iterator;
2651 class Column_charset_iterator;
2652#endif
2653};
2654
2655#ifdef HAVE_PSI_STAGE_INTERFACE
2656/*
2657 Helper class for PSI context while applying a Rows_log_event.
2658 */
2660 private:
2663
2664 /**
2665 A cached pointer to this stage PSI_stage_progress.
2666 */
2668
2669 /**
2670 Counter that is unconditionally incremented on each row that is processed.
2671 This is helpful in case estimation is needed after started processing
2672 a Rows_log_event.
2673 */
2676 public:
2678
2679 void set_progress(PSI_stage_progress *progress) { m_progress = progress; }
2680
2681 /**
2682 If instrumentation is enabled this member function SHALL return true.
2683 @return true if instrumentation is enabled for the given stage, false
2684 otherwise.
2685 */
2686 bool is_enabled() { return m_progress != nullptr; }
2687
2688 /**
2689 This member function shall update the progress and reestimate the remaining
2690 work needed. This MUST be called after setting n_rows_applied correctly
2691 by calling inc_n_rows_applied beforehand.
2692
2693 Cursor, begin and end are used in case estimation is needed.
2694
2695 @param cursor Pointer to where we are in the buffer of rows to be processed.
2696 @param begin Pointer to the beginning of the rows buffer.
2697 @param end Pointer to the end of the rows buffer.
2698 */
2699 void update_work_estimated_and_completed(const uchar *cursor,
2700 const uchar *begin,
2701 const uchar *end) {
2702 if (!is_enabled()) return;
2703
2705
2706 /* Estimate if need be. */
2707 if (estimated == 0) {
2708 assert(cursor > begin);
2709 const ulonglong avg_row_change_size = (cursor - begin) / m_n_rows_applied;
2710 estimated = (end - begin) / avg_row_change_size;
2712 }
2713
2714 /* reset estimated if done more work than estimated */
2715 if (m_n_rows_applied > estimated)
2718 }
2719
2720 /**
2721 Resets this object.
2722 */
2723 void end_work() {
2724 m_progress = nullptr;
2725 m_n_rows_applied = 0;
2726 }
2727
2728 /**
2729 Updates the counter of processed rows.
2730 @param delta the amount of increment to be done.
2731 */
2732 void inc_n_rows_applied(ulonglong delta) { m_n_rows_applied += delta; }
2733
2734 /**
2735 Gets the value of the counter of rows that have been processed.
2736 @return the value of the counter of rows processed so far.
2737 */
2739};
2740#endif
2741
2742/**
2743 @class Rows_log_event
2744
2745 Common base class for all row-containing log events.
2746
2747 RESPONSIBILITIES
2748
2749 Encode the common parts of all events containing rows, which are:
2750 - Write data header and data body to an IO_CACHE.
2751
2752 Virtual inheritance is required here to handle the diamond problem in
2753 the class Write_rows_log_event, Update_rows_log_event and
2754 Delete_rows_log_event.
2755 The diamond structure is explained in @c Write_rows_log_event,
2756 @c Update_rows_log_event,
2757 @c Delete_rows_log_event
2758
2759 @internal
2760 The inheritance structure in the current design for the classes is
2761 as follows:
2762
2763 Binary_log_event
2764 ^
2765 |
2766 |
2767 Rows_event Log_event
2768 \ /
2769 <<vir>>\ /
2770 \ /
2771 Rows_log_event
2772 @endinternal
2774*/
2776 public Log_event {
2777#ifdef HAVE_PSI_STAGE_INTERFACE
2778 protected:
2780#endif
2781
2782 public:
2783 // disable copy-move semantics
2784 Rows_log_event(Rows_log_event &&) noexcept = delete;
2785 Rows_log_event &operator=(Rows_log_event &&) noexcept = delete;
2786 Rows_log_event(const Rows_log_event &) = delete;
2787 Rows_log_event &operator=(const Rows_log_event &) = delete;
2788
2797 };
2798
2799 /**
2800 Enumeration of the errors that can be returned.
2803 ERR_OPEN_FAILURE = -1, /**< Failure to open table */
2804 ERR_OK = 0, /**< No error */
2805 ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
2806 ERR_OUT_OF_MEM = 2, /**< Out of memory */
2807 ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
2808 ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
2809 };
2811 /* Special constants representing sets of flags */
2812 enum { RLE_NO_FLAGS = 0U };
2813
2816 void set_flags(flag_set flags_arg) { m_flags |= flags_arg; }
2817 void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
2818 flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
2821 get_general_type_code() = 0; /* General rows op type, no version */
2822
2823#if defined(MYSQL_SERVER)
2824 int pack_info(Protocol *protocol) override;
2825#endif
2826
2827#ifndef MYSQL_SERVER
2828 void print_verbose(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info);
2829 size_t print_verbose_one_row(IO_CACHE *file, table_def *td,
2830 PRINT_EVENT_INFO *print_event_info,
2831 MY_BITMAP *cols_bitmap, const uchar *ptr,
2832 const uchar *prefix,
2833 enum_row_image_type row_image_type);
2834#endif
2836#ifdef MYSQL_SERVER
2837 int add_row_data(uchar *data, size_t length) {
2838 return do_add_row_data(data, length);
2839 }
2840#endif
2841
2842 /* Member functions to implement superclass interface */
2843 size_t get_data_size() override;
2845 MY_BITMAP const *get_cols() const { return &m_cols; }
2846 MY_BITMAP const *get_cols_ai() const { return &m_cols_ai; }
2848 return m_table_id;
2849 }
2850
2851#if defined(MYSQL_SERVER)
2852 /**
2853 Compares the table's read/write_set with the columns included in
2854 this event's before-image and/or after-image. Each subclass
2855 (Write/Update/Delete) implements this function by comparing on the
2856 image(s) pertinent to the subclass.
2857
2858 @param[in] table The table to compare this events bitmaps
2859 against.
2860
2861 @retval true if sets match
2862 @retval false otherwise (following bitmap_cmp return logic).
2863 */
2864 virtual bool read_write_bitmaps_cmp(const TABLE *table) const = 0;
2865#endif
2866
2867#ifdef MYSQL_SERVER
2868 bool write_data_header(Basic_ostream *ostream) override;
2869 bool write_data_body(Basic_ostream *ostream) override;
2870 const char *get_db() override { return m_table->s->db.str; }
2871#endif
2872
2873 uint m_row_count; /* The number of rows added to the event */
2874
2875 protected:
2876 /*
2877 The constructors are protected since you're supposed to inherit
2878 this class, not create instances of this class.
2879 */
2880#ifdef MYSQL_SERVER
2882 MY_BITMAP const *cols, bool is_transactional,
2884 const unsigned char *extra_row_ndb_info);
2885#endif
2887 const char *row_data,
2888 const mysql::binlog::event::Format_description_event *description_event);
2889
2890#ifndef MYSQL_SERVER
2891 void print_helper(FILE *, PRINT_EVENT_INFO *) const;
2892#endif
2893
2894#ifdef MYSQL_SERVER
2895 virtual int do_add_row_data(uchar *data, size_t length);
2896#endif
2898#ifdef MYSQL_SERVER
2899 TABLE *m_table; /* The table the rows belong to */
2900#endif
2901 MY_BITMAP m_cols; /* Bitmap denoting columns available */
2902 /**
2903 Bitmap denoting columns available in the image as they appear in the table
2904 setup. On some setups, the number and order of columns may differ from
2905 master to slave so, a bitmap for local available columns is computed using
2906 `ReplicatedColumnsView` utility class.
2907 */
2909#ifdef MYSQL_SERVER
2910 /**
2911 Hash table that will hold the entries for while using HASH_SCAN
2912 algorithm to search and update/delete rows.
2913 */
2915
2916 /**
2917 The algorithm to use while searching for rows using the before
2918 image.
2919 */
2921#endif
2922 /**
2923 Bitmap for columns available in the after image, if present. These
2924 fields are only available for Update_rows events. Observe that the
2925 width of both the before image COLS vector and the after image
2926 COLS vector is the same: the number of columns of the table on the
2927 master.
2928 */
2930 /**
2931 Bitmap denoting columns available in the after-image as they appear in the
2932 table setup. On some setups, the number and order of columns may differ from
2933 master to slave so, a bitmap for local available columns is computed using
2934 `ReplicatedColumnsView` utility class.
2935 */
2938 /* Bit buffers in the same memory as the class */
2939 uint32 m_bitbuf[128 / (sizeof(uint32) * 8)];
2940 uint32 m_bitbuf_ai[128 / (sizeof(uint32) * 8)];
2941
2942 /*
2943 is_valid depends on the value of m_rows_buf, so while changing the value
2944 of m_rows_buf check if is_valid also needs to be modified
2946 uchar *m_rows_buf; /* The rows in packed format */
2947 uchar *m_rows_cur; /* One-after the end of the data */
2948 uchar *m_rows_end; /* One-after the end of the allocated space */
2949
2950 /* helper functions */
2952#if defined(MYSQL_SERVER)
2953 const uchar *m_curr_row; /* Start of the row being processed */
2954 const uchar *m_curr_row_end; /* One-after the end of the current row */
2955 uchar *m_key; /* Buffer to keep key value during searches */
2957 KEY *m_key_info; /* Points to description of index #m_key_index */
2958 class Key_compare {
2959 public:
2960 /**
2961 @param ki Where to find KEY description
2962 @note m_distinct_keys is instantiated when Rows_log_event is constructed;
2963 it stores a Key_compare object internally. However at that moment, the
2964 index (KEY*) to use for comparisons, is not yet known. So, at
2965 instantiation, we indicate the Key_compare the place where it can
2966 find the KEY* when needed (this place is Rows_log_event::m_key_info),
2967 Key_compare remembers the place in member m_key_info.
2968 Before we need to do comparisons - i.e. before we need to insert
2969 elements, we update Rows_log_event::m_key_info once for all.
2971 Key_compare(KEY **ki = nullptr) : m_key_info(ki) {}
2972 bool operator()(uchar *k1, uchar *k2) const {
2973 return key_cmp2((*m_key_info)->key_part, k1, (*m_key_info)->key_length,
2974 k2, (*m_key_info)->key_length) < 0;
2975 }
2977 private:
2980 std::set<uchar *, Key_compare> m_distinct_keys;
2981 std::set<uchar *, Key_compare>::iterator m_itr;
2982 /**
2983 A spare buffer which will be used when saving the distinct keys
2984 for doing an index scan with HASH_SCAN search algorithm.
2985 */
2987
2988 /**
2989 Unpack the current row image from the event into m_table->record[0].
2990
2991 @param rli The applier context.
2992
2993 @param cols The bitmap of columns included in the update.
2994
2995 @param is_after_image Should be true if this is an after-image,
2996 false if it is a before-image.
2997
2998 @param only_seek unpack_row()
2999
3000 @retval 0 Success
3001
3002 @retval ER_* On error, it is guaranteed that the error has been
3003 reported through my_error, and the corresponding ER_* code is
3004 returned. Currently the error codes are: EE_OUTOFMEMORY,
3005 ER_REPLICA_CORRUPT_EVENT, or various JSON errors when applying JSON
3006 diffs (ER_COULD_NOT_APPLY_JSON_DIFF, ER_INVALID_JSON_BINARY_DATA,
3007 and maybe others).
3008 */
3009 int unpack_current_row(const Relay_log_info *const rli, MY_BITMAP const *cols,
3010 bool is_after_image, bool only_seek = false);
3011 /**
3012 Updates the generated columns of the `TABLE` object referenced by
3013 `m_table`, that have an active bit in the parameter bitset
3014 `fields_to_update`.
3015
3016 @param fields_to_update A bitset where the bit at the index of
3017 generated columns to update must be set to `1`
3018
3019 @return 0 if the operation terminated successfully, 1 otherwise.
3020 */
3021 int update_generated_columns(MY_BITMAP const &fields_to_update);
3022 /*
3023 This member function is called when deciding the algorithm to be used to
3024 find the rows to be updated on the slave during row based replication.
3025 This this functions sets the m_rows_lookup_algorithm and also the
3026 m_key_index with the key index to be used if the algorithm is dependent on
3027 an index.
3028 TODO(Bug#31173056): Remove SUPPRESS_UBSAN_CLANG10
3029 */
3031
3032 /*
3033 Encapsulates the operations to be done before applying
3034 row event for update and delete.
3035 */
3037
3038 /*
3039 Encapsulates the operations to be done after applying
3040 row event for update and delete.
3041 */
3043
3044 /**
3045 Helper function to check whether there is an auto increment
3046 column on the table where the event is to be applied.
3047 GIPKs when not present in the source table are also considered a
3048 auto inc column in a extra column.
3049
3050 @param rli the relay log object associated to the replicated table
3051
3052 @return true if there is an autoincrement field on the extra
3053 columns, false otherwise.
3054 */
3055 bool is_auto_inc_in_extra_columns(const Relay_log_info *const rli);
3056
3057 /**
3058 Helper function to check whether the storage engine error
3059 allows for the transaction to be retried or not.
3060
3061 @param error Storage engine error
3062 @retval true if the error is retryable.
3063 @retval false if the error is non-retryable.
3064 */
3066#endif
3067
3068 bool is_rbr_logging_format() const override { return true; }
3069
3070 private:
3071#if defined(MYSQL_SERVER)
3072
3073 /**
3074 Wrapper around `TABLE *m_table` that abstracts the table field set iteration
3075 logic, since it is not mandatory that all table fields are to be
3076 replicated. For details, @see ReplicatedColumnsView class documentation.
3077
3078 A smart pointer is used here as the developer might want to instantiate the
3079 view using different classes in runtime depending on the given context.
3080 */
3082
3083 int do_apply_event(Relay_log_info const *rli) override;
3084 int do_update_pos(Relay_log_info *rli) override;
3086
3087 /*
3088 Primitive to prepare for a sequence of row executions.
3089
3090 DESCRIPTION
3091
3092 Before doing a sequence of do_prepare_row() and do_exec_row()
3093 calls, this member function should be called to prepare for the
3094 entire sequence. Typically, this member function will allocate
3095 space for any buffers that are needed for the two member
3096 functions mentioned above.
3097
3098 RETURN VALUE
3099
3100 The member function will return 0 if all went OK, or a non-zero
3101 error code otherwise.
3102 */
3103 virtual int do_before_row_operations(const Relay_log_info *const log) = 0;
3104
3105 /*
3106 Primitive to clean up after a sequence of row executions.
3107
3108 DESCRIPTION
3109
3110 After doing a sequence of do_prepare_row() and do_exec_row(),
3111 this member function should be called to clean up and release
3112 any allocated buffers.
3113
3114 The error argument, if non-zero, indicates an error which happened during
3115 row processing before this function was called. In this case, even if
3116 function is successful, it should return the error code given in the
3117 argument.
3118 */
3119 virtual int do_after_row_operations(const Relay_log_info *const log,
3120 int error) = 0;
3121
3122 /*
3123 Primitive to do the actual execution necessary for a row.
3124
3125 DESCRIPTION
3126 The member function will do the actual execution needed to handle a row.
3127 The row is located at m_curr_row. When the function returns,
3128 m_curr_row_end should point at the next row (one byte after the end
3129 of the current row).
3130
3131 RETURN VALUE
3132 0 if execution succeeded, 1 if execution failed.
3134 */
3135 virtual int do_exec_row(const Relay_log_info *const rli) = 0;
3136
3137 /**
3138 Private member function called while handling idempotent errors.
3139
3140 @param rli Pointer to relay log info structure.
3141 @param [in,out] err the error to handle. If it is listed as
3142 idempotent/ignored related error, then it is cleared.
3143 @returns true if the slave should stop executing rows.
3144 */
3146
3147 /**
3148 Private member function called after updating/deleting a row. It
3149 performs some assertions and more importantly, it updates
3150 m_curr_row so that the next row is processed during the row
3151 execution main loop (@c Rows_log_event::do_apply_event()).
3152
3153 @param rli Pointer to relay log info structure.
3154 @param err the current error code.
3155 */
3156 void do_post_row_operations(Relay_log_info const *rli, int err);
3157
3158 /**
3159 Commodity wrapper around do_exec_row(), that deals with resetting
3160 the thd reference in the table.
3161 */
3162 int do_apply_row(Relay_log_info const *rli);
3163
3164 /**
3165 Implementation of the index scan and update algorithm. It uses
3166 PK, UK or regular Key to search for the record to update. When
3167 found it updates it.
3168 */
3170
3171 /**
3172 Implementation of the hash_scan and update algorithm. It collects
3173 rows positions in a hashtable until the last row is
3174 unpacked. Then it scans the table to update and when a record in
3175 the table matches the one in the hashtable, the update/delete is
3176 performed.
3177 */
3179
3180 /**
3181 Implementation of the legacy table_scan and update algorithm. For
3182 each unpacked row it scans the storage engine table for a
3183 match. When a match is found, the update/delete operations are
3184 performed.
3185 */
3187
3188 /**
3189 Seek past the after-image of an update event, in case a row was processed
3190 without reading the after-image.
3191
3192 An update event may process a row without reading the after-image,
3193 e.g. in case of ignored or idempotent errors. To ensure that the
3194 read position for the next row is correct, we need to seek past
3195 the after-image.
3196
3197 @param rli The applier context
3198
3199 @param curr_bi_start The read position of the beginning of the
3200 before-image. (The function compares this with m_curr_row to know
3201 if the after-image has been read or not.)
3202
3203 @retval 0 Success
3204 @retval ER_* Error code returned by unpack_current_row
3205 */
3207 [[maybe_unused]],
3208 const uchar *curr_bi_start
3209 [[maybe_unused]]) {
3210 return 0;
3211 }
3212
3213 /**
3214 Initializes scanning of rows. Opens an index and initializes an iterator
3215 over a list of distinct keys (m_distinct_keys) if it is a HASH_SCAN
3216 over an index or the table if its a HASH_SCAN over the table.
3217 */
3218 int open_record_scan();
3219
3220 /**
3221 Does the cleanup
3222 - closes the index if opened by open_record_scan
3223 - closes the table if opened for scanning.
3224 */
3225 int close_record_scan();
3226
3227 /**
3228 Fetches next row. If it is a HASH_SCAN over an index, it populates
3229 table->record[0] with the next row corresponding to the index. If
3230 the indexes are in non-contigous ranges it fetches record corresponding
3231 to the key value in the next range.
3232
3233 @param first_read signifying if this is the first time we are reading a row
3234 over an index.
3235 @return error code when there are no more records to be fetched or some
3236 other error occurred,
3237 - 0 otherwise.
3238 */
3239 int next_record_scan(bool first_read);
3240
3241 /**
3242 Populates the m_distinct_keys with unique keys to be modified
3243 during HASH_SCAN over keys.
3244 @returns 0 success, or the error code.
3245 */
3247
3248 /**
3249 Populates the m_hash when using HASH_SCAN. Thence, it:
3250 - unpacks the before image (BI)
3251 - saves the positions
3252 - saves the positions into the hash map, using the
3253 BI checksum as key
3254 - unpacks the after image (AI) if needed, so that
3255 m_curr_row_end gets updated correctly.
3256
3257 @param rli The reference to the relay log info object.
3258 @returns 0 on success. Otherwise, the error code.
3259 */
3260 int do_hash_row(Relay_log_info const *rli);
3261
3262 /**
3263 This member function scans the table and applies the changes
3264 that had been previously hashed. As such, m_hash MUST be filled
3265 by do_hash_row before calling this member function.
3266
3267 @param rli The reference to the relay log info object.
3268 @returns 0 on success. Otherwise, the error code.
3269 */
3270 int do_scan_and_update(Relay_log_info const *rli);
3271#endif /* defined(MYSQL_SERVER) */
3272
3273 friend class Old_rows_log_event;
3274
3275 /**
3276 This bitmap is used as a backup for the write set while we calculate
3277 the values for any hidden generated columns (functional indexes). In order
3278 to calculate the values, the columns must be marked in the write set. After
3279 the values are calculated, we set the write set back to its original value.
3280 */
3282};
3283
3284/**
3285 @class Write_rows_log_event
3286
3287 Log row insertions and updates. The event contain several
3288 insert/update rows for a table. Note that each event contains only
3289 rows for one table.
3290
3291 @internal
3292 The inheritance structure is as follows
3293
3294 Binary_log_event
3295 ^
3296 |
3297 |
3298 |
3299 Log_event B_l:Rows_event
3300 ^ /\
3301 | / \
3302 | <<vir>>/ \ <<vir>>
3303 | / \
3304 | / \
3305 | / \
3306 Rows_log_event B_l:W_R_E
3307 \ /
3308 \ /
3309 \ /
3310 \ /
3311 \ /
3312 \/
3313 Write_rows_log_event
3314
3315 B_l: Namespace Binary_log
3316 W_R_E: class Write_rows_event
3317 @endinternal
3319*/
3322 public:
3323 enum {
3324 /* Support interface to THD::binlog_prepare_pending_rows_event */
3326 };
3327
3328#if defined(MYSQL_SERVER)
3330 const mysql::binlog::event::Table_id &table_id,
3331 bool is_transactional,
3332 const unsigned char *extra_row_ndb_info);
3333#endif
3335 const char *buf,
3336 const mysql::binlog::event::Format_description_event *description_event);
3337#if defined(MYSQL_SERVER)
3339 bool is_transactional,
3340 const uchar *before_record
3341 [[maybe_unused]],
3342 const uchar *after_record);
3343 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3344 return bitmap_cmp(get_cols(), table->write_set);
3345 }
3346#endif
3347
3348 void claim_memory_ownership(bool claim) override;
3349
3350 protected:
3351 int write_row(const Relay_log_info *const, const bool);
3353 private:
3356 }
3357
3358#ifndef MYSQL_SERVER
3359 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3360#endif
3361
3362#if defined(MYSQL_SERVER)
3363 int do_before_row_operations(const Relay_log_info *const) override;
3364 int do_after_row_operations(const Relay_log_info *const, int) override;
3365 int do_exec_row(const Relay_log_info *const) override;
3366#endif
3367};
3368
3369/**
3370 @class Update_rows_log_event
3371
3372 Log row updates with a before image. The event contain several
3373 update rows for a table. Note that each event contains only rows for
3374 one table.
3375
3376 Also note that the row data consists of pairs of row data: one row
3377 for the old data and one row for the new data.
3378
3379 @internal
3380 The inheritance structure is as follows
3381
3382 Binary_log_event
3383 ^
3384 |
3385 |
3386 |
3387 Log_event B_l:Rows_event
3388 ^ /\
3389 | / \
3390 | <<vir>>/ \ <<vir>>
3391 | / \
3392 | / \
3393 | / \
3394 Rows_log_event B_l:U_R_E
3395 \ /
3396 \ /
3397 \ /
3398 \ /
3399 \ /
3400 \/
3401 Update_rows_log_event
3402
3403
3404 B_l: Namespace Binary_log
3405 U_R_E: class Update_rows_event
3406 @eninternal
3408*/
3411 public:
3412 enum {
3413 /* Support interface to THD::binlog_prepare_pending_rows_event */
3415 };
3417#ifdef MYSQL_SERVER
3419 const mysql::binlog::event::Table_id &table_id,
3420 MY_BITMAP const *cols_bi, MY_BITMAP const *cols_ai,
3421 bool is_transactional,
3422 const unsigned char *extra_row_ndb_info);
3423
3425 const mysql::binlog::event::Table_id &table_id,
3426 bool is_transactional,
3427 const unsigned char *extra_row_ndb_info);
3428
3429 void init(MY_BITMAP const *cols);
3430#endif
3431
3432 ~Update_rows_log_event() override;
3433
3435 const char *buf,
3436 const mysql::binlog::event::Format_description_event *description_event);
3437
3438#ifdef MYSQL_SERVER
3440 bool is_transactional,
3441 const uchar *before_record,
3442 const uchar *after_record);
3443 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3444 return (bitmap_cmp(get_cols(), table->read_set) &&
3445 bitmap_cmp(get_cols_ai(), table->write_set));
3446 }
3447#endif
3448
3449 void claim_memory_ownership(bool claim) override;
3451 protected:
3454 }
3455
3456#ifndef MYSQL_SERVER
3457 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3458#endif
3459
3460#if defined(MYSQL_SERVER)
3461 int do_before_row_operations(const Relay_log_info *const) override;
3462 int do_after_row_operations(const Relay_log_info *const, int) override;
3463 int do_exec_row(const Relay_log_info *const) override;
3464
3466 const uchar *curr_bi_start) override;
3467
3468 private:
3469 /**
3470 Auxiliary function used in the (THD*, ...) constructor to
3471 determine the type code based on configuration options.
3472
3473 @param thd_arg The THD object for the session.
3474
3475 @return One of PARTIAL_UPDATE_ROWS_EVENT, or UPDATE_ROWS_EVENT.
3476 */
3478 const THD *thd_arg);
3479#endif /* defined(MYSQL_SERVER) */
3480};
3481
3482/**
3483 @class Delete_rows_log_event
3484
3485 Log row deletions. The event contain several delete rows for a
3486 table. Note that each event contains only rows for one table.
3487
3488 RESPONSIBILITIES
3489
3490 - Act as a container for rows that has been deleted on the master
3491 and should be deleted on the slave.
3492
3493 COLLABORATION
3494
3495 Row_writer
3496 Create the event and add rows to the event.
3497 Row_reader
3498 Extract the rows from the event.
3499
3500 @internal
3501 The inheritance structure is as follows
3502
3503 Binary_log_event
3504 ^
3505 |
3506 |
3507 |
3508 Log_event B_l:Rows_event
3509 ^ /\
3510 | / \
3511 | <<vir>>/ \ <<vir>>
3512 | / \
3513 | / \
3514 | / \
3515 Rows_log_event B_l:D_R_E
3516 \ /
3517 \ /
3518 \ /
3519 \ /
3520 \ /
3521 \/
3522 Delete_rows_log_event
3523
3524 B_l: Namespace Binary_log
3525 D_R_E: class Delete_rows_event
3526 @endinternal
3528*/
3531 public:
3532 enum {
3533 /* Support interface to THD::binlog_prepare_pending_rows_event */
3535 };
3536
3537#ifdef MYSQL_SERVER
3539 bool is_transactional,
3540 const unsigned char *extra_row_ndb_info);
3541#endif
3543 const char *buf,
3544 const mysql::binlog::event::Format_description_event *description_event);
3545#ifdef MYSQL_SERVER
3547 bool is_transactional,
3548 const uchar *before_record,
3549 const uchar *after_record
3550 [[maybe_unused]]);
3551 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3552 return bitmap_cmp(get_cols(), table->read_set);
3553 }
3554#endif
3555
3556 void claim_memory_ownership(bool claim) override;
3558 protected:
3561 }
3562
3563#ifndef MYSQL_SERVER
3564 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3565#endif
3566
3567#if defined(MYSQL_SERVER)
3568 int do_before_row_operations(const Relay_log_info *const) override;
3569 int do_after_row_operations(const Relay_log_info *const, int) override;
3570 int do_exec_row(const Relay_log_info *const) override;
3571#endif
3572};
3573
3574/**
3575 @class Incident_log_event
3576
3577 Class representing an incident, an occurrence out of the ordinary,
3578 that happened on the master.
3579
3580 The event is used to inform the slave that something out of the
3581 ordinary happened on the master that might cause the database to be
3582 in an inconsistent state.
3583
3584 It's the derived class of Incident_event
3585
3586 @internal
3587 The inheritance structure is as follows
3588
3589 Binary_log_event
3590 ^
3591 |
3592 |
3593 B_l:Incident_event Log_event
3594 \ /
3595 \ /
3596 \ /
3597 \ /
3598 Incident_log_event
3599
3600 B_l: Namespace Binary_log
3601 @endinternal
3603*/
3605 public Log_event {
3606 public:
3607 // disable copy-move semantics
3609 Incident_log_event &operator=(Incident_log_event &&) noexcept = delete;
3610 Incident_log_event(const Incident_log_event &) = delete;
3611 Incident_log_event &operator=(const Incident_log_event &) = delete;
3613#ifdef MYSQL_SERVER
3614 Incident_log_event(THD *thd_arg, enum_incident incident_arg,
3615 std::string_view msg)
3616 : mysql::binlog::event::Incident_event(incident_arg),
3619 DBUG_TRACE;
3620 DBUG_PRINT("enter", ("incident: %d", incident_arg));
3621 common_header->set_is_valid(incident_arg > INCIDENT_NONE &&
3622 incident_arg < INCIDENT_COUNT);
3623 assert(message == nullptr && message_length == 0);
3625 msg.length() + 1, MYF(MY_WME)))) {
3626 // The allocation failed. Mark this binlog event as invalid.
3628 return;
3629 }
3630 strmake(message, msg.data(), msg.length());
3631 message_length = msg.length();
3632 return;
3633 }
3634#endif
3635
3636#ifdef MYSQL_SERVER
3637 int pack_info(Protocol *) override;
3638#endif
3639
3641 const char *buf,
3642 const mysql::binlog::event::Format_description_event *description_event);
3643
3644 ~Incident_log_event() override;
3645
3646 void claim_memory_ownership(bool claim) override;
3647
3648#ifndef MYSQL_SERVER
3649 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3650#endif
3651
3652#if defined(MYSQL_SERVER)
3653 int do_apply_event(Relay_log_info const *rli) override;
3654 bool write_data_header(Basic_ostream *ostream) override;
3655 bool write_data_body(Basic_ostream *ostream) override;
3656#endif
3657
3658 size_t get_data_size() override {
3662
3663 bool ends_group() const override { return true; }
3664
3665 private:
3666 const char *description() const;
3667};
3668
3669/**
3670 @class Ignorable_log_event
3671
3672 Base class for ignorable log events is Ignorable_event.
3673 Events deriving from this class can be safely ignored
3674 by slaves that cannot recognize them.
3675
3676 Its the derived class of Ignorable_event
3677
3678 @internal
3679 The inheritance structure is as follows
3680
3681 Binary_log_event
3682 ^
3683 |
3684 |
3685 B_l:Ignorable_event Log_event
3686 \ /
3687 <<virtual>>\ /
3688 \ /
3689 Ignorable_log_event
3690
3691 B_l: Namespace Binary_log
3692 @endinternal
3693*/
3696 public Log_event {
3697 public:
3698 // disable copy-move semantics
3700 Ignorable_log_event &operator=(Ignorable_log_event &&) noexcept = delete;
3701 Ignorable_log_event(const Ignorable_log_event &) = delete;
3702 Ignorable_log_event &operator=(const Ignorable_log_event &) = delete;
3704#ifdef MYSQL_SERVER
3705 Ignorable_log_event(THD *thd_arg)
3708 DBUG_TRACE;
3710 return;
3711 }
3712#endif
3713
3715 const char *buf,
3717 ~Ignorable_log_event() override;
3718
3719 void claim_memory_ownership(bool claim) override;
3720
3721#ifdef MYSQL_SERVER
3722 int pack_info(Protocol *) override;
3723#endif
3724
3725#ifndef MYSQL_SERVER
3726 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3727#endif
3728
3729 size_t get_data_size() override {
3731 }
3732};
3733
3734/**
3735 @class Rows_query_log_event
3736 It is used to record the original query for the rows
3737 events in RBR.
3738 It is the subclass of Ignorable_log_event and Rows_query_event
3739
3740 @internal
3741 The inheritance structure in the current design for the classes is
3742 as follows:
3743 Binary_log_event
3744 ^
3745 |
3746 |
3747 |
3748 Log_event B_l:Ignorable_event
3749 ^ /\
3750 | / \
3751 | <<vir>>/ \ <<vir>>
3752 | / \
3753 | / \
3754 | / \
3755 Ignorable_log_event B_l:Rows_query_event
3756 \ /
3757 \ /
3758 \ /
3759 \ /
3760 \ /
3761 \/
3762 Rows_query_log_event
3763
3764 B_l : namespace namespace mysql::binlog::event
3765 @endinternal
3766*/
3769 public:
3770#ifdef MYSQL_SERVER
3771 Rows_query_log_event(THD *thd_arg, const char *query, size_t query_len)
3772 : Ignorable_log_event(thd_arg) {
3773 DBUG_TRACE;
3775 m_rows_query_length = query_len;
3776 if (!(m_rows_query =
3779 return;
3782 "rows_query_alter", size_t i = 0; while (i < m_rows_query_length) {
3783 if (m_rows_query[i] == '\\') {
3784 m_rows_query[i] = '\0';
3785 i++;
3786 for (auto j = i; j < m_rows_query_length - 1; j++) {
3787 m_rows_query[j] = m_rows_query[j + 1];
3788 }
3790 } else
3791 i++;
3792 });
3793 DBUG_PRINT("enter", ("%s", m_rows_query));
3794 return;
3795 }
3796#endif
3797
3798#ifdef MYSQL_SERVER
3799 int pack_info(Protocol *) override;
3800 int do_apply_event(Relay_log_info const *rli) override;
3801 bool write_data_body(Basic_ostream *ostream) override;
3802#endif
3803
3805 const char *buf,
3807
3808 void claim_memory_ownership(bool claim) override;
3809
3810 ~Rows_query_log_event() override {
3812 m_rows_query = nullptr;
3813 }
3814#ifndef MYSQL_SERVER
3815 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3816#endif
3817 size_t get_data_size() override {
3820 }
3822
3823static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
3824 FILE *file,
3825 bool flush_stream) {
3826 return my_b_copy_to_file(cache, file) ||
3827 (flush_stream ? (fflush(file) || ferror(file)) : 0) ||
3828 reinit_io_cache(cache, WRITE_CACHE, 0, false, true);
3829}
3830
3831#ifdef MYSQL_SERVER
3832/*****************************************************************************
3833
3834 Heartbeat Log Event class
3835
3836 The class is not logged to a binary log, and is not applied on to the slave.
3837 The decoding of the event on the slave side is done by its superclass,
3838 mysql::binlog::event::Heartbeat_event.
3840 ****************************************************************************/
3842 public Log_event {
3843 public:
3845 const char *buf,
3846 const mysql::binlog::event::Format_description_event *description_event);
3848
3850 public Log_event {
3851 public:
3853 const char *buf,
3854 const mysql::binlog::event::Format_description_event *description_event);
3855};
3856/**
3857 The function is called by slave applier in case there are
3858 active table filtering rules to force gathering events associated
3859 with Query-log-event into an array to execute
3860 them once the fate of the Query is determined for execution.
3861*/
3863#endif
3864
3865int append_query_string(const THD *thd, const CHARSET_INFO *csinfo,
3866 String const *from, String *to);
3868
3871 public Log_event {
3872 public:
3873#ifdef MYSQL_SERVER
3874
3875 class Applier_context {
3876 private:
3877 // context for the applier (to remove if we remove the DATABASE scheduler)
3880 public:
3881 Applier_context() = default;
3882 virtual ~Applier_context() { reset(); }
3886
3887 Transaction_payload_log_event(THD *thd_arg, const char *payload,
3888 uint64_t payload_size,
3889 uint16_t compression_type,
3890 uint64_t uncompressed_size)
3891 : Transaction_payload_event(payload, payload_size, compression_type,
3892 uncompressed_size),
3893 Log_event(thd_arg, 0 /* flags */, Log_event::EVENT_TRANSACTIONAL_CACHE,
3895
3896 Transaction_payload_log_event(THD *thd_arg, const char *payload,
3897 uint64_t payload_size)
3899 thd_arg, payload, payload_size,
3900 mysql::binlog::event::compression::type::NONE, payload_size) {}
3901
3903 : Transaction_payload_log_event(thd_arg, nullptr, (uint64_t)0) {}
3904#endif
3905
3907 const char *buf,
3910
3911 ~Transaction_payload_log_event() override = default;
3912
3913 void claim_memory_ownership(bool claim) override;
3914
3915#ifndef MYSQL_SERVER
3916 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3917#endif
3918
3919 size_t get_event_length() { return LOG_EVENT_HEADER_LEN + get_data_size(); }
3920 size_t get_data_size() override;
3921
3922#if defined(MYSQL_SERVER)
3923 private:
3925
3926 public:
3927 int do_apply_event(Relay_log_info const *rli) override;
3928 bool apply_payload_event(Relay_log_info const *rli, const uchar *event_buf);
3930 int pack_info(Protocol *protocol) override;
3931 bool ends_group() const override;
3932 bool write(Basic_ostream *ostream) override;
3934 void set_mts_dbs(Mts_db_names &arg);
3935 uint8 mts_number_dbs() override;
3936#endif
3937};
3938
3939/**
3940 @class Gtid_log_event
3941
3942 This is a subclass if Gtid_event and Log_event. It contains
3943 per-transaction fields, including the GTID and logical timestamps
3944 used by MTS.
3945
3946 @internal
3947 The inheritance structure is as follows
3948
3949 Binary_log_event
3950 ^
3951 |
3952 |
3953 B_l:Gtid_event Log_event
3954 \ /
3955 \ /
3956 \ /
3957 \ /
3958 Gtid_log_event
3959
3960 B_l: Namespace Binary_log
3961 @endinternal
3962*/
3964 public Log_event {
3965 public:
3966 // disable copy-move semantics
3967 Gtid_log_event(Gtid_log_event &&) noexcept = delete;
3968 Gtid_log_event &operator=(Gtid_log_event &&) noexcept = delete;
3969 Gtid_log_event(const Gtid_log_event &) = delete;
3970 Gtid_log_event &operator=(const Gtid_log_event &) = delete;
3971
3972#ifdef MYSQL_SERVER
3973 /**
3974 Create a new event using the GTID owned by the given thread.
3975 */
3976 Gtid_log_event(THD *thd_arg, bool using_trans, int64 last_committed_arg,
3977 int64 sequence_number_arg, bool may_have_sbr_stmts_arg,
3978 ulonglong original_commit_timestamp_arg,
3979 ulonglong immediate_commit_timestamp_arg,
3980 uint32_t original_server_version_arg,
3981 uint32_t immediate_server_version_arg);
3982
3983 /**
3984 Create a new event using the GTID from the given Gtid_specification
3985 without a THD object.
3986 */
3987 Gtid_log_event(uint32 server_id_arg, bool using_trans,
3988 int64 last_committed_arg, int64 sequence_number_arg,
3989 bool may_have_sbr_stmts_arg,
3990 ulonglong original_commit_timestamp_arg,
3991 ulonglong immediate_commit_timestamp_arg,
3992 const Gtid_specification spec_arg,
3993 uint32_t original_server_version_arg,
3994 uint32_t immediate_server_version_arg);
3995#endif
3996
3997#ifdef MYSQL_SERVER
3998 int pack_info(Protocol *) override;
3999#endif
4001 const char *buffer,
4003
4004 ~Gtid_log_event() override = default;
4005
4006 void claim_memory_ownership(bool claim) override;
4007
4009
4010 size_t get_data_size() override {
4011 if (is_tagged()) {
4012 auto size_calculated = Encoder_type::get_size(*this);
4013 DBUG_EXECUTE_IF("add_unknown_ignorable_fields_to_gtid_log_event",
4014 { size_calculated += 2; });
4015 return size_calculated;
4016 }
4017 DBUG_EXECUTE_IF("do_not_write_rpl_timestamps", return POST_HEADER_LENGTH;);
4021 }
4022
4023 /// @brief Clears tsid and spec
4024 void clear_gtid_and_spec();
4025
4026 /// @brief Updates parent tsid and gtid info structure
4028
4029 size_t get_event_length() { return LOG_EVENT_HEADER_LEN + get_data_size(); }
4030
4031 /// Used internally by both print() and pack_info().
4032 size_t to_string(char *buf) const;
4033
4034 private:
4035#ifdef MYSQL_SERVER
4036 /**
4037 Writes the post-header to the given output stream.
4038
4039 This is an auxiliary function typically used by the write() member
4040 function.
4041
4042 @param ostream The output stream to write to.
4043
4044 @retval true Error.
4045 @retval false Success.
4046 */
4047 bool write_data_header(Basic_ostream *ostream) override;
4048 bool write_data_body(Basic_ostream *ostream) override;
4049 /**
4050 Writes the post-header to the given memory buffer.
4051
4052 This is an auxiliary function used by write_to_memory.
4053
4054 @param[in,out] buffer Buffer to which the post-header will be written.
4055
4056 @return The number of bytes written, i.e., always
4057 Gtid_log_event::POST_HEADER_LENGTH.
4058 */
4060
4061 /**
4062 Writes the body to the given memory buffer.
4063
4064 This is an auxiliary function used by write_to_memory.
4065
4066 @param [in,out] buff Buffer to which the data will be written.
4067
4068 @return The number of bytes written, i.e.,
4069 If the transaction did not originated on this server
4070 Gtid_event::IMMEDIATE_COMMIT_TIMESTAMP_LENGTH.
4071 else
4072 FULL_COMMIT_TIMESTAMP_LENGTH.
4073 */
4075
4076 /// @copydoc write_body_to_memory
4077 /// @details Version for tagged Gtid log event
4079
4080#endif
4081
4082 public:
4083#ifndef MYSQL_SERVER
4084 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4085#endif
4086
4087#if defined(MYSQL_SERVER)
4088 int do_apply_event(Relay_log_info const *rli) override;
4089 int do_update_pos(Relay_log_info *rli) override;
4091#endif
4092
4093 /**
4094 Return the gtid type for this Gtid_log_event: this can be
4095 either ANONYMOUS_GTID, AUTOMATIC_GTID, or ASSIGNED_GTID.
4096 */
4097 enum_gtid_type get_type() const { return spec.type; }
4098
4099 /**
4100 Return the TSID for this GTID. The TSID is shared with the
4101 Log_event so it should not be modified.
4102 */
4103 const Tsid &get_tsid() const { return tsid; }
4104 /**
4105 Return the SIDNO relative to the global tsid_map for this GTID.
4106
4107 This requires a lookup and possibly even update of global_tsid_map,
4108 hence global_tsid_lock must be held. If global_tsid_lock is not
4109 held, the caller must pass need_lock=true. If there is an error
4110 (e.g. out of memory) while updating global_tsid_map, this function
4111 returns a negative number.
4112
4113 @param need_lock If true, the read lock on global_tsid_lock is
4114 acquired and released inside this function; if false, the read
4115 lock or write lock must be held prior to calling this function.
4116 @retval SIDNO if successful
4117 @retval negative if adding TSID to global_tsid_map causes an error.
4118 */
4119 rpl_sidno get_sidno(bool need_lock);
4120
4121 /**
4122 Return the SIDNO relative to the given Tsid_map for this GTID.
4123
4124 This assumes that the Tsid_map is local to the thread, and thus
4125 does not use locks.
4126
4127 @param tsid_map The tsid_map to use.
4128 @retval SIDNO if successful.
4129 @retval negative if adding TSID to tsid_map causes an error.
4130 */
4131 rpl_sidno get_sidno(Tsid_map *tsid_map) { return tsid_map->add_tsid(tsid); }
4132 /// Return the GNO for this GTID.
4133 rpl_gno get_gno() const override { return spec.gtid.gno; }
4134
4135 /// @returns The GTID event specification
4138 /// string holding the text "SET @@GLOBAL.GTID_NEXT = '"
4139 static const char *SET_STRING_PREFIX;
4140
4141 private:
4142 /// Length of SET_STRING_PREFIX
4143 static const size_t SET_STRING_PREFIX_LENGTH = 26;
4144 /// The maximal length of the entire "SET ..." query.
4145 static const size_t MAX_SET_STRING_LENGTH = SET_STRING_PREFIX_LENGTH +
4148
4149 private:
4150 /**
4151 Internal representation of the GTID. The SIDNO will be
4152 uninitialized (value -1) until the first call to get_sidno(bool).
4153 */
4155 /// TSID for this GTID.
4156 Tsid tsid;
4157
4158 public:
4159 /**
4160 Set the transaction length information based on binlog cache size.
4161
4162 Note that is_checksum_enabled and event_counter are optional parameters.
4163 When not specified, the function will assume that no checksum will be used
4164 and the informed cache_size is the final transaction size without
4165 considering the GTID event size.
4166
4167 The high level formula that will be used by the function is:
4168
4169 trx_length = cache_size +
4170 cache_checksum_active * cache_events * CRC32_payload +
4171 gtid_length +
4172 cache_checksum_active * CRC32_payload; // For the GTID.
4173
4174 @param cache_size The size of the binlog cache in bytes.
4175 @param is_checksum_enabled If checksum will be added to events on flush.
4176 @param event_counter The amount of events in the cache.
4177 */
4179 bool is_checksum_enabled = false,
4180 int event_counter = 0);
4181
4182 /// @copydoc set_trx_length_by_cache_size
4183 /// @detail tagged version of event
4185 bool is_checksum_enabled = false,
4186 int event_counter = 0);
4187};
4188
4189/**
4190 @class Previous_gtids_log_event
4191
4192 This is the subclass of Previous_gtids_event and Log_event
4193 It is used to record the gtid_executed in the last binary log file,
4194 for ex after flush logs, or at the starting of the binary log file
4195
4196 @internal
4197 The inheritance structure is as follows
4198
4199 Binary_log_event
4200 ^
4201 |
4202 |
4203B_l:Previous_gtids_event Log_event
4204 \ /
4205 \ /
4206 \ /
4207 \ /
4208 Previous_gtids_log_event
4209
4210 B_l: Namespace Binary_log
4211 @endinternal
4212*/
4215 public Log_event {
4216 public:
4217 // disable copy-move semantics
4220 delete;
4223 delete;
4224
4225#ifdef MYSQL_SERVER
4227#endif
4228
4229#ifdef MYSQL_SERVER
4230 int pack_info(Protocol *) override;
4231#endif
4232
4234 const char *buf,
4235 const mysql::binlog::event::Format_description_event *description_event);
4236 ~Previous_gtids_log_event() override = default;
4237
4238 size_t get_data_size() override { return buf_size; }
4239
4240 void claim_memory_ownership(bool claim) override;
4241
4242#ifndef MYSQL_SERVER
4243 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4244#endif
4245#ifdef MYSQL_SERVER
4246 bool write(Basic_ostream *ostream) override {
4247#ifndef NDEBUG
4248 if (DBUG_EVALUATE_IF("skip_writing_previous_gtids_log_event", 1, 0) &&
4249 /*
4250 The skip_writing_previous_gtids_log_event debug point was designed
4251 for skipping the writing of the previous_gtids_log_event on binlog
4252 files only.
4253 */
4254 !is_relay_log_event()) {
4255 DBUG_PRINT("info",
4256 ("skip writing Previous_gtids_log_event because of"
4257 "debug option 'skip_writing_previous_gtids_log_event'"));
4258 return false;
4259 }
4260
4261 if (DBUG_EVALUATE_IF("write_partial_previous_gtids_log_event", 1, 0) &&
4262 /*
4263 The write_partial_previous_gtids_log_event debug point was designed
4264 for writing a partial previous_gtids_log_event on binlog files only.
4265 */
4266 !is_relay_log_event()) {
4267 DBUG_PRINT("info",
4268 ("writing partial Previous_gtids_log_event because of"
4269 "debug option 'write_partial_previous_gtids_log_event'"));
4270 return (Log_event::write_header(ostream, get_data_size()) ||
4272 }
4273#endif
4274
4275 return (Log_event::write_header(ostream, get_data_size()) ||
4276 Log_event::write_data_header(ostream) || write_data_body(ostream) ||
4277 Log_event::write_footer(ostream));
4278 }
4279 bool write_data_body(Basic_ostream *ostream) override;
4280#endif
4282 /// Return the encoded buffer, or NULL on error.
4283 const uchar *get_buf() { return buf; }
4284 /**
4285 Return the formatted string, or NULL on error.
4286 The string is allocated using my_malloc and it is the
4287 responsibility of the caller to free it.
4288 */
4289 char *get_str(size_t *length,
4291 /// Add all GTIDs from this event to the given Gtid_set.
4292 int add_to_set(Gtid_set *gtid_set) const;
4293 /*
4294 Previous Gtid Log events should always be skipped
4295 there is nothing to apply there, whether it is
4296 relay log's (generated on Slave) or it is binary log's
4297 (generated on Master, copied to slave as relay log).
4298 Also, we should not increment slave_skip_counter
4299 for this event, hence return EVENT_SKIP_IGNORE.
4301#if defined(MYSQL_SERVER)
4303 {
4304 return EVENT_SKIP_IGNORE;
4306
4307 int do_apply_event(Relay_log_info const *) override { return 0; }
4308 int do_update_pos(Relay_log_info *rli) override;
4309#endif
4310};
4311
4312/**
4313 @class Transaction_context_log_event
4314
4315 This is the subclass of Transaction_context_event and Log_event
4316 This class encodes the transaction_context_log_event.
4317
4318 @internal
4319 The inheritance structure is as follows
4320
4321 Binary_log_event
4322 ^
4323 |
4324 |
4325B_l:Transaction_context_event Log_event
4326 \ /
4327 \ /
4328 \ /
4329 \ /
4330 Transaction_context_log_event
4331
4332 B_l: Namespace Binary_log
4333 @endinternal
4334*/
4337 public Log_event {
4338 private:
4339 /// The Tsid_map to use for creating the Gtid_set.
4341 /// A gtid_set which is used to store the transaction set used for
4342 /// conflict detection.
4344
4345#ifdef MYSQL_SERVER
4346 bool write_data_header(Basic_ostream *ostream) override;
4347
4348 bool write_data_body(Basic_ostream *ostream) override;
4349
4351
4352 bool write_data_set(Basic_ostream *ostream, std::list<const char *> *set);
4353#endif
4354
4356
4357 static int get_data_set_size(std::list<const char *> *set);
4358
4359 size_t to_string(char *buf, ulong len) const;
4360
4361 public:
4362#ifdef MYSQL_SERVER
4363
4364 Transaction_context_log_event(const char *server_uuid_arg, bool using_trans,
4365 my_thread_id thread_id_arg,
4366 bool is_gtid_specified);
4367
4368#endif
4369
4371 const char *buffer,
4373
4375
4376 void claim_memory_ownership(bool claim) override;
4377
4378 size_t get_data_size() override;
4379
4380 size_t get_event_length();
4381
4382#ifdef MYSQL_SERVER
4383 int pack_info(Protocol *protocol) override;
4384#endif
4385
4386#ifndef MYSQL_SERVER
4387 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4388#endif
4390#if defined(MYSQL_SERVER)
4391 int do_apply_event(Relay_log_info const *) override { return 0; }
4392 int do_update_pos(Relay_log_info *rli) override;
4393#endif
4394
4395 /**
4396 Add a hash which identifies a inserted/updated/deleted row on the
4397 ongoing transaction.
4398
4399 @param[in] hash row identifier
4400 */
4401 void add_write_set(const char *hash);
4402
4403 /**
4404 Return a pointer to write-set list.
4405 */
4406 std::list<const char *> *get_write_set() { return &write_set; }
4407
4408 /**
4409 Add a hash which identifies a read row on the ongoing transaction.
4410
4411 @param[in] hash row identifier
4412 */
4413 void add_read_set(const char *hash);
4414
4415 /**
4416 Return a pointer to read-set list.
4417 */
4418 std::list<const char *> *get_read_set() { return &read_set; }
4419
4420 /**
4421 Read snapshot version from encoded buffers.
4422 Cannot be executed during data read from file (event constructor),
4423 since its required locks will collide with the server gtid state
4424 initialization procedure.
4425 */
4426 bool read_snapshot_version();
4427
4428 /**
4429 Return the transaction snapshot timestamp.
4430 */
4432
4433 /**
4434 Return the server uuid.
4435 */
4436 const char *get_server_uuid() { return server_uuid; }
4437
4438 /**
4439 Return the id of the committing thread.
4440 */
4441 my_thread_id get_thread_id() const {
4442 return static_cast<my_thread_id>(thread_id);
4443 }
4444
4445 /**
4446 Return true if transaction has GTID fully specified, false otherwise.
4447 */
4448 bool is_gtid_specified() const { return gtid_specified; }
4449};
4450
4451/**
4452 @class View_change_log_event
4453
4454 This is the subclass of View_change_log_event and Log_event
4455 This class created the view_change_log_event which is used as a marker in
4456 case a new node joins or leaves the group.
4457
4458 @internal
4459 The inheritance structure is as follows
4460
4461 Binary_log_event
4462 ^
4463 |
4464 |
4465B_l: View_change_event Log_event
4466 \ /
4467 \ /
4468 \ /
4469 \ /
4470 View_change_log_event
4471
4472 B_l: Namespace Binary_log
4473 @endinternal
4475
4477 public Log_event {
4478 private:
4479 size_t to_string(char *buf, ulong len) const;
4480
4481#ifdef MYSQL_SERVER
4482 bool write_data_header(Basic_ostream *ostream) override;
4483
4484 bool write_data_body(Basic_ostream *ostream) override;
4485
4486 bool write_data_map(Basic_ostream *ostream,
4487 std::map<std::string, std::string> *map);
4488#endif
4489
4490 size_t get_size_data_map(std::map<std::string, std::string> *map);
4491
4492 public:
4493 // disable copy-move semantics
4495 View_change_log_event &operator=(View_change_log_event &&) noexcept = delete;
4497 View_change_log_event &operator=(const View_change_log_event &) = delete;
4498
4499 View_change_log_event(const char *view_id);
4500
4502 const char *buffer,
4503 const mysql::binlog::event::Format_description_event *descr_event);
4504
4505 ~View_change_log_event() override;
4506
4507 void claim_memory_ownership(bool claim) override;
4508
4509 size_t get_data_size() override;
4510
4511#ifdef MYSQL_SERVER
4512 int pack_info(Protocol *protocol) override;
4513#endif
4514
4515#ifndef MYSQL_SERVER
4516 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4517#endif
4518
4519#if defined(MYSQL_SERVER)
4520 int do_apply_event(Relay_log_info const *rli) override;
4521 int do_update_pos(Relay_log_info *rli) override;
4522#endif
4523
4524 /**
4525 Returns the view id.
4526 */
4527 char *get_view_id() { return view_id; }
4528
4529 /**
4530 Sets the certification info in the event
4531
4532 @note size is calculated on this method as the size of the data
4533 might render the log even invalid. Also due to its size doing it
4534 here avoid looping over the data multiple times.
4535
4536 @param[in] info certification info to be written
4537 @param[out] event_size the event size after this operation
4538 */
4539 void set_certification_info(std::map<std::string, std::string> *info,
4540 size_t *event_size);
4541
4542 /**
4543 Returns the certification info
4544 */
4545 std::map<std::string, std::string> *get_certification_info() {
4546 return &certification_info;
4547 }
4548
4549 /**
4550 Set the certification sequence number
4551
4552 @param number the sequence number
4553 */
4554 void set_seq_number(rpl_gno number) { seq_number = number; }
4555
4556 /**
4557 Returns the certification sequence number
4558 */
4559 rpl_gno get_seq_number() { return seq_number; }
4561
4562inline bool is_any_gtid_event(const Log_event *evt) {
4564 evt->get_type_code()));
4565}
4566
4567/**
4568 Check if the given event is a session control event, one of
4569 `User_var_event`, `Intvar_event` or `Rand_event`.
4570
4571 @param evt The event to check.
4572
4573 @return true if the given event is of type `User_var_event`,
4574 `Intvar_event` or `Rand_event`, false otherwise.
4575 */
4576inline bool is_session_control_event(Log_event *evt) {
4580}
4581
4582/**
4583 The function checks the argument event properties to deduce whether
4584 it represents an atomic DDL.
4585
4586 @param evt a reference to Log_event
4587 @return true when the DDL properties are found,
4588 false otherwise
4589*/
4590inline bool is_atomic_ddl_event(Log_event const *evt) {
4591 return evt != nullptr &&
4593 static_cast<Query_log_event const *>(evt)->ddl_xid !=
4595}
4596
4597/**
4598 The function lists all DDL instances that are supported
4599 for crash-recovery (WL9175).
4600 todo: the supported feature list is supposed to grow. Once
4601 a feature has been readied for 2pc through WL7743,9536(7141/7016) etc
4602 it needs registering in the function.
4603
4604 @param thd an Query-log-event creator thread handle
4605 @param using_trans
4606 The caller must specify the value according to the following
4607 rules:
4608 @c true when
4609 - on master the current statement is not processing
4610 a table in SE which does not support atomic DDL
4611 - on slave the relay-log repository is transactional.
4612 @c false otherwise.
4613 @return true when the being created (master) or handled (slave) event
4614 is 2pc-capable, @c false otherwise.
4615*/
4616bool is_atomic_ddl(THD *thd, bool using_trans);
4617
4618#ifdef MYSQL_SERVER
4619/**
4620 Serialize an binary event to the given output stream. It is more general
4621 than call ev->write() directly. The caller will not be affected if any
4622 change happens in serialization process. For example, serializing the
4623 event in different format.
4625template <class EVENT>
4626bool binary_event_serialize(EVENT *ev, Basic_ostream *ostream) {
4627 return ev->write(ostream);
4628}
4629
4630/*
4631 This is an utility function that adds a quoted identifier into the a buffer.
4632 This also escapes any existence of the quote string inside the identifier.
4633 */
4634size_t my_strmov_quoted_identifier(THD *thd, char *buffer,
4635 const char *identifier, size_t length);
4636#else
4637size_t my_strmov_quoted_identifier(char *buffer, const char *identifier);
4638#endif
4640 const char *identifier,
4641 size_t length);
4642
4643/**
4644 Read an integer in net_field_length format, guarding against read out of
4645 bounds and advancing the position.
4646
4647 @param[in,out] packet Pointer to buffer to read from. On successful
4648 return, the buffer position will be incremented to point to the next
4649 byte after what was read.
4650
4651 @param[in,out] max_length Pointer to the number of bytes in the
4652 buffer. If the function would need to look at more than *max_length
4653 bytes in order to decode the number, the function will do nothing
4654 and return true.
4655
4656 @param[out] out Pointer where the value will be stored.
4657
4658 @retval false Success.
4659 @retval true Failure, i.e., reached end of buffer.
4660*/
4661template <typename T>
4662bool net_field_length_checked(const uchar **packet, size_t *max_length, T *out);
4663
4664/**
4665 Extract basic info about an event: type, query, is it ignorable
4666
4667 @param log_event the event to extract info from
4668 @return a pair first param is true if an error occurred, false otherwise
4669 second param is the event info
4670 */
4671std::pair<bool, mysql::binlog::event::Log_event_basic_info>
4673
4674/**
4675 Extract basic info about an event: type, query, is it ignorable
4676
4677 @param buf The event info buffer
4678 @param length The length of the buffer
4679 @param fd_event The Format description event associated
4680 @return a pair first param is true if an error occurred, false otherwise
4681 second param is the event info
4682 */
4683std::pair<bool, mysql::binlog::event::Log_event_basic_info>
4685 const char *buf, size_t length,
4687
4688/**
4689 @} (end of group Replication)
4690*/
4691
4692#endif /* _log_event_h */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
int64 query_id_t
Definition: binlog.h:72
Contains the classes representing events occurring in the replication stream.
#define LOG_EVENT_HEADER_LEN
Definition: binlog_event.h:443
This event is created to contain the file data.
Definition: log_event.h:2092
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:7040
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:7067
virtual int get_create_or_append() const
Definition: log_event.cc:7090
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:2126
size_t get_data_size() override
Definition: log_event.h:2117
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:7077
~Append_block_log_event() override=default
const char * get_db() override
Definition: log_event.h:2123
Append_block_log_event(Append_block_log_event &&) noexcept=delete
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:7120
The abstract class for basic output streams which provides write operation.
Definition: basic_ostream.h:37
Event for the first block of file to be loaded, its only difference from Append_block event is that t...
Definition: log_event.h:2242
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:7341
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:7331
~Begin_load_query_log_event() override=default
Begin_load_query_log_event(THD *thd)
Begin_load_query_log_event(Begin_load_query_log_event &&) noexcept=delete
int get_create_or_append() const override
Definition: log_event.cc:7337
Delete_file_log_event is created when the LOAD_DATA query fails on the master for some reason,...
Definition: log_event.h:2164
Delete_file_log_event(const Delete_file_log_event &)=delete
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:7281
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:7259
size_t get_data_size() override
Definition: log_event.h:2187
~Delete_file_log_event() override=default
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:2195
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:7236
const char * get_db() override
Definition: log_event.h:2192
Delete_file_log_event(Delete_file_log_event &&) noexcept=delete
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:7269
Log row deletions.
Definition: log_event.h:3528
bool read_write_bitmaps_cmp(const TABLE *table) const override
Compares the table's read/write_set with the columns included in this event's before-image and/or aft...
Definition: log_event.h:3549
static bool binlog_row_logging_function(THD *thd, TABLE *table, bool is_transactional, const uchar *before_record, const uchar *after_record)
Definition: log_event.cc:12459
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12512
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:12479
Delete_rows_log_event(THD *, TABLE *, const mysql::binlog::event::Table_id &, bool is_transactional, const unsigned char *extra_row_ndb_info)
Definition: log_event.cc:12448
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3557
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12519
@ TYPE_CODE
Definition: log_event.h:3532
int do_before_row_operations(const Relay_log_info *const) override
Definition: log_event.cc:12486
Event responsible for LOAD DATA execution, it similar to Query_log_event but before executing the que...
Definition: log_event.h:2309
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:7495
bool is_sbr_logging_format() const override
When a query log event contains a non-transaction control statement, we assume that it is changing da...
Definition: log_event.h:2334
bool write_post_header_for_derived(Basic_ostream *ostream) override
Definition: log_event.cc:7405
int pack_info(Protocol *protocol) override
This (which is used only for SHOW BINLOG EVENTS) could be updated to print SET @session_var=.
Definition: log_event.cc:7464
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:7399
ulong get_post_header_size_for_derived() override
Definition: log_event.cc:7395
Execute_load_query_log_event(THD *thd, const char *query_arg, ulong query_length, uint fn_pos_start_arg, uint fn_pos_end_arg, mysql::binlog::event::enum_load_dup_handling dup_handling_arg, bool using_trans, bool immediate, bool suppress_use, int errcode)
Definition: log_event.cc:7354
~Execute_load_query_log_event() override=default
Definition: field.h:577
For binlog version 4.
Definition: log_event.h:1525
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:5355
std::atomic< int32 > atomic_usage_counter
Definition: log_event.h:1543
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5361
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:5534
size_t get_data_size() override
Definition: log_event.h:1556
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5371
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5505
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5454
Format_description_log_event()
Format_description_log_event 1st ctor.
Definition: log_event.cc:5246
This is a subclass if Gtid_event and Log_event.
Definition: log_event.h:3962
void set_trx_length_by_cache_size_tagged(ulonglong cache_size, bool is_checksum_enabled=false, int event_counter=0)
Set the transaction length information based on binlog cache size.
Definition: log_event.cc:13605
rpl_gno get_gno() const override
Return the GNO for this GTID.
Definition: log_event.h:4131
rpl_sidno get_sidno(bool need_lock)
Return the SIDNO relative to the global tsid_map for this GTID.
Definition: log_event.cc:13636
~Gtid_log_event() override=default
bool write_data_header(Basic_ostream *ostream) override
Writes the post-header to the given output stream.
Definition: log_event.cc:13319
Gtid_log_event(Gtid_log_event &&) noexcept=delete
size_t get_event_length()
Definition: log_event.h:4027
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13586
enum_gtid_type get_type() const
Return the gtid type for this Gtid_log_event: this can be either ANONYMOUS_GTID, AUTOMATIC_GTID,...
Definition: log_event.h:4095
uint32 write_body_to_memory(uchar *buff)
Writes the body to the given memory buffer.
Definition: log_event.cc:13356
Gtid_log_event(const Gtid_log_event &)=delete
uint32 write_tagged_event_body_to_memory(uchar *buffer)
Writes the body to the given memory buffer.
Definition: log_event.cc:13329
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:13430
uint32 write_post_header_to_memory(uchar *buffer)
Writes the post-header to the given memory buffer.
Definition: log_event.cc:13259
static const size_t SET_STRING_PREFIX_LENGTH
Length of SET_STRING_PREFIX.
Definition: log_event.h:4141
Tsid tsid
TSID for this GTID.
Definition: log_event.h:4154
const Tsid & get_tsid() const
Return the TSID for this GTID.
Definition: log_event.h:4101
Gtid_specification get_gtid_spec()
Definition: log_event.cc:13649
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13421
void set_trx_length_by_cache_size(ulonglong cache_size, bool is_checksum_enabled=false, int event_counter=0)
Set the transaction length information based on binlog cache size.
Definition: log_event.cc:13615
static const size_t MAX_SET_STRING_LENGTH
The maximal length of the entire "SET ..." query.
Definition: log_event.h:4143
void update_parent_gtid_info()
Updates parent tsid and gtid info structure.
Definition: log_event.cc:13084
static const char * SET_STRING_PREFIX
string holding the text "SET @@GLOBAL.GTID_NEXT = '"
Definition: log_event.h:4137
void clear_gtid_and_spec()
Clears tsid and spec.
Definition: log_event.cc:13090
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:13174
Gtid_specification spec
Internal representation of the GTID.
Definition: log_event.h:4152
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13155
size_t get_data_size() override
Definition: log_event.h:4008
size_t to_string(char *buf) const
Used internally by both print() and pack_info().
Definition: log_event.cc:13163
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:13600
Represents a set of GTIDs.
Definition: rpl_gtid.h:1556
Definition: rpl_utility.h:110
Definition: log_event.h:3848
Heartbeat_log_event_v2(const char *buf, const mysql::binlog::event::Format_description_event *description_event)
Definition: log_event.cc:14504
Definition: log_event.h:3840
Heartbeat_log_event(const char *buf, const mysql::binlog::event::Format_description_event *description_event)
Definition: log_event.cc:14497
Base class for ignorable log events is Ignorable_event.
Definition: log_event.h:3694
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12856
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:12849
size_t get_data_size() override
Definition: log_event.h:3727
Ignorable_log_event(Ignorable_log_event &&) noexcept=delete
~Ignorable_log_event() override
Ignorable_log_event(const Ignorable_log_event &)=delete
Class representing an incident, an occurrence out of the ordinary, that happened on the master.
Definition: log_event.h:3603
Incident_log_event(const Incident_log_event &)=delete
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:12801
size_t get_data_size() override
Definition: log_event.h:3656
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:12827
~Incident_log_event() override
Definition: log_event.cc:12715
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:12761
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12734
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:12728
const char * description() const
Definition: log_event.cc:12719
bool ends_group() const override
Definition: log_event.h:3661
Incident_log_event(Incident_log_event &&) noexcept=delete
The class derives from the class Intvar_event in Binlog API, defined in the header binlog_event....
Definition: log_event.h:1601
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5851
~Intvar_log_event() override=default
Intvar_log_event(Intvar_log_event &&) noexcept=delete
size_t get_data_size() override
Definition: log_event.h:1630
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:5930
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:5861
Intvar_log_event(const Intvar_log_event &)=delete
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5826
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:1638
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5905
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5925
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
Definition: key.h:113
Definition: sql_list.h:467
Definition: log_event.h:2345
bool has_replace
Definition: log_event.h:2365
const size_t BUF_SIZE
Definition: log_event.h:2354
const char * table_name
Definition: log_event.h:2361
const char * fname
Definition: log_event.h:2362
const sql_exchange * sql_ex
Definition: log_event.h:2359
THD * thd
Definition: log_event.h:2358
bool has_ignore
Definition: log_event.h:2366
String str
Definition: log_event.h:2355
const char * db
Definition: log_event.h:2360
bool is_concurrent
Definition: log_event.h:2364
const String * generate(size_t *fn_start, size_t *fn_end)
Definition: log_event.cc:7604
Load_query_generator(THD *thd_arg, const sql_exchange *ex, const char *db_arg, const char *table_name_arg, bool is_concurrent_arg, bool replace, bool ignore)
Definition: log_event.cc:7587
This is the abstract base class for binary log events.
Definition: log_event.h:538
bool write_header(Basic_ostream *ostream, size_t data_length)
Writes the common-header of this event to the given output stream and updates the checksum.
Definition: log_event.cc:1255
ulong mts_group_idx
Index in rli->gaq array to indicate a group that this event is purging.
Definition: log_event.h:693
bool is_mts_sequential_exec()
Is called from get_mts_execution_mode() to.
Definition: log_event.h:909
bool is_using_stmt_cache() const
Definition: log_event.h:839
enum_skip_reason continue_group(Relay_log_info *rli)
Helper function to ignore an event w.r.t.
Definition: log_event.cc:2473
bool is_no_filter_event() const
Definition: log_event.h:833
int apply_event(Relay_log_info *rli)
Apply the event to the database.
Definition: log_event.cc:3074
virtual int do_apply_event(Relay_log_info const *rli)
Primitive to apply an event to the database.
Definition: log_event.h:1162
virtual const char * get_db()
Definition: log_event.cc:1058
enum_event_cache_type event_cache_type
Defines the type of the cache, if any, where the event will be stored before being flushed to disk.
Definition: log_event.h:676
int net_send(Protocol *protocol, const char *log_name, my_off_t pos)
Only called by SHOW BINLOG EVENTS.
Definition: log_event.cc:1063
uint32 write_header_to_memory(uchar *buf)
Writes the common header of this event to the given memory buffer.
Definition: log_event.cc:1216
virtual mysql::binlog::event::Log_event_type get_type_code() const
Definition: log_event.h:797
virtual bool starts_group() const
Events of a certain type can start or end a group of events treated transactionally wrt binlog.
Definition: log_event.h:1094
uint32 server_id
Definition: log_event.h:664
enum_mts_event_exec_mode
Definition: log_event.h:929
@ EVENT_EXEC_PARALLEL
Definition: log_event.h:933
@ EVENT_EXEC_SYNC
Definition: log_event.h:941
@ EVENT_EXEC_CAN_NOT
Definition: log_event.h:945
@ EVENT_EXEC_ASYNC
Definition: log_event.h:937
enum_skip_reason shall_skip(Relay_log_info *rli)
Decide if the event shall be skipped, and the reason for skipping it.
Definition: log_event.h:1137
bool is_valid()
Definition: log_event.cc:1308
virtual uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter)
The method fills in pointers to event's database name c-strings to a supplied array.
Definition: log_event.h:1056
ha_checksum crc
Placeholder for event checksum while writing to binlog.
Definition: log_event.h:686
virtual size_t get_data_size()
Definition: log_event.h:879
bool wrapper_my_b_safe_write(Basic_ostream *ostream, const uchar *buf, size_t data_length)
Write the given buffer to the given output stream, updating the checksum if checksums are enabled.
Definition: log_event.cc:1194
enum_event_cache_type
Definition: log_event.h:567
@ EVENT_CACHE_COUNT
Definition: log_event.h:589
@ EVENT_INVALID_CACHE
Definition: log_event.h:568
@ EVENT_NO_CACHE
Definition: log_event.h:585
@ EVENT_STMT_CACHE
Definition: log_event.h:574
@ EVENT_TRANSACTIONAL_CACHE
Definition: log_event.h:580
enum_skip_reason
Enumeration of what kinds of skipping (and non-skipping) that can occur when the slave executes an ev...
Definition: log_event.h:547
@ EVENT_SKIP_IGNORE
Skip event by ignoring it.
Definition: log_event.h:558
@ EVENT_SKIP_COUNT
Skip event and decrease skip counter.
Definition: log_event.h:563
@ EVENT_SKIP_NOT
Don't skip event.
Definition: log_event.h:551
bool m_free_temp_buf_in_destructor
Definition: log_event.h:655
bool contains_partition_info(bool)
Definition: log_event.cc:2493
bool is_relay_log_event() const
Definition: log_event.h:827
bool is_ignorable_event() const
Definition: log_event.h:830
ulonglong future_event_relay_log_pos
A copy of the main rli value stored into event to pass to MTS worker rli.
Definition: log_event.h:716
int update_pos(Relay_log_info *rli)
Update the relay log position.
Definition: log_event.h:1129
virtual int do_apply_event_worker(Slave_worker *w)
Definition: log_event.cc:982
void set_artificial_event()
Definition: log_event.h:815
const char * get_type_str() const
Returns the human readable name of this event's type.
Definition: log_event.cc:898
time_t get_time()
Prints a "session_var=value" string.
Definition: log_event.cc:875
bool write_footer(Basic_ostream *ostream)
Definition: log_event.cc:1203
Relay_log_info * worker
MTS: associating the event with either an assigned Worker or Coordinator.
Definition: log_event.h:711
bool is_using_trans_cache() const
Definition: log_event.h:836
enum enum_mts_event_exec_mode get_mts_execution_mode(bool mts_in_group)
MTS Coordinator finds out a way how to execute the current event.
Definition: log_event.h:963
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli)
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:1004
db_worker_hash_entry * mts_assigned_partitions[MAX_DBS_IN_EVENT_MTS]
Partition info associate with event to deliver to MTS event applier.
Definition: log_event.h:723
virtual bool write(Basic_ostream *ostream)
Definition: log_event.h:785
ulong rbr_exec_mode
A storage to cache the global system variable's value.
Definition: log_event.h:670
mysql::binlog::event::Log_event_header * common_header
The Log_event_header class contains the variable present in the common header.
Definition: log_event.h:699
virtual void set_mts_isolate_group()
Definition: log_event.h:1035
THD * thd
Definition: log_event.h:719
int apply_gtid_event(Relay_log_info *rli)
Apply the GTID event in curr_group_data to the database.
Definition: log_event.cc:3030
mysql::binlog::event::Log_event_footer * common_footer
The Log_event_footer class contains the variable present in the common footer.
Definition: log_event.h:705
virtual bool write_data_body(Basic_ostream *)
Definition: log_event.h:794
Log_event(mysql::binlog::event::Log_event_header *header, mysql::binlog::event::Log_event_footer *footer, enum_event_cache_type cache_type_arg, enum_event_logging_type logging_type_arg)
This minimal constructor is for when you are not even sure that there is a valid THD.
Definition: log_event.cc:934
void register_temp_buf(char *buf, bool free_in_destructor=true)
Definition: log_event.h:865
virtual uint8 mts_number_dbs()
Definition: log_event.h:1073
void free_temp_buf()
Definition: log_event.h:869
bool is_mts_group_isolated()
Definition: log_event.h:1080
ulong exec_time
Definition: log_event.h:658
virtual bool is_rbr_logging_format() const
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:808
virtual ~Log_event()
Definition: log_event.h:864
enum_event_logging_type event_logging_type
Defines when information, i.e.
Definition: log_event.h:682
enum_event_logging_type
Definition: log_event.h:592
@ EVENT_NORMAL_LOGGING
Definition: log_event.h:598
@ EVENT_IMMEDIATE_LOGGING
Definition: log_event.h:603
@ EVENT_INVALID_LOGGING
Definition: log_event.h:593
@ EVENT_CACHE_LOGGING_COUNT
Definition: log_event.h:607
char * temp_buf
Definition: log_event.h:648
virtual bool is_sbr_logging_format() const
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:804
virtual int pack_info(Protocol *protocol)
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:1053
bool is_using_immediate_logging() const
Definition: log_event.h:842
void set_relay_log_event()
Definition: log_event.h:823
virtual bool write_data_header(Basic_ostream *)
Definition: log_event.h:793
static void init_show_field_list(mem_root_deque< Item * > *field_list)
init_show_field_list() prepares the column names and types for the output of SHOW BINLOG EVENTS; it i...
Definition: log_event.cc:1086
bool is_artificial_event() const
Definition: log_event.h:824
virtual int do_update_pos(Relay_log_info *rli)
Advance relay log coordinates.
Definition: log_event.cc:996
virtual bool ends_group() const
Definition: log_event.h:1099
bool need_checksum()
A decider of whether to trigger checksum computation or not.
Definition: log_event.cc:1115
virtual void claim_memory_ownership(bool claim)
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.h:862
Slave_worker * get_slave_worker(Relay_log_info *rli)
The method maps the event to a Worker and return a pointer to it.
Definition: log_event.cc:2621
This is the subclass of Previous_gtids_event and Log_event It is used to record the gtid_executed in ...
Definition: log_event.h:4213
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13740
Previous_gtids_log_event(Previous_gtids_log_event &&) noexcept=delete
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13747
char * get_str(size_t *length, const Gtid_set::String_format *string_format) const
Return the formatted string, or NULL on error.
Definition: log_event.cc:13721
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13684
int do_apply_event(Relay_log_info const *) override
Primitive to apply an event to the database.
Definition: log_event.h:4305
int add_to_set(Gtid_set *gtid_set) const
Add all GTIDs from this event to the given Gtid_set.
Definition: log_event.cc:13710
size_t get_data_size() override
Definition: log_event.h:4236
enum_skip_reason do_shall_skip(Relay_log_info *) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.h:4300
bool write(Basic_ostream *ostream) override
Definition: log_event.h:4244
~Previous_gtids_log_event() override=default
const uchar * get_buf()
Return the encoded buffer, or NULL on error.
Definition: log_event.h:4281
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:13658
Definition: protocol.h:33
A Query event is written to the binary log whenever the database is modified on the master,...
Definition: log_event.h:1285
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5127
bool need_sql_require_primary_key
Whether or not the statement represented by this event requires Q_SQL_REQUIRE_PRIMARY_KEY to be logge...
Definition: log_event.h:1491
bool is_sbr_logging_format() const override
When a query log event contains a non-transaction control statement, we assume that it is changing da...
Definition: log_event.h:1461
Query_log_event(const Query_log_event &)=delete
bool is_trans_keyword() const
Definition: log_event.h:1429
mysql::binlog::event::Log_event_header::Byte * data_buf
Definition: log_event.h:1287
bool m_skip_temp_tables_handling_by_worker
Instructs the applier to skip temporary tables handling.
Definition: log_event.h:1329
static size_t get_query(const char *buf, size_t length, const mysql::binlog::event::Format_description_event *fd_event, const char **query_arg)
Return the query string pointer (and its size) from a Query log event using only the event buffer (we...
Definition: log_event.cc:5177
Query_log_event()
The simplest constructor that could possibly work.
Definition: log_event.cc:3661
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:5141
virtual ulong get_post_header_size_for_derived()
Definition: log_event.h:1413
bool starts_group() const override
Notice, DDL queries are logged without BEGIN/COMMIT parentheses and identification of such single-que...
Definition: log_event.h:1469
uchar mts_number_dbs() override
Definition: log_event.h:1380
my_thread_id slave_proxy_id
Definition: log_event.h:1302
void set_skip_temp_tables_handling_by_worker()
Definition: log_event.h:1331
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:5230
bool has_ddl_committed
The flag indicates whether the DDL query has been (already) committed or not.
Definition: log_event.h:1322
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:4407
~Query_log_event() override
Definition: log_event.h:1398
void attach_temp_tables_worker(THD *, const Relay_log_info *)
Associating slave Worker thread to a subset of temporary tables.
Definition: log_event.cc:4384
bool write(Basic_ostream *ostream) override
Query_log_event::write().
Definition: log_event.cc:3368
bool rollback_injected_by_coord
True if this is a ROLLBACK event injected by the mts coordinator to finish a group corresponding to a...
Definition: log_event.h:1310
bool is_query_prefix_match(const char *pattern, uint p_len)
Definition: log_event.h:1485
uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter) override
Definition: log_event.h:1355
bool needs_default_table_encryption
Whether or not the statement represented by this event requires Q_DEFAULT_TABLE_ENCRYPTION to be logg...
Definition: log_event.h:1495
const char * get_db() override
Definition: log_event.h:1342
int pack_info(Protocol *protocol) override
This (which is used only for SHOW BINLOG EVENTS) could be updated to print SET @session_var=.
Definition: log_event.cc:3317
bool ends_group() const override
Definition: log_event.h:1474
bool is_skip_temp_tables_handling_by_worker()
Definition: log_event.h:1335
virtual bool write_post_header_for_derived(Basic_ostream *)
Definition: log_event.h:1406
void detach_temp_tables_worker(THD *, const Relay_log_info *)
Dissociating slave Worker thread from its thd->temporary_tables to possibly update the involved entri...
Definition: log_event.cc:4398
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
Definition: log_event.h:1674
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5971
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:1708
~Rand_log_event() override=default
size_t get_data_size() override
Definition: log_event.h:1703
Rand_log_event(const Rand_log_event &)=delete
Rand_log_event(Rand_log_event &&) noexcept=delete
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:6016
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5997
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5947
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:6011
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:5965
Definition: rpl_rli.h:203
This will be deprecated when we move to using sequence ids.
Definition: log_event.h:2027
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5659
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5547
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:5802
~Rotate_log_event() override=default
Rotate_log_event(Rotate_log_event &&) noexcept=delete
Rotate_log_event(const Rotate_log_event &)=delete
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:5620
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5630
size_t get_data_size() override
Definition: log_event.h:2047
Definition: log_event.h:2657
bool is_enabled()
If instrumentation is enabled this member function SHALL return true.
Definition: log_event.h:2684
Rows_applier_psi_stage & operator=(const Rows_applier_psi_stage &rhs)
void inc_n_rows_applied(ulonglong delta)
Updates the counter of processed rows.
Definition: log_event.h:2730
ulonglong m_n_rows_applied
Counter that is unconditionally incremented on each row that is processed.
Definition: log_event.h:2672
ulonglong get_n_rows_applied()
Gets the value of the counter of rows that have been processed.
Definition: log_event.h:2736
Rows_applier_psi_stage()
Definition: log_event.h:2675
void update_work_estimated_and_completed(const uchar *cursor, const uchar *begin, const uchar *end)
This member function shall update the progress and reestimate the remaining work needed.
Definition: log_event.h:2697
void set_progress(PSI_stage_progress *progress)
Definition: log_event.h:2677
void end_work()
Resets this object.
Definition: log_event.h:2721
PSI_stage_progress * m_progress
A cached pointer to this stage PSI_stage_progress.
Definition: log_event.h:2665
Definition: log_event.h:2956
KEY ** m_key_info
Definition: log_event.h:2976
Key_compare(KEY **ki=nullptr)
Definition: log_event.h:2969
bool operator()(uchar *k1, uchar *k2) const
Definition: log_event.h:2970
Common base class for all row-containing log events.
Definition: log_event.h:2774
MY_BITMAP write_set_backup
This bitmap is used as a backup for the write set while we calculate the values for any hidden genera...
Definition: log_event.h:3279
uint32 m_bitbuf[128/(sizeof(uint32) *8)]
Definition: log_event.h:2937
uchar * m_rows_end
Definition: log_event.h:2946
int close_record_scan()
Does the cleanup.
Definition: log_event.cc:8864
virtual mysql::binlog::event::Log_event_type get_general_type_code()=0
int handle_idempotent_and_ignored_errors(Relay_log_info const *rli, int *err)
Private member function called while handling idempotent errors.
Definition: log_event.cc:8809
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:10393
virtual int do_before_row_operations(const Relay_log_info *const log)=0
uchar * m_rows_buf
Definition: log_event.h:2944
uint m_rows_lookup_algorithm
The algorithm to use while searching for rows using the before image.
Definition: log_event.h:2918
TABLE * m_table
Definition: log_event.h:2897
ColumnViewPtr m_column_view
Wrapper around TABLE *m_table that abstracts the table field set iteration logic, since it is not man...
Definition: log_event.h:3079
bool is_rbr_logging_format() const override
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:3066
int do_hash_row(Relay_log_info const *rli)
Populates the m_hash when using HASH_SCAN.
Definition: log_event.cc:9246
Hash_slave_rows m_hash
Hash table that will hold the entries for while using HASH_SCAN algorithm to search and update/delete...
Definition: log_event.h:2912
uchar * m_distinct_key_spare_buf
A spare buffer which will be used when saving the distinct keys for doing an index scan with HASH_SCA...
Definition: log_event.h:2984
int do_hash_scan_and_update(Relay_log_info const *rli)
Implementation of the hash_scan and update algorithm.
Definition: log_event.cc:9489
int add_row_data(uchar *data, size_t length)
Definition: log_event.h:2835
void decide_row_lookup_algorithm_and_key() SUPPRESS_UBSAN_CLANG10
Definition: log_event.cc:8418
uint m_key_index
Definition: log_event.h:2954
int do_apply_row(Relay_log_info const *rli)
Commodity wrapper around do_exec_row(), that deals with resetting the thd reference in the table.
Definition: log_event.cc:8839
int row_operations_scan_and_key_setup()
Definition: log_event.cc:8515
MY_BITMAP const * get_cols_ai() const
Definition: log_event.h:2844
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:10255
Rows_log_event(const Rows_log_event &)=delete
MY_BITMAP m_local_cols_ai
Bitmap denoting columns available in the after-image as they appear in the table setup.
Definition: log_event.h:2934
uchar * m_key
Definition: log_event.h:2953
int do_index_scan_and_update(Relay_log_info const *rli)
Implementation of the index scan and update algorithm.
Definition: log_event.cc:9015
int do_scan_and_update(Relay_log_info const *rli)
This member function scans the table and applies the changes that had been previously hashed.
Definition: log_event.cc:9314
virtual int do_add_row_data(uchar *data, size_t length)
Definition: log_event.cc:8151
@ RLE_NO_FLAGS
Definition: log_event.h:2810
Rows_applier_psi_stage m_psi_progress
Definition: log_event.h:2777
static bool is_trx_retryable_upon_engine_error(int error)
Helper function to check whether the storage engine error allows for the transaction to be retried or...
Definition: log_event.cc:8606
size_t get_data_size() override
Definition: log_event.cc:8118
const char * get_db() override
Definition: log_event.h:2868
uint16 flag_set
Definition: log_event.h:2787
row_lookup_mode
Definition: log_event.h:2789
@ ROW_LOOKUP_INDEX_SCAN
Definition: log_event.h:2792
@ ROW_LOOKUP_UNDEFINED
Definition: log_event.h:2790
@ ROW_LOOKUP_NOT_NEEDED
Definition: log_event.h:2791
@ ROW_LOOKUP_TABLE_SCAN
Definition: log_event.h:2793
@ ROW_LOOKUP_HASH_SCAN
Definition: log_event.h:2794
virtual bool read_write_bitmaps_cmp(const TABLE *table) const =0
Compares the table's read/write_set with the columns included in this event's before-image and/or aft...
virtual int skip_after_image_for_update_event(const Relay_log_info *rli, const uchar *curr_bi_start)
Seek past the after-image of an update event, in case a row was processed without reading the after-i...
Definition: log_event.h:3204
bool is_auto_inc_in_extra_columns(const Relay_log_info *const rli)
Helper function to check whether there is an auto increment column on the table where the event is to...
Definition: log_event.cc:8588
uchar * m_rows_cur
Definition: log_event.h:2945
const mysql::binlog::event::Table_id & get_table_id() const
Definition: log_event.h:2845
uint m_row_count
Definition: log_event.h:2871
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:9593
int next_record_scan(bool first_read)
Fetches next row.
Definition: log_event.cc:8877
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:10499
int do_table_scan_and_update(Relay_log_info const *rli)
Implementation of the legacy table_scan and update algorithm.
Definition: log_event.cc:9510
MY_BITMAP m_local_cols
Bitmap denoting columns available in the image as they appear in the table setup.
Definition: log_event.h:2906
int open_record_scan()
Initializes scanning of rows.
Definition: log_event.cc:8939
void clear_flags(flag_set flags_arg)
Definition: log_event.h:2815
virtual int do_exec_row(const Relay_log_info *const rli)=0
std::set< uchar *, Key_compare >::iterator m_itr
Definition: log_event.h:2979
enum_error
Enumeration of the errors that can be returned.
Definition: log_event.h:2800
@ ERR_TABLE_LIMIT_EXCEEDED
No more room for tables.
Definition: log_event.h:2803
@ ERR_BAD_TABLE_DEF
Table definition does not match.
Definition: log_event.h:2805
@ ERR_OPEN_FAILURE
Failure to open table.
Definition: log_event.h:2801
@ ERR_RBR_TO_SBR
daisy-chanining RBR to SBR not allowed
Definition: log_event.h:2806
@ ERR_OUT_OF_MEM
Out of memory.
Definition: log_event.h:2804
@ ERR_OK
No error.
Definition: log_event.h:2802
int row_operations_scan_and_key_teardown(int error)
Definition: log_event.cc:8558
int update_generated_columns(MY_BITMAP const &fields_to_update)
Updates the generated columns of the TABLE object referenced by m_table, that have an active bit in t...
Definition: log_event.cc:8095
virtual int do_after_row_operations(const Relay_log_info *const log, int error)=0
MY_BITMAP const * get_cols() const
Definition: log_event.h:2843
std::set< uchar *, Key_compare > m_distinct_keys
Definition: log_event.h:2978
void do_post_row_operations(Relay_log_info const *rli, int err)
Private member function called after updating/deleting a row.
Definition: log_event.cc:8721
Rows_log_event(Rows_log_event &&) noexcept=delete
const uchar * m_curr_row
Definition: log_event.h:2951
MY_BITMAP m_cols_ai
Bitmap for columns available in the after image, if present.
Definition: log_event.h:2927
int add_key_to_distinct_keyset()
Populates the m_distinct_keys with unique keys to be modified during HASH_SCAN over keys.
Definition: log_event.cc:8995
KEY * m_key_info
Definition: log_event.h:2955
int unpack_current_row(const Relay_log_info *const rli, MY_BITMAP const *cols, bool is_after_image, bool only_seek=false)
Unpack the current row image from the event into m_table->record[0].
Definition: log_event.cc:8002
int do_update_pos(Relay_log_info *rli) override
The method either increments the relay log position or commits the current statement and increments t...
Definition: log_event.cc:10361
~Rows_log_event() override
Definition: log_event.cc:7982
void set_flags(flag_set flags_arg)
Definition: log_event.h:2814
friend class Old_rows_log_event
Definition: log_event.h:3271
const uchar * m_curr_row_end
Definition: log_event.h:2952
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:10466
uint32 m_bitbuf_ai[128/(sizeof(uint32) *8)]
Definition: log_event.h:2938
MY_BITMAP m_cols
Definition: log_event.h:2899
It is used to record the original query for the rows events in RBR.
Definition: log_event.h:3766
size_t get_data_size() override
Definition: log_event.h:3815
~Rows_query_log_event() override
Definition: log_event.h:3808
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:12988
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:12971
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:12886
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12893
Rows_query_log_event(THD *thd_arg, const char *query, size_t query_len)
Definition: log_event.h:3769
Rpl_filter.
Definition: rpl_filter.h:214
const char * get_rewrite_db(const char *db, size_t *new_len)
Definition: rpl_filter.cc:1176
bool is_rewrite_empty()
Definition: rpl_filter.cc:571
Mix-in to handle the message logging and reporting for relay log info and master log info structures.
Definition: rpl_reporting.h:54
Definition: rpl_rli_pdb.h:498
Definition: log_event.h:1951
mysql::binlog::event::Log_event_type get_type_code() const override
Definition: log_event.h:1980
Stop_log_event()
Definition: log_event.h:1960
~Stop_log_event() override=default
Stop_log_event(const Stop_log_event &)=delete
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:6961
enum_skip_reason do_shall_skip(Relay_log_info *) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.h:1989
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:6981
String class wrapper with a preallocated buffer of size buff_sz.
Definition: sql_string.h:681
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Table_map_log_event which maps a table definition to a number.
Definition: log_event.h:2429
@ TM_GENERATED_INVISIBLE_PK_F
Table has generated invisible primary key.
Definition: log_event.h:2472
@ TM_BIT_LEN_EXACT_F
Definition: log_event.h:2465
@ TM_NO_FLAGS
Definition: log_event.h:2464
@ TM_REFERRED_FK_DB_F
Definition: log_event.h:2466
Table_map_log_event(Table_map_log_event &&) noexcept=delete
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:11025
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:10890
@ TYPE_CODE
Definition: log_event.h:2438
Table_map_log_event(const Table_map_log_event &)=delete
uint8 mts_number_dbs() override
Definition: log_event.h:2521
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:11034
const char * get_db_name() const
Definition: log_event.h:2513
virtual int save_field_metadata()
Save the field metadata based on the real_type of the field.
Definition: log_event.cc:10587
bool init_set_str_value_field()
Definition: log_event.cc:11342
flag_set get_flags(flag_set flag) const
Definition: log_event.h:2475
~Table_map_log_event() override
bool init_geometry_type_field()
Definition: log_event.cc:11390
bool init_charset_field(std::function< bool(const Field *)> include_type, Optional_metadata_field_type default_charset_type, Optional_metadata_field_type column_charset_type)
Capture and serialize character sets.
Definition: log_event.cc:11236
bool init_primary_key_field()
Definition: log_event.cc:11421
enum_flag
Definition: log_event.h:2452
@ ENUM_FLAG_COUNT
Nothing here right now, but the flags support is there in preparation for changes that are coming.
Definition: log_event.h:2459
bool is_rbr_logging_format() const override
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:2583
const mysql::binlog::event::Table_id & get_table_id() const
Definition: log_event.h:2509
bool init_column_visibility_field()
Definition: log_event.cc:11469
const char * get_table_name() const
Definition: log_event.h:2512
uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter) override
Definition: log_event.h:2533
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:11039
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:11053
bool init_enum_str_value_field()
Definition: log_event.cc:11369
bool init_column_name_field()
Definition: log_event.cc:11330
ColumnViewPtr m_column_view
Wrapper around TABLE *m_table that abstracts the table field set iteration logic, since it is not man...
Definition: log_event.h:2607
const char * get_db() override
Definition: log_event.h:2520
size_t get_data_size() override
Definition: log_event.h:2515
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:11501
TABLE * m_table
Definition: log_event.h:2593
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:10771
void init_metadata_fields()
Capture the optional metadata fields which should be logged into table_map_log_event and serialize th...
Definition: log_event.cc:11182
enum_error
Enumeration of the errors that can be returned.
Definition: log_event.h:2443
@ ERR_OK
No error.
Definition: log_event.h:2445
@ ERR_TABLE_LIMIT_EXCEEDED
No more room for tables.
Definition: log_event.h:2446
@ ERR_OPEN_FAILURE
Failure to open table.
Definition: log_event.h:2444
@ ERR_OUT_OF_MEM
Out of memory.
Definition: log_event.h:2447
@ ERR_BAD_TABLE_DEF
Table definition does not match.
Definition: log_event.h:2448
@ ERR_RBR_TO_SBR
daisy-chanining RBR to SBR not allowed
Definition: log_event.h:2449
bool has_generated_invisible_primary_key() const
Definition: log_event.cc:10767
bool init_vector_dimensionality_field()
Definition: log_event.cc:11407
StringBuffer< 1024 > m_metadata_buf
Definition: log_event.h:2596
bool init_signedness_field()
Definition: log_event.cc:11205
This is the subclass of Transaction_context_event and Log_event This class encodes the transaction_co...
Definition: log_event.h:4335
static int get_data_set_size(std::list< const char * > *set)
Definition: log_event.cc:13982
void add_write_set(const char *hash)
Add a hash which identifies a inserted/updated/deleted row on the ongoing transaction.
Definition: log_event.cc:13994
my_thread_id get_thread_id() const
Return the id of the committing thread.
Definition: log_event.h:4439
Transaction_context_log_event(const char *server_uuid_arg, bool using_trans, my_thread_id thread_id_arg, bool is_gtid_specified)
Definition: log_event.cc:13756
void add_read_set(const char *hash)
Add a hash which identifies a read row on the ongoing transaction.
Definition: log_event.cc:13999
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13874
Gtid_set * get_snapshot_version()
Return the transaction snapshot timestamp.
Definition: log_event.h:4429
size_t get_data_size() override
Definition: log_event.cc:13881
int do_apply_event(Relay_log_info const *) override
Primitive to apply an event to the database.
Definition: log_event.h:4389
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13849
bool read_snapshot_version()
Read snapshot version from encoded buffers.
Definition: log_event.cc:13962
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:13841
Gtid_set * snapshot_version
A gtid_set which is used to store the transaction set used for conflict detection.
Definition: log_event.h:4341
size_t get_event_length()
Definition: log_event.cc:13893
Tsid_map * tsid_map
The Tsid_map to use for creating the Gtid_set.
Definition: log_event.h:4338
std::list< const char * > * get_read_set()
Return a pointer to read-set list.
Definition: log_event.h:4416
size_t get_snapshot_version_size()
Definition: log_event.cc:13976
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:13898
bool is_gtid_specified() const
Return true if transaction has GTID fully specified, false otherwise.
Definition: log_event.h:4446
~Transaction_context_log_event() override
Definition: log_event.cc:13824
bool write_data_set(Basic_ostream *ostream, std::list< const char * > *set)
Definition: log_event.cc:13942
std::list< const char * > * get_write_set()
Return a pointer to write-set list.
Definition: log_event.h:4404
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13914
size_t to_string(char *buf, ulong len) const
Definition: log_event.cc:13835
const char * get_server_uuid()
Return the server uuid.
Definition: log_event.h:4434
bool write_snapshot_version(Basic_ostream *ostream)
Definition: log_event.cc:13926
Mts_db_names & get_mts_db_names()
Definition: log_event.h:3882
Mts_db_names m_mts_db_names
Definition: log_event.h:3876
void reset()
Definition: log_event.h:3881
virtual ~Applier_context()
Definition: log_event.h:3880
Definition: log_event.h:3869
size_t get_event_length()
Definition: log_event.h:3917
void set_mts_dbs(Mts_db_names &arg)
Definition: log_event.cc:14247
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:14226
uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter) override
The method fills in pointers to event's database name c-strings to a supplied array.
Definition: log_event.cc:14232
bool apply_payload_event(Relay_log_info const *rli, const uchar *event_buf)
Definition: log_event.cc:14318
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:14404
bool ends_group() const override
Definition: log_event.cc:14451
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:14409
~Transaction_payload_log_event() override=default
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:14441
size_t get_data_size() override
Definition: log_event.cc:14218
Transaction_payload_log_event(THD *thd_arg, const char *payload, uint64_t payload_size, uint16_t compression_type, uint64_t uncompressed_size)
Definition: log_event.h:3885
Applier_context m_applier_ctx
Definition: log_event.h:3922
uint8 mts_number_dbs() override
Definition: log_event.cc:14263
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:14267
Represents a bidirectional map between TSID and SIDNO.
Definition: rpl_gtid.h:749
rpl_sidno add_tsid(const Tsid &tsid)
Add the given TSID to this map if it does not already exist.
Definition: rpl_gtid_tsid_map.cc:61
Log row updates with a before image.
Definition: log_event.h:3408
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12657
static mysql::binlog::event::Log_event_type get_update_rows_event_type(const THD *thd_arg)
Auxiliary function used in the (THD*, ...) constructor to determine the type code based on configurat...
Definition: log_event.cc:12544
static bool binlog_row_logging_function(THD *thd, TABLE *table, bool is_transactional, const uchar *before_record, const uchar *after_record)
Definition: log_event.cc:12572
bool read_write_bitmaps_cmp(const TABLE *table) const override
Compares the table's read/write_set with the columns included in this event's before-image and/or aft...
Definition: log_event.h:3441
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:12617
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12650
@ TYPE_CODE
Definition: log_event.h:3412
Update_rows_log_event(THD *, TABLE *, const mysql::binlog::event::Table_id &table_id, MY_BITMAP const *cols_bi, MY_BITMAP const *cols_ai, bool is_transactional, const unsigned char *extra_row_ndb_info)
int do_before_row_operations(const Relay_log_info *const) override
Definition: log_event.cc:12624
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3450
~Update_rows_log_event() override
Definition: log_event.cc:12595
int skip_after_image_for_update_event(const Relay_log_info *rli, const uchar *curr_bi_start) override
Seek past the after-image of an update event, in case a row was processed without reading the after-i...
Definition: log_event.cc:9188
void init(MY_BITMAP const *cols)
Definition: log_event.cc:12579
Every time a query uses the value of a user variable, a User_var_log_event is written before the Quer...
Definition: log_event.h:1882
~User_var_log_event() override=default
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:1936
bool is_deferred()
Definition: log_event.h:1925
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:6909
query_id_t query_id
Definition: log_event.h:1892
void set_deferred(query_id_t qid)
Definition: log_event.h:1930
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6530
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:6799
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:6928
User_var_log_event(const User_var_log_event &)=delete
User_var_log_event(User_var_log_event &&) noexcept=delete
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:6914
bool deferred
Definition: log_event.h:1891
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6628
This is the subclass of View_change_log_event and Log_event This class created the view_change_log_ev...
Definition: log_event.h:4475
std::map< std::string, std::string > * get_certification_info()
Returns the certification info.
Definition: log_event.h:4543
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:14139
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:14066
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:14156
void set_seq_number(rpl_gno number)
Set the certification sequence number.
Definition: log_event.h:4552
char * get_view_id()
Returns the view id.
Definition: log_event.h:4525
size_t get_size_data_map(std::map< std::string, std::string > *map)
Definition: log_event.cc:14047
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:14072
size_t get_data_size() override
Definition: log_event.cc:14038
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:14145
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:14098
rpl_gno get_seq_number()
Returns the certification sequence number.
Definition: log_event.h:4557
bool write_data_map(Basic_ostream *ostream, std::map< std::string, std::string > *map)
Definition: log_event.cc:14164
void set_certification_info(std::map< std::string, std::string > *info, size_t *event_size)
Sets the certification info in the event.
Definition: log_event.cc:14200
View_change_log_event(const View_change_log_event &)=delete
size_t to_string(char *buf, ulong len) const
Definition: log_event.cc:14061
Log row insertions and updates.
Definition: log_event.h:3319
int do_before_row_operations(const Relay_log_info *const) override
Definition: log_event.cc:11987
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:12434
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3352
Write_rows_log_event(THD *, TABLE *, const mysql::binlog::event::Table_id &table_id, bool is_transactional, const unsigned char *extra_row_ndb_info)
Definition: log_event.cc:11957
bool read_write_bitmaps_cmp(const TABLE *table) const override
Compares the table's read/write_set with the columns included in this event's before-image and/or aft...
Definition: log_event.h:3341
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12411
int write_row(const Relay_log_info *const, const bool)
Write the current row into event's table.
Definition: log_event.cc:12176
@ TYPE_CODE
Definition: log_event.h:3323
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12095
static bool binlog_row_logging_function(THD *thd, TABLE *table, bool is_transactional, const uchar *before_record, const uchar *after_record)
Definition: log_event.cc:11967
Similar to Xid_log_event except that.
Definition: log_event.h:1821
static const int xid_bufs_size
Definition: log_event.h:1824
bool do_commit(THD *thd) override
Differs from Xid_log_event::do_commit in that it carries out XA prepare (not the commit).
Definition: log_event.cc:6486
XA_prepare_log_event(THD *thd_arg, XID *xid_arg, bool one_phase_arg=false)
Definition: log_event.h:1828
size_t get_data_size() override
Definition: log_event.h:1844
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6424
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:6452
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6410
mysql::binlog::event::Log_event_type get_type_code() const override
Definition: log_event.h:1841
Definition: log_event.h:1747
enum_skip_reason do_shall_skip(Relay_log_info *rli) override
Decide if this event shall be skipped or not and the reason for skipping it.
Definition: log_event.cc:6396
bool ends_group() const override
Definition: log_event.h:1760
Xid_apply_log_event(THD *thd_arg, mysql::binlog::event::Log_event_header *header_arg, mysql::binlog::event::Log_event_footer *footer_arg)
Definition: log_event.h:1750
virtual bool do_commit(THD *thd_arg)=0
int do_apply_event_worker(Slave_worker *rli) override
Worker commits Xid transaction and in case of its transactional info table marks the current group as...
Definition: log_event.cc:6151
~Xid_apply_log_event() override=default
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:6224
This is the subclass of Xid_event defined in libbinlogevent, An XID event is generated for a commit o...
Definition: log_event.h:1770
~Xid_log_event() override=default
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6077
Xid_log_event(const Xid_log_event &)=delete
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6054
size_t get_data_size() override
Definition: log_event.h:1796
bool do_commit(THD *thd_arg) override
The methods combines few commit actions to make it usable as in the single- so multi- threaded case.
Definition: log_event.cc:6110
void claim_memory_ownership(bool claim) override
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
Definition: log_event.cc:6071
Xid_log_event(Xid_log_event &&) noexcept=delete
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
This event is created to contain the file data.
Definition: load_data_events.h:274
const char * db
'db' is filled when the event is created in mysql_load() (the event needs to have a 'db' member to be...
Definition: load_data_events.h:311
unsigned int block_len
Definition: load_data_events.h:298
Event for the first block of file to be loaded, its only difference from Append_block event is that t...
Definition: load_data_events.h:358
@ APPEND_BLOCK_HEADER_LEN
Definition: binlog_event.h:882
@ IGNORABLE_HEADER_LEN
Definition: binlog_event.h:896
@ FORMAT_DESCRIPTION_HEADER_LEN
Definition: binlog_event.h:886
@ INCIDENT_HEADER_LEN
Definition: binlog_event.h:894
@ DELETE_FILE_HEADER_LEN
Definition: binlog_event.h:883
@ ROTATE_HEADER_LEN
Definition: binlog_event.h:880
const Log_event_header * header() const
Return a const pointer to the header of the log event.
Definition: binlog_event.h:959
Binary_log_event & operator=(const Binary_log_event &)=default
const Log_event_footer * footer() const
Return a const pointer to the footer of the log event.
Definition: binlog_event.h:967
DELETE_FILE_EVENT occurs when the LOAD DATA failed on the master.
Definition: load_data_events.h:202
const char * db
Definition: load_data_events.h:215
Log row deletions.
Definition: rows_event.h:1136
Event responsible for LOAD DATA execution, it similar to Query_event but before executing the query i...
Definition: load_data_events.h:119
For binlog version 4.
Definition: control_events.h:239
GTID stands for Global Transaction IDentifier It is composed of two parts:
Definition: control_events.h:1016
int get_server_version_length() const
We only store the immediate_server_version if both server versions are the same.
Definition: control_events.h:1236
int get_commit_timestamp_length() const
Definition: control_events.h:1226
int get_commit_group_ticket_length() const
Returns the length of the packed commit_group_ticket field.
Definition: control_events.cpp:620
bool is_tagged() const
Checks whether this Gtid log event contains a tag.
Definition: control_events.cpp:650
unsigned long long get_trx_length() const
Definition: control_events.h:1315
static const int POST_HEADER_LENGTH
Total length of post header.
Definition: control_events.h:1254
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1669
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1743
Base class for ignorable log events.
Definition: control_events.h:674
Class representing an incident, an occurrence out of the ordinary, that happened on the master.
Definition: control_events.h:440
char * message
Definition: control_events.h:491
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:461
size_t message_length
Definition: control_events.h:492
enum_incident
Enumeration of the incidents that can occur for the server.
Definition: control_events.h:445
@ INCIDENT_NONE
No incident.
Definition: control_events.h:447
@ INCIDENT_COUNT
Shall be last event of the enumeration.
Definition: control_events.h:451
An Intvar_event will be created just before a Query_event, if the query uses one of the variables LAS...
Definition: statement_events.h:921
Intvar_event(const char *buf, const Format_description_event *fde)
Constructor receives a packet from the MySQL master or the binary log and decodes it to create an Int...
Definition: statement_events.cpp:483
The Common-Header always has the same form and length within one version of MySQL.
Definition: binlog_event.h:685
unsigned long long log_pos
Definition: binlog_event.h:716
unsigned char Byte
The following type definition is to be used whenever data is placed and manipulated in a common buffe...
Definition: binlog_event.h:731
Log_event_type type_code
Event type extracted from the header.
Definition: binlog_event.h:701
void set_is_valid(bool is_valid)
Set if the event object shall be considered valid or not.
Definition: binlog_event.h:765
uint16_t flags
Definition: binlog_event.h:724
Definition: control_events.h:1380
size_t buf_size
Definition: control_events.h:1408
const unsigned char * buf
Definition: control_events.h:1409
A Query_event is created for each query that modifies the database, unless the query is logged row-ba...
Definition: statement_events.h:451
const char * db
Definition: statement_events.h:535
const char * query
Definition: statement_events.h:534
unsigned char mts_accessed_dbs
Definition: statement_events.h:640
char mts_accessed_db_names[MAX_DBS_IN_EVENT_MTS][NAME_LEN]
Definition: statement_events.h:641
size_t q_len
Definition: statement_events.h:587
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
Definition: statement_events.h:1033
Rand_event(unsigned long long seed1_arg, unsigned long long seed2_arg)
Definition: statement_events.h:1043
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:116
unsigned int flags
Definition: control_events.h:120
size_t ident_len
Definition: control_events.h:119
Common base class for all row-containing binary log events.
Definition: rows_event.h:882
Table_id m_table_id
Actual event type.
Definition: rows_event.h:954
enum_flag get_flags() const
Definition: rows_event.h:1034
uint16_t m_flags
Definition: rows_event.h:955
Rows query event type, which is a subclass of the Ignorable_event, to record the original query for t...
Definition: rows_event.h:1177
char * m_rows_query
Definition: rows_event.h:1207
size_t m_rows_query_length
Definition: rows_event.h:1208
A stop event is written to the log files under these circumstances:
Definition: control_events.h:379
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:385
Each table share has a table id, it is mainly used for row based replication.
Definition: table_id.h:42
In row-based mode, every row operation event is preceded by a Table_map_event which maps a table defi...
Definition: rows_event.h:525
unsigned char * m_coltype
Definition: rows_event.h:686
std::string m_tblnam
Definition: rows_event.h:683
uint16_t flag_set
Definition: rows_event.h:534
unsigned char * m_null_bits
field metadata
Definition: rows_event.h:693
Optional_metadata_field_type
DEFAULT_CHARSET and COLUMN_CHARSET don't appear together, and ENUM_AND_SET_DEFAULT_CHARSET and ENUM_A...
Definition: rows_event.h:548
unsigned long m_colcnt
Definition: rows_event.h:685
unsigned char * m_field_metadata
Definition: rows_event.h:692
unsigned long m_field_metadata_size
The size of field metadata buffer set by calling save_field_metadata()
Definition: rows_event.h:691
size_t m_data_size
Definition: rows_event.h:678
std::string m_dbnam
event data size
Definition: rows_event.h:681
flag_set m_flags
Definition: rows_event.h:676
unsigned int m_optional_metadata_len
Definition: rows_event.h:694
Table_id m_table_id
Event post header contents.
Definition: rows_event.h:675
unsigned char * m_optional_metadata
Definition: rows_event.h:695
This class is used to combine the information of the ongoing transaction including the write set and ...
Definition: control_events.h:1468
bool gtid_specified
Definition: control_events.h:1504
uint32_t thread_id
Definition: control_events.h:1503
std::list< const char * > read_set
Definition: control_events.h:1508
const char * server_uuid
Definition: control_events.h:1502
std::list< const char * > write_set
Definition: control_events.h:1507
Event that encloses all the events of a transaction.
Definition: control_events.h:735
Transaction_payload_event(const Transaction_payload_event &)=delete
An unknown event should never occur.
Definition: binlog_event.h:997
Log row updates with a before image.
Definition: rows_event.h:1117
Written every time a statement uses a user variable; precedes other events for the statement.
Definition: statement_events.h:804
const char * name
Definition: statement_events.h:853
User_var_event(const char *name_arg, unsigned int name_len_arg, char *val_arg, unsigned long val_len_arg, Value_type type_arg, unsigned int charset_number_arg, unsigned char flags_arg)
This constructor will initialize the instance variables and the type_code, it will be used only by th...
Definition: statement_events.h:820
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:1568
long long int seq_number
Definition: control_events.h:1622
std::map< std::string, std::string > certification_info
Definition: control_events.h:1624
char view_id[ENCODED_VIEW_ID_MAX_LEN]
Definition: control_events.h:1620
Log row insertions.
Definition: rows_event.h:1099
An XA_prepare event is generated for a XA prepared transaction.
Definition: control_events.h:588
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:617
void * xid
Definition: control_events.h:608
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:523
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:530
uint64_t xid
Definition: control_events.h:540
Represents Transaction Source Identifier which is composed of source UUID and transaction tag.
Definition: tsid.h:47
static std::size_t get_size(const T &arg)
Definition: serializer_impl.hpp:70
Definition: partition_info.h:209
Used to hold information about file and file structure in exchange via non-DB file (....
Definition: sql_exchange.h:79
A table definition from the master.
Definition: rpl_utility.h:249
static uint vector_column_count(const unsigned char *types, ulong size)
Return the number of VECTOR columns.
Definition: rpl_utility.h:315
Maps table id's (integers) to table pointers.
Definition: rpl_tblmap.h:51
static char buf[MAX_BUF]
Definition: conf_to_src.cc:73
Contains the classes representing events operating in the replication stream properties.
#define U
Definition: ctype-tis620.cc:74
uint64_t sql_mode_t
Definition: dd_event.h:39
#define MAX_DBS_IN_EVENT_MTS
The maximum number of updated databases that a status of Query-log-event can carry.
Definition: binlog_event.h:117
#define MAX_TIME_ZONE_NAME_LENGTH
Maximum length of time zone name that we support (Time zone name is char(64) in db).
Definition: binlog_event.h:130
#define OVER_MAX_DBS_IN_EVENT_MTS
When the actual number of databases exceeds MAX_DBS_IN_EVENT_MTS the value of OVER_MAX_DBS_IN_EVENT_M...
Definition: binlog_event.h:124
void close_cached_file(IO_CACHE *cache)
Definition: mf_cache.cc:87
bool my_b_inited(const IO_CACHE *info)
Definition: my_sys.h:495
#define MY_WME
Definition: my_sys.h:128
int my_b_copy_to_file(IO_CACHE *cache, FILE *file)
Definition: mf_iocache2.cc:72
bool reinit_io_cache(IO_CACHE *info, enum cache_type type, my_off_t seek_offset, bool use_async_io, bool clear_cache)
Definition: mf_iocache.cc:328
@ WRITE_CACHE
Definition: my_sys.h:290
std::pair< bool, mysql::binlog::event::Log_event_basic_info > extract_log_event_basic_info(Log_event *log_event)
Extract basic info about an event: type, query, is it ignorable.
Definition: log_event.cc:14564
size_t my_strmov_quoted_identifier(THD *thd, char *buffer, const char *identifier, size_t length)
Definition: log_event.cc:14524
bool is_atomic_ddl_event(Log_event const *evt)
The function checks the argument event properties to deduce whether it represents an atomic DDL.
Definition: log_event.h:4588
char * str_to_hex(char *to, const char *from, size_t len)
Transforms a string into "" or its expression in 0x... form.
Definition: log_event.cc:801
bool binary_event_serialize(EVENT *ev, Basic_ostream *ostream)
Serialize an binary event to the given output stream.
Definition: log_event.h:4624
bool net_field_length_checked(const uchar **packet, size_t *max_length, T *out)
Read an integer in net_field_length format, guarding against read out of bounds and advancing the pos...
Definition: log_event.cc:761
TYPELIB binlog_checksum_typelib
Definition: log_event.cc:221
bool is_atomic_ddl(THD *thd, bool using_trans)
The function lists all DDL instances that are supported for crash-recovery (WL9175).
Definition: log_event.cc:3734
int ignored_error_code(int err_code)
Ignore error code specified on command line.
Definition: log_event.cc:607
MYSQL_PLUGIN_IMPORT char server_version[SERVER_VERSION_LENGTH]
Definition: log_event.h:125
std::unique_ptr< cs::util::ReplicatedColumnsView > ColumnViewPtr
Definition: log_event.h:121
bool is_any_gtid_event(const Log_event *evt)
Definition: log_event.h:4560
size_t my_strmov_quoted_identifier_helper(int q, char *buffer, const char *identifier, size_t length)
Definition: log_event.cc:14537
bool is_session_control_event(Log_event *evt)
Check if the given event is a session control event, one of User_var_event, Intvar_event or Rand_even...
Definition: log_event.h:4574
PSI_memory_key key_memory_Rows_query_log_event_rows_query
Definition: log_event.cc:196
const int64 SEQ_MAX_TIMESTAMP
Maximum value of binlog logical timestamp.
Definition: log_event.h:355
MYSQL_PLUGIN_IMPORT ulong server_id
Definition: log_event.h:118
static bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache, FILE *file, bool flush_stream)
Definition: log_event.h:3821
PSI_memory_key key_memory_Incident_log_event_message
Definition: log_event.cc:195
bool slave_execute_deferred_events(THD *thd)
The function is called by slave applier in case there are active table filtering rules to force gathe...
Definition: log_event.cc:6036
int append_query_string(const THD *thd, const CHARSET_INFO *csinfo, String const *from, String *to)
Append a version of the 'from' string suitable for use in a query to the 'to' string.
Definition: log_event.cc:819
int get_rpl_part_id(partition_info *part_info)
This method is used to extract the partition_id from a partitioned table.
Definition: log_event.cc:7757
#define LOG_EVENT_RELAY_LOG_F
Events with this flag set are created by slave IO thread and written to relay log.
Definition: log_event.h:283
#define LOG_EVENT_NO_FILTER_F
Events with this flag are not filtered (e.g.
Definition: log_event.h:303
#define LOG_EVENT_IGNORABLE_F
For an event, 'e', carrying a type code, that a slave, 's', does not recognize, 's' will check 'e' fo...
Definition: log_event.h:294
#define LOG_EVENT_ARTIFICIAL_F
Artificial events are created arbitrarily and not written to binary log.
Definition: log_event.h:275
#define LOG_EVENT_MTS_ISOLATE_F
MTS: group of events can be marked to force its execution in isolation from any other Workers.
Definition: log_event.h:314
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
#define mysql_stage_set_work_completed(P1, P2)
Definition: mysql_stage.h:115
#define mysql_stage_get_work_estimated(P1)
Definition: mysql_stage.h:143
#define mysql_stage_set_work_estimated(P1, P2)
Definition: mysql_stage.h:140
static int flag
Definition: hp_test1.cc:40
int key_cmp2(KEY_PART_INFO *key_part, const uchar *key1, uint key1_length, const uchar *key2, uint key2_length)
Compare two given keys.
Definition: key.cc:505
#define free(A)
Definition: lexyy.cc:915
LOAD DATA INFILE is not written to the binary log like other statements.
static int native_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: m_string.h:216
static bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2)
Quite unlike other C comparison functions ending with 'cmp', e.g.
Definition: my_bitmap.h:108
Abstraction functions over zlib/intrinsics.
std::uint32_t ha_checksum
Definition: my_checksum.h:106
Header for compiler-dependent features.
#define SUPPRESS_UBSAN_CLANG10
Definition: my_compiler.h:129
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
#define DBUG_EVALUATE_IF(keyword, a1, a2)
Definition: my_dbug.h:179
#define DBUG_TRACE
Definition: my_dbug.h:146
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint8_t uint8
Definition: my_inttypes.h:63
ulonglong my_off_t
Definition: my_inttypes.h:72
unsigned char uchar
Definition: my_inttypes.h:52
int64_t int64
Definition: my_inttypes.h:68
#define MYF(v)
Definition: my_inttypes.h:97
uint16_t uint16
Definition: my_inttypes.h:65
uint32_t uint32
Definition: my_inttypes.h:67
#define FN_REFLEN
Definition: my_io.h:83
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:57
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Functions related to handling of plugins and other dynamically loaded libraries.
#define MYSQL_PLUGIN_IMPORT
Definition: my_sharedlib.h:71
Common header for many mysys elements.
static my_thread_id thread_id
Definition: my_thr_init.cc:63
uint32 my_thread_id
Definition: my_thread_local.h:34
static char * query
Definition: myisam_ftdump.cc:47
Common definition between mysql server & client.
unsigned int net_length_size(unsigned long long num)
#define SERVER_VERSION_LENGTH
Definition: mysql_com.h:74
Instrumentation helpers for stages.
static void print_header(MYSQL_RES *result)
Definition: mysqladmin.cc:1279
bool short_form
static uint verbose
Definition: mysqlcheck.cc:66
static bool replace
Definition: mysqlimport.cc:70
static bool ignore
Definition: mysqlimport.cc:70
static const char * sql_mode
Definition: mysqlslap.cc:199
const char * delimiter
Definition: mysqlslap.cc:160
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: pfs.cc:38
Definition: buf0block_hint.cc:30
const std::string charset("charset")
const std::string FILE("FILE")
Definition: os0file.h:89
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
bool is_valid(const dd::Spatial_reference_system *srs, const Geometry *g, const char *func_name, bool *is_valid) noexcept
Decides if a geometry is valid.
Definition: is_valid.cc:95
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:927
void print(trx_t *trx, dict_index_t *index, std::ostream &out, ref_t ref, bool fatal)
Print information about the given LOB.
Definition: lob0impl.cc:1333
The namespace contains classes representing events that can occur in a replication stream.
Definition: binlog_event.cpp:36
Log_event_type
Enumeration type for the different types of log events.
Definition: binlog_event.h:286
@ INCIDENT_EVENT
Something out of the ordinary happened on the master.
Definition: binlog_event.h:330
@ FORMAT_DESCRIPTION_EVENT
Definition: binlog_event.h:312
@ EXECUTE_LOAD_QUERY_EVENT
Definition: binlog_event.h:315
@ ROWS_QUERY_LOG_EVENT
Definition: binlog_event.h:345
@ WRITE_ROWS_EVENT
Version 2 of the Row events.
Definition: binlog_event.h:348
@ DELETE_ROWS_EVENT
Definition: binlog_event.h:350
@ XA_PREPARE_LOG_EVENT
Definition: binlog_event.h:362
@ QUERY_EVENT
Definition: binlog_event.h:300
@ UNKNOWN_EVENT
Every time you add a type, you have to.
Definition: binlog_event.h:294
@ PREVIOUS_GTIDS_LOG_EVENT
Definition: binlog_event.h:355
@ UPDATE_ROWS_EVENT
Definition: binlog_event.h:349
@ RAND_EVENT
Definition: binlog_event.h:310
@ TABLE_MAP_EVENT
Definition: binlog_event.h:317
@ STOP_EVENT
Definition: binlog_event.h:301
@ INTVAR_EVENT
Definition: binlog_event.h:303
@ USER_VAR_EVENT
Definition: binlog_event.h:311
@ ROTATE_EVENT
Definition: binlog_event.h:302
@ SLAVE_EVENT
Definition: binlog_event.h:305
const uint64_t INVALID_XID
The following constant represents the maximum of MYSQL_XID domain.
Definition: statement_events.h:49
enum_load_dup_handling
Elements of this enum describe how LOAD DATA handles duplicates.
Definition: load_data_events.h:64
constexpr auto tsid_max_length
Maximum TSID text length (without null character)
Definition: tsid.h:41
HARNESS_EXPORT std::string string_format(const char *format,...)
Definition: utilities.cc:64
Definition: instrumented_condition_variable.h:32
const char * begin(const char *const c)
Definition: base64.h:44
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
const char * db_name
Definition: rules_table_service.cc:55
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2883
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2893
Performance schema instrumentation interface.
required string type
Definition: replication_group_member_actions.proto:34
required string event
Definition: replication_group_member_actions.proto:32
Contains the classes representing events which are used for row based replication.
Rpl_filter * rpl_filter
mysql::gtid::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of mysql::gtid::gno_t.
Definition: rpl_gtid.h:112
const int MAX_GNO_TEXT_LENGTH
The length of MAX_GNO when printed in decimal.
Definition: rpl_gtid.h:286
enum_gtid_type
Enumeration of different types of values for Gtid_specification, i.e, the different internal states t...
Definition: rpl_gtid.h:3860
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:108
mysql::gtid::Tsid Tsid
Definition: rpl_gtid_state.cc:56
enum_row_image_type
Definition: rpl_record.h:40
ulonglong my_xid
Definition: handler.h:1235
File containing constants that can be used throughout the server.
Our own string classes, used pervasively throughout the executor.
Contains the classes representing statement events occurring in the replication stream.
#define STRING_WITH_LEN(X)
Definition: string_with_len.h:29
char * strmake(char *dst, const char *src, size_t length)
Definition: strmake.cc:42
Definition: m_ctype.h:421
Class Gtid_set::String_format defines the separators used by Gtid_set::to_string.
Definition: rpl_gtid.h:1881
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:3977
enum_gtid_type type
The type of this GTID.
Definition: rpl_gtid.h:3990
Gtid gtid
The GTID: { SIDNO, GNO } if type == GTID; { 0, 0 } if type == AUTOMATIC or ANONYMOUS.
Definition: rpl_gtid.h:3996
rpl_gno gno
GNO of this Gtid.
Definition: rpl_gtid.h:1106
Definition: my_sys.h:346
const char * str
Definition: mysql_lex_string.h:41
Definition: my_bitmap.h:43
Definition: log_event.h:507
const char * name[MAX_DBS_IN_EVENT_MTS]
Definition: log_event.h:508
int num
Definition: log_event.h:509
Mts_db_names()=default
void reset_and_dispose()
Definition: log_event.h:513
Interface for an instrumented stage progress.
Definition: psi_stage_bits.h:63
LEX_CSTRING db
Definition: table.h:779
Definition: table.h:1407
TABLE_SHARE * s
Definition: table.h:1408
Definition: typelib.h:35
Legends running throughout the module:
Definition: rpl_rli_pdb.h:74
static bool is_any_gtid_event(const Log_event_type &type)
Helps to identify any GTID event - returns true for GTID_LOG_EVENT, GTID_TAGGED_LOG_EVENT and ANONYMO...
Definition: binlog_event.h:399
Metadata_fields organizes m_optional_metadata into a structured format which is easy to access.
Definition: rows_event.h:579
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:83
Include file for Sun RPC to compile out of the box.
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:39
Definition: dtoa.cc:588
synode_no q[FIFO_SIZE]
Definition: xcom_base.cc:4086
static uint64_t cache_size
Definition: xcom_cache.cc:362