MySQL 9.5.0
Source Code Documentation
log_event.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2025, 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;
125struct db_worker_hash_entry;
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 */
725 db_worker_hash_entry *mts_assigned_partitions[MAX_DBS_IN_EVENT_MTS];
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 */
911 bool is_mts_sequential_exec() const {
914
915 static bool is_mts_sequential_exec(
917 switch (type_code) {
923 return true;
924 default:
925 return false;
926 }
927 }
928
929 /*
930 possible decisions by get_mts_execution_mode().
931 The execution mode can be PARALLEL or not (thereby sequential
932 unless impossible at all). When it's sequential it further breaks into
933 ASYNChronous and SYNChronous.
934 */
936 /*
937 Event is run by a Worker.
938 */
940 /*
941 Event is run by Coordinator.
942 */
944 /*
945 Event is run by Coordinator and requires synchronization with Workers.
946 */
948 /*
949 Event can't be executed neither by Workers nor Coordinator.
950 */
952 };
953
955 bool mts_in_group, mysql::binlog::event::Log_event_type type_code,
956 uint32 server_id, uint32 log_pos) {
957 /*
958 Slave workers are unable to handle Format_description_log_event,
959 Rotate_log_event and Previous_gtids_log_event correctly.
960 However, when a transaction spans multiple relay logs, these
961 events occur in the middle of a transaction. The way we handle
962 this is by marking the events as 'ASYNC', meaning that the
963 coordinator thread will handle the events without stopping the
964 worker threads.
965
966 @todo Refactor this: make Log_event::get_slave_worker handle
967 transaction boundaries in a more robust way, so that it is able
968 to process Format_description_log_event, Rotate_log_event, and
969 Previous_gtids_log_event. Then, when these events occur in the
970 middle of a transaction, make them part of the transaction so
971 that the worker that handles the transaction handles these
972 events too. /Sven
973 */
974 if (
975 /*
976 When a Format_description_log_event occurs in the middle of
977 a transaction, it either has the slave's server_id, or has
978 end_log_pos==0.
979
980 @todo This does not work when master and slave have the same
981 server_id and replicate-same-server-id is enabled, since
982 events that are not in the middle of a transaction will be
983 executed in ASYNC mode in that case.
984 */
986 ((server_id == (uint32)::server_id) || (log_pos == 0))) ||
987 /*
988 All Previous_gtids_log_events in the relay log are generated
989 by the slave. They don't have any meaning to the applier, so
990 they can always be ignored by the applier. So we can process
991 them asynchronously by the coordinator. It is also important
992 to not feed them to workers because that confuses
993 get_slave_worker.
994 */
996 /*
997 Rotate_log_event can occur in the middle of a transaction.
998 When this happens, either it is a Rotate event generated on
999 the slave which has the slave's server_id, or it is a Rotate
1000 event that originates from a master but has end_log_pos==0.
1001 */
1002 (type_code == mysql::binlog::event::ROTATE_EVENT &&
1003 ((server_id == (uint32)::server_id) ||
1004 (log_pos == 0 && mts_in_group))))
1005 return EVENT_EXEC_ASYNC;
1006 else if (is_mts_sequential_exec(type_code))
1007 return EVENT_EXEC_SYNC;
1008 else
1009 return EVENT_EXEC_PARALLEL;
1010 }
1011
1012 private:
1013 /**
1014 MTS Coordinator finds out a way how to execute the current event.
1015
1016 Besides the parallelizable case, some events have to be applied by
1017 Coordinator concurrently with Workers and some to require synchronization
1018 with Workers (@c see wait_for_workers_to_finish) before to apply them.
1019
1020 @param mts_in_group the being group parsing status, true
1021 means inside the group
1022
1023 @retval EVENT_EXEC_PARALLEL if event is executed by a Worker
1024 @retval EVENT_EXEC_ASYNC if event is executed by Coordinator
1025 @retval EVENT_EXEC_SYNC if event is executed by Coordinator
1026 with synchronization against the Workers
1027 */
1028 enum enum_mts_event_exec_mode get_mts_execution_mode(bool mts_in_group) {
1029 return get_mts_execution_mode(mts_in_group, get_type_code(), server_id,
1031 }
1032
1033 /**
1034 @return index in [0, M] range to indicate
1035 to be assigned worker;
1036 M is the max index of the worker pool.
1037 */
1039
1040 /*
1041 Group of events can be marked to force its execution
1042 in isolation from any other Workers.
1043 Typically that is done for a transaction that contains
1044 a query accessing more than OVER_MAX_DBS_IN_EVENT_MTS databases.
1045 Factually that's a sequential mode where a Worker remains to
1046 be the applier.
1047 */
1048 virtual void set_mts_isolate_group() {
1049 assert(ends_group() ||
1053 }
1054
1055 public:
1056 /**
1057 The method fills in pointers to event's database name c-strings
1058 to a supplied array.
1059 In other than Query-log-event case the returned array contains
1060 just one item.
1061 @param[out] arg pointer to a struct containing char* array
1062 pointers to be filled in and the number
1063 of filled instances.
1064 @param rpl_filter pointer to a replication filter.
1065
1066 @return number of the filled instances indicating how many
1067 databases the event accesses.
1068 */
1069 virtual uint8 get_mts_dbs(Mts_db_names *arg,
1070 Rpl_filter *rpl_filter [[maybe_unused]]) {
1071 arg->name[0] = get_db();
1072
1073 return arg->num = mts_number_dbs();
1074 }
1075
1076 /*
1077 @return the number of updated by the event databases.
1078
1079 @note In other than Query-log-event case that's one.
1080 */
1081 virtual uint8 mts_number_dbs() { return 1; }
1082
1083 /**
1084 @return true if the terminal event of a group is marked to
1085 execute in isolation from other Workers,
1086 false otherwise
1087 */
1088 bool is_mts_group_isolated() {
1090 }
1091
1092 /**
1093 Events of a certain type can start or end a group of events treated
1094 transactionally wrt binlog.
1095
1096 Public access is required by implementation of recovery + skip.
1097
1098 @return true if the event starts a group (transaction)
1099 false otherwise
1101#endif
1102 virtual bool starts_group() const { return false; }
1103 /**
1104 @return true if the event ends a group (transaction)
1105 false otherwise
1106 */
1107 virtual bool ends_group() const { return false; }
1108#ifdef MYSQL_SERVER
1109 /**
1110 Apply the event to the database.
1111
1112 This function represents the public interface for applying an
1113 event.
1114
1115 @see do_apply_event
1116 */
1117 int apply_event(Relay_log_info *rli);
1118
1119 /**
1120 Apply the GTID event in curr_group_data to the database.
1121
1122 @param rli Pointer to coordinato's relay log info.
1123
1124 @retval 0 success
1125 @retval 1 error
1126 */
1127 inline int apply_gtid_event(Relay_log_info *rli);
1128
1129 /**
1130 Update the relay log position.
1131
1132 This function represents the public interface for "stepping over"
1133 the event and will update the relay log information.
1134
1135 @see do_update_pos
1136 */
1137 int update_pos(Relay_log_info *rli) { return do_update_pos(rli); }
1138
1139 /**
1140 Decide if the event shall be skipped, and the reason for skipping
1141 it.
1142
1143 @see do_shall_skip
1144 */
1146 DBUG_TRACE;
1148 DBUG_PRINT("info", ("skip reason=%d=%s", ret,
1149 ret == EVENT_SKIP_NOT ? "NOT"
1150 : ret == EVENT_SKIP_IGNORE ? "IGNORE"
1151 : "COUNT"));
1152 return ret;
1153 }
1154
1155 /**
1156 Primitive to apply an event to the database.
1157
1158 This is where the change to the database is made.
1159
1160 @note The primitive is protected instead of private, since there
1161 is a hierarchy of actions to be performed in some cases.
1162
1163 @see Format_description_log_event::do_apply_event()
1164
1165 @param rli Pointer to relay log info structure
1166
1167 @retval 0 Event applied successfully
1168 @retval errno Error code if event application failed
1169 */
1170 virtual int do_apply_event(Relay_log_info const *rli [[maybe_unused]]) {
1171 return 0; /* Default implementation does nothing */
1172 }
1173
1174 virtual int do_apply_event_worker(Slave_worker *w);
1175
1176 protected:
1177 /**
1178 Helper function to ignore an event w.r.t. the slave skip counter.
1179
1180 This function can be used inside do_shall_skip() for functions
1181 that cannot end a group. If the slave skip counter is 1 when
1182 seeing such an event, the event shall be ignored, the counter
1183 left intact, and processing continue with the next event.
1184
1185 A typical usage is:
1186 @code
1187 enum_skip_reason do_shall_skip(Relay_log_info *rli) {
1188 return continue_group(rli);
1189 }
1190 @endcode
1191
1192 @return Skip reason
1193 */
1195
1196 /**
1197 Advance relay log coordinates.
1198
1199 This function is called to advance the relay log coordinates to
1200 just after the event. It is essential that both the relay log
1201 coordinate and the group log position is updated correctly, since
1202 this function is used also for skipping events.
1203
1204 Normally, each implementation of do_update_pos() shall:
1205
1206 - Update the event position to refer to the position just after
1207 the event.
1208
1209 - Update the group log position to refer to the position just
1210 after the event <em>if the event is last in a group</em>
1211
1212 @param rli Pointer to relay log info structure
1213
1214 @retval 0 Coordinates changed successfully
1215 @retval errno Error code if advancing failed (usually just
1216 1). Observe that handler errors are returned by the
1217 do_apply_event() function, and not by this one.
1218 */
1219 virtual int do_update_pos(Relay_log_info *rli);
1220
1221 /**
1222 Decide if this event shall be skipped or not and the reason for
1223 skipping it.
1224
1225 The default implementation decide that the event shall be skipped
1226 if either:
1227
1228 - the server id of the event is the same as the server id of the
1229 server and <code>rli->replicate_same_server_id</code> is true,
1230 or
1231
1232 - if <code>rli->slave_skip_counter</code> is greater than zero.
1233
1234 @see do_apply_event
1235 @see do_update_pos
1236
1237 @retval Log_event::EVENT_SKIP_NOT
1238 The event shall not be skipped and should be applied.
1239
1240 @retval Log_event::EVENT_SKIP_IGNORE
1241 The event shall be skipped by just ignoring it, i.e., the slave
1242 skip counter shall not be changed. This happends if, for example,
1243 the originating server id of the event is the same as the server
1244 id of the slave.
1245
1246 @retval Log_event::EVENT_SKIP_COUNT
1247 The event shall be skipped because the slave skip counter was
1248 non-zero. The caller shall decrease the counter by one.
1249 */
1251#endif
1252};
1253
1254/*
1255 One class for each type of event.
1256 Two constructors for each class:
1257 - one to create the event for logging (when the server acts as a master),
1258 called after an update to the database is done,
1259 which accepts parameters like the query, the database, the options for LOAD
1260 DATA INFILE...
1261 - one to create the event from a packet (when the server acts as a slave),
1262 called before reproducing the update, which accepts parameters (like a
1263 buffer). Used to read from the master, from the relay log, and in
1264 mysqlbinlog. This constructor must be format-tolerant.
1265*/
1266
1267/**
1268 A Query event is written to the binary log whenever the database is
1269 modified on the master, unless row based logging is used.
1270
1271 Query_log_event is created for logging, and is called after an update to the
1272 database is done. It is used when the server acts as the master.
1273
1274 Virtual inheritance is required here to handle the diamond problem in
1275 the class @c Execute_load_query_log_event.
1276 The diamond structure is explained in @c Excecute_load_query_log_event
1277
1278 @internal
1279 The inheritance structure is as follows:
1280
1281 Binary_log_event
1282 ^
1283 |
1284 |
1285 Query_event Log_event
1286 \ /
1287 <<virtual>>\ /
1288 \ /
1289 Query_log_event
1290 @endinternal
1291*/
1293 public Log_event {
1294 protected:
1296
1297 public:
1298 // disable copy-move semantics
1299 Query_log_event(Query_log_event &&) noexcept = delete;
1300 Query_log_event &operator=(Query_log_event &&) noexcept = delete;
1301 Query_log_event(const Query_log_event &) = delete;
1302 Query_log_event &operator=(const Query_log_event &) = delete;
1303
1304 /*
1305 For events created by Query_log_event::do_apply_event (and
1306 Load_log_event::do_apply_event()) we need the *original* thread
1307 id, to be able to log the event with the original (=master's)
1308 thread id (fix for BUG#1686).
1309 */
1311
1312 /**
1313 True if this is a ROLLBACK event injected by the mts coordinator to finish a
1314 group corresponding to a partial transaction in the relay log.
1315 False otherwise and by default, as it must be explicitly set to true by the
1316 coordinator.
1317 */
1318 bool rollback_injected_by_coord = false;
1319
1320 /**
1321 The flag indicates whether the DDL query has been (already)
1322 committed or not. It's initialized as OFF at the event instantiation,
1323 flips ON when the DDL transaction has been committed with
1324 all its possible extra statement due to replication or GTID.
1325
1326 The flag status is also checked in few places to catch uncommitted
1327 transactions which can normally happen due to filtering out. In
1328 such a case the commit is deferred to @c Log_event::do_update_pos().
1329 */
1330 bool has_ddl_committed;
1331
1332#ifdef MYSQL_SERVER
1333
1334 /**
1335 Instructs the applier to skip temporary tables handling.
1336 */
1338
1342
1345 }
1346
1347 Query_log_event(THD *thd_arg, const char *query_arg, size_t query_length,
1348 bool using_trans, bool immediate, bool suppress_use,
1349 int error, bool ignore_command = false);
1350 const char *get_db() override { return db; }
1351
1352 /**
1353 @param[out] arg pointer to a struct containing char* array
1354 pointers be filled in and the number of
1355 filled instances.
1356 In case the number exceeds MAX_DBS_IN_EVENT_MTS,
1357 the overfill is indicated with assigning the number to
1358 OVER_MAX_DBS_IN_EVENT_MTS.
1359 @param rpl_filter pointer to a replication filter.
1360
1361 @return number of databases in the array or OVER_MAX_DBS_IN_EVENT_MTS.
1362 */
1365 // the empty string db name is special to indicate sequential applying
1366 mts_accessed_db_names[0][0] = 0;
1367 } else {
1368 for (uchar i = 0; i < mts_accessed_dbs; i++) {
1369 const char *db_name = mts_accessed_db_names[i];
1370
1371 // Only default database is rewritten.
1372 if (!rpl_filter->is_rewrite_empty() && !strcmp(get_db(), db_name)) {
1373 size_t dummy_len;
1374 const char *db_filtered =
1375 rpl_filter->get_rewrite_db(db_name, &dummy_len);
1376 // db_name != db_filtered means that db_name is rewritten.
1377 if (strcmp(db_name, db_filtered)) db_name = db_filtered;
1378 }
1379 arg->name[i] = db_name;
1380 }
1381 }
1382 return arg->num = mts_accessed_dbs;
1383 }
1384
1387
1388 uchar mts_number_dbs() override { return mts_accessed_dbs; }
1389
1390 int pack_info(Protocol *protocol) override;
1391#else
1392 void print_query_header(IO_CACHE *file,
1393 PRINT_EVENT_INFO *print_event_info) const;
1394 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1395 static bool rewrite_db_in_buffer(
1396 char **buf, ulong *event_len,
1398#endif
1399
1401
1403 const char *buf,
1406 ~Query_log_event() override {
1408 }
1409
1410 void claim_memory_ownership(bool claim) override;
1411
1412#ifdef MYSQL_SERVER
1413 bool write(Basic_ostream *ostream) override;
1414 virtual bool write_post_header_for_derived(Basic_ostream *) { return false; }
1415#endif
1416
1417 /*
1418 Returns number of bytes additionally written to post header by derived
1419 events (so far it is only Execute_load_query event).
1420 */
1421 virtual ulong get_post_header_size_for_derived() { return 0; }
1422 /* Writes derived event-specific part of post header. */
1423
1424 public: /* !!! Public in this patch to allow old usage */
1425#if defined(MYSQL_SERVER)
1427 int do_apply_event(Relay_log_info const *rli) override;
1428 int do_update_pos(Relay_log_info *rli) override;
1429
1430 int do_apply_event(Relay_log_info const *rli, const char *query_arg,
1431 size_t q_len_arg);
1432#endif /* MYSQL_SERVER */
1433 /*
1434 If true, the event always be applied by slave SQL thread or be printed by
1435 mysqlbinlog
1436 */
1437 bool is_trans_keyword() const {
1438 /*
1439 Before the patch for bug#50407, The 'SAVEPOINT and ROLLBACK TO'
1440 queries input by user was written into log events directly.
1441 So the keywords can be written in both upper case and lower case
1442 together, strncasecmp is used to check both cases. they also could be
1443 binlogged with comments in the front of these keywords. for examples:
1444 / * bla bla * / SAVEPOINT a;
1445 / * bla bla * / ROLLBACK TO a;
1446 but we don't handle these cases and after the patch, both quiries are
1447 binlogged in upper case with no comments.
1448 */
1449 return !strncmp(query, "BEGIN", q_len) ||
1450 !strncmp(query, "COMMIT", q_len) ||
1451 !native_strncasecmp(query, "SAVEPOINT", 9) ||
1452 !native_strncasecmp(query, "ROLLBACK", 8) ||
1453 !native_strncasecmp(query, STRING_WITH_LEN("XA START")) ||
1455 !native_strncasecmp(query, STRING_WITH_LEN("XA PREPARE")) ||
1456 !native_strncasecmp(query, STRING_WITH_LEN("XA COMMIT")) ||
1457 !native_strncasecmp(query, STRING_WITH_LEN("XA ROLLBACK"));
1458 }
1459
1460 /**
1461 When a query log event contains a non-transaction control statement, we
1462 assume that it is changing database content (DML) and was logged using
1463 binlog_format=statement.
1464
1465 @return True the event represents a statement that was logged using SBR
1466 that can change database content.
1467 False for transaction control statements.
1468 */
1469 bool is_sbr_logging_format() const override { return !is_trans_keyword(); }
1470
1471 /**
1472 Notice, DDL queries are logged without BEGIN/COMMIT parentheses
1473 and identification of such single-query group
1474 occurs within logics of @c get_slave_worker().
1476
1477 bool starts_group() const override {
1478 return !strncmp(query, "BEGIN", q_len) ||
1479 !strncmp(query, STRING_WITH_LEN("XA START"));
1481
1482 bool ends_group() const override {
1483 return !strncmp(query, "COMMIT", q_len) ||
1484 (!native_strncasecmp(query, STRING_WITH_LEN("ROLLBACK")) &&
1485 native_strncasecmp(query, STRING_WITH_LEN("ROLLBACK TO "))) ||
1486 !strncmp(query, STRING_WITH_LEN("XA ROLLBACK"));
1487 }
1488 static size_t get_query(
1489 const char *buf, size_t length,
1491 const char **query_arg);
1492
1493 bool is_query_prefix_match(const char *pattern, uint p_len) {
1494 return !strncmp(query, pattern, p_len);
1495 }
1496
1497 /** Whether or not the statement represented by this event requires
1498 `Q_SQL_REQUIRE_PRIMARY_KEY` to be logged along aside. */
1499 bool need_sql_require_primary_key{false};
1500
1501 /** Whether or not the statement represented by this event requires
1502 `Q_DEFAULT_TABLE_ENCRYPTION` to be logged along aside. */
1504};
1505
1506/**
1507 @class Format_description_log_event
1508
1509 For binlog version 4.
1510 This event is saved by threads which read it, as they need it for future
1511 use (to decode the ordinary events).
1512 This is the subclass of Format_description_event
1513
1514 @internal
1515 The inheritance structure in the current design for the classes is
1516 as follows:
1517
1518 Binary_log_event
1519 ^
1520 |
1521 |
1522 Format_description_event Log_event
1523 \ /
1524 \ /
1525 \ /
1526 Format_description_log_event
1527 @endinternal
1528 @section Format_description_log_event_binary_format Binary Format
1530
1533 public Log_event {
1534 public:
1535 /*
1536 MTS Workers and Coordinator share the event and that affects its
1537 destruction. Instantiation is always done by Coordinator/SQL thread.
1538 Workers are allowed to destroy only "obsolete" instances, those
1539 that are not actual for Coordinator anymore but needed to Workers
1540 that are processing queued events depending on the old instance.
1541 The counter of a new FD is incremented by Coordinator or Worker at
1542 time of {Relay_log_info,Slave_worker}::set_rli_description_event()
1543 execution.
1544 In the same methods the counter of the "old" FD event is decremented
1545 and when it drops to zero the old FD is deleted.
1546 The latest read from relay-log event is to be
1547 destroyed by Coordinator/SQL thread at its thread exit.
1548 Notice the counter is processed even in the single-thread mode where
1549 decrement and increment are done by the single SQL thread.
1550 */
1551 std::atomic<int32> atomic_usage_counter{0};
1552
1555 const char *buf,
1556 const mysql::binlog::event::Format_description_event *description_event);
1557#ifdef MYSQL_SERVER
1558 bool write(Basic_ostream *ostream) override;
1559 int pack_info(Protocol *protocol) override;
1560#else
1561 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1562#endif
1563
1564 size_t get_data_size() override {
1565 /*
1566 The vector of post-header lengths is considered as part of the
1567 post-header, because in a given version it never changes (contrary to the
1568 query in a Query_log_event).
1569 */
1572 }
1573
1574 void claim_memory_ownership(bool claim) override;
1575
1576 protected:
1577#if defined(MYSQL_SERVER)
1578 int do_apply_event(Relay_log_info const *rli) override;
1579 int do_update_pos(Relay_log_info *rli) override;
1581#endif
1582};
1583
1584/**
1585 @class Intvar_log_event
1586
1587 The class derives from the class Intvar_event in Binlog API,
1588 defined in the header binlog_event.h. An Intvar_log_event is
1589 created just before a Query_log_event, if the query uses one
1590 of the variables LAST_INSERT_ID or INSERT_ID. This class is used
1591 by the slave for applying the event.
1592
1593 @internal
1594 The inheritance structure in the current design for the classes is
1595 as follows:
1596
1597 Binary_log_event
1598 ^
1599 |
1600 |
1601 Intvar_event Log_event
1602 \ /
1603 \ /
1604 \ /
1605 Intvar_log_event
1606 @endinternal
1607*/
1609 public Log_event {
1610 public:
1611 // disable copy-move semantics
1612 Intvar_log_event(Intvar_log_event &&) noexcept = delete;
1613 Intvar_log_event &operator=(Intvar_log_event &&) noexcept = delete;
1614 Intvar_log_event(const Intvar_log_event &) = delete;
1615 Intvar_log_event &operator=(const Intvar_log_event &) = delete;
1617#ifdef MYSQL_SERVER
1618 Intvar_log_event(THD *thd_arg, uchar type_arg, ulonglong val_arg,
1619 enum_event_cache_type cache_type_arg,
1620 enum_event_logging_type logging_type_arg)
1621 : mysql::binlog::event::Intvar_event(type_arg, val_arg),
1622 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1623 footer()) {
1625 }
1626 int pack_info(Protocol *protocol) override;
1627#else
1628 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1629#endif
1630
1632 const char *buf,
1633 const mysql::binlog::event::Format_description_event *description_event);
1634 ~Intvar_log_event() override = default;
1635
1636 void claim_memory_ownership(bool claim) override;
1637
1638 size_t get_data_size() override {
1639 return 9; /* sizeof(type) + sizeof(val) */
1640 ;
1641 }
1642#ifdef MYSQL_SERVER
1643 bool write(Basic_ostream *ostream) override;
1644#endif
1645
1646 bool is_sbr_logging_format() const override { return true; }
1647
1648 private:
1649#if defined(MYSQL_SERVER)
1650 int do_apply_event(Relay_log_info const *rli) override;
1651 int do_update_pos(Relay_log_info *rli) override;
1653#endif
1654};
1655
1656/**
1657 @class Rand_log_event
1658
1659 Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
1660 4.1.1 does not need it (it's repeatable again) so this event needn't be
1661 written in 4.1.1 for PASSWORD() (but the fact that it is written is just a
1662 waste, it does not cause bugs).
1663
1664 The state of the random number generation consists of 128 bits,
1665 which are stored internally as two 64-bit numbers.
1666
1667 @internal
1668 The inheritance structure in the current design for the classes is
1669 as follows:
1670 Binary_log_event
1671 ^
1672 |
1673 |
1674 Rand_event Log_event
1675 \ /
1676 \ /
1677 \ /
1678 Rand_log_event
1679 @endinternal
1680*/
1682 public Log_event {
1683 public:
1684 // disable copy-move semantics
1685 Rand_log_event(Rand_log_event &&) noexcept = delete;
1686 Rand_log_event &operator=(Rand_log_event &&) noexcept = delete;
1687 Rand_log_event(const Rand_log_event &) = delete;
1688 Rand_log_event &operator=(const Rand_log_event &) = delete;
1690#ifdef MYSQL_SERVER
1691 Rand_log_event(THD *thd_arg, ulonglong seed1_arg, ulonglong seed2_arg,
1692 enum_event_cache_type cache_type_arg,
1693 enum_event_logging_type logging_type_arg)
1694 : mysql::binlog::event::Rand_event(seed1_arg, seed2_arg),
1695 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1696 footer()) {
1698 }
1699 int pack_info(Protocol *protocol) override;
1700#else
1701 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1702#endif
1703
1705 const char *buf,
1706 const mysql::binlog::event::Format_description_event *description_event);
1707 ~Rand_log_event() override = default;
1708
1709 void claim_memory_ownership(bool claim) override;
1710
1711 size_t get_data_size() override { return 16; /* sizeof(ulonglong) * 2*/ }
1712#ifdef MYSQL_SERVER
1713 bool write(Basic_ostream *ostream) override;
1714#endif
1715
1716 bool is_sbr_logging_format() const override { return true; }
1717
1718 private:
1719#if defined(MYSQL_SERVER)
1720 int do_apply_event(Relay_log_info const *rli) override;
1721 int do_update_pos(Relay_log_info *rli) override;
1723#endif
1724};
1725
1726/**
1727 @class Xid_log_event
1728
1729 This is the subclass of Xid_event defined in libbinlogevent,
1730 An XID event is generated for a commit of a transaction that modifies one or
1731 more tables of an XA-capable storage engine
1732 Logs xid of the transaction-to-be-committed in the 2pc protocol.
1733 Has no meaning in replication, slaves ignore it
1734 The inheritance structure in the current design for the classes is
1735 as follows
1736
1737 @internal
1738 The inheritance structure in the current design for the classes is
1739 as follows:
1740 Binary_log_event
1741 ^
1742 |
1743 |
1744 Xid_event Log_event
1745 \ /
1746 \ /
1747 \ /
1748 Xid_log_event
1749 @endinternal
1750*/
1751#ifndef MYSQL_SERVER
1752typedef ulonglong my_xid; // this line is the same as in handler.h
1753#endif
1754
1755class Xid_apply_log_event : public Log_event {
1756 protected:
1757#ifdef MYSQL_SERVER
1758 Xid_apply_log_event(THD *thd_arg,
1762 Log_event::EVENT_NORMAL_LOGGING, header_arg, footer_arg) {}
1763#endif
1766 : Log_event(header_arg, footer_arg) {}
1767 ~Xid_apply_log_event() override = default;
1768 bool ends_group() const override { return true; }
1769#if defined(MYSQL_SERVER)
1771 int do_apply_event(Relay_log_info const *rli) override;
1772 int do_apply_event_worker(Slave_worker *rli) override;
1773 virtual bool do_commit(THD *thd_arg) = 0;
1774#endif
1776
1778 public Xid_apply_log_event {
1779 public:
1780 // disable copy-move semantics
1781 Xid_log_event(Xid_log_event &&) noexcept = delete;
1782 Xid_log_event &operator=(Xid_log_event &&) noexcept = delete;
1783 Xid_log_event(const Xid_log_event &) = delete;
1784 Xid_log_event &operator=(const Xid_log_event &) = delete;
1786#ifdef MYSQL_SERVER
1787 Xid_log_event(THD *thd_arg, my_xid x)
1788 : mysql::binlog::event::Xid_event(x),
1789 Xid_apply_log_event(thd_arg, header(), footer()) {
1791 }
1792 int pack_info(Protocol *protocol) override;
1793#else
1794 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1795#endif
1796
1798 const char *buf,
1799 const mysql::binlog::event::Format_description_event *description_event);
1800 ~Xid_log_event() override = default;
1801
1802 void claim_memory_ownership(bool claim) override;
1803
1804 size_t get_data_size() override { return sizeof(xid); }
1805#ifdef MYSQL_SERVER
1806 bool write(Basic_ostream *ostream) override;
1807#endif
1808 private:
1809#if defined(MYSQL_SERVER)
1810 bool do_commit(THD *thd_arg) override;
1811#endif
1812};
1813
1814/**
1815 @class XA_prepare_log_event
1816
1817 Similar to Xid_log_event except that
1818 - it is specific to XA transaction
1819 - it carries out the prepare logics rather than the final committing
1820 when @c one_phase member is off.
1821 From the groupping perspective the event finalizes the current "prepare" group
1822 started with XA START Query-log-event.
1823 When @c one_phase is false Commit of Rollback for XA transaction are
1824 logged separately to the prepare-group events so being a groups of
1825 their own.
1827
1829 public Xid_apply_log_event {
1830 private:
1831 /* Total size of buffers to hold serialized members of XID struct */
1832 static const int xid_bufs_size = 12;
1833
1834 public:
1835#ifdef MYSQL_SERVER
1836 XA_prepare_log_event(THD *thd_arg, XID *xid_arg, bool one_phase_arg = false)
1837 : mysql::binlog::event::XA_prepare_event((void *)xid_arg, one_phase_arg),
1839#endif
1841 const char *buf,
1842 const mysql::binlog::event::Format_description_event *description_event)
1843 : mysql::binlog::event::XA_prepare_event(buf, description_event),
1845 DBUG_TRACE;
1846 xid = nullptr;
1847 return;
1848 }
1851 }
1852 size_t get_data_size() override {
1853 return xid_bufs_size + my_xid.gtrid_length + my_xid.bqual_length;
1854 }
1855
1856 void claim_memory_ownership(bool claim) override;
1857
1858#ifdef MYSQL_SERVER
1859 bool write(Basic_ostream *ostream) override;
1860#else
1861 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1862#endif
1863#if defined(MYSQL_SERVER)
1864 int pack_info(Protocol *protocol) override;
1865 bool do_commit(THD *thd) override;
1866#endif
1867};
1868
1869/**
1870 @class User_var_log_event
1871
1872 Every time a query uses the value of a user variable, a User_var_log_event is
1873 written before the Query_log_event, to set the user variable.
1874
1875 @internal
1876 The inheritance structure in the current design for the classes is
1877 as follows:
1878 Binary_log_event
1879 ^
1880 |
1881 |
1882 User_var_event Log_event
1883 \ /
1884 \ /
1885 \ /
1886 User_var_log_event
1887 @endinternal
1888*/
1890 public Log_event {
1891 public:
1892 // disable copy-move semantics
1894 User_var_log_event &operator=(User_var_log_event &&) noexcept = delete;
1895 User_var_log_event(const User_var_log_event &) = delete;
1896 User_var_log_event &operator=(const User_var_log_event &) = delete;
1898#ifdef MYSQL_SERVER
1901 User_var_log_event(THD *thd_arg, const char *name_arg, uint name_len_arg,
1902 char *val_arg, ulong val_len_arg, Item_result type_arg,
1903 uint charset_number_arg, uchar flags_arg,
1904 enum_event_cache_type cache_type_arg,
1905 enum_event_logging_type logging_type_arg)
1906 : mysql::binlog::event::User_var_event(name_arg, name_len_arg, val_arg,
1907 val_len_arg, type_arg,
1908 charset_number_arg, flags_arg),
1909 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1910 footer()),
1911 deferred(false) {
1912 common_header->set_is_valid(name != nullptr);
1913 }
1914 int pack_info(Protocol *protocol) override;
1915#else
1916 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1917#endif
1918
1920 const char *buf,
1921 const mysql::binlog::event::Format_description_event *description_event);
1922 ~User_var_log_event() override = default;
1923
1924 void claim_memory_ownership(bool claim) override;
1925
1926#ifdef MYSQL_SERVER
1927 bool write(Basic_ostream *ostream) override;
1928 /*
1929 Getter and setter for deferred User-event.
1930 Returns true if the event is not applied directly
1931 and which case the applier adjusts execution path.
1932 */
1933 bool is_deferred() { return deferred; }
1934 /*
1935 In case of the deferred applying the variable instance is flagged
1936 and the parsing time query id is stored to be used at applying time.
1937 */
1938 void set_deferred(query_id_t qid) {
1939 deferred = true;
1940 query_id = qid;
1941 }
1942#endif
1943
1944 bool is_sbr_logging_format() const override { return true; }
1945
1946 private:
1947#if defined(MYSQL_SERVER)
1948 int do_apply_event(Relay_log_info const *rli) override;
1949 int do_update_pos(Relay_log_info *rli) override;
1951#endif
1952};
1953
1954/**
1955 @class Stop_log_event
1957*/
1959 public Log_event {
1960 public:
1961 // disable copy-move semantics
1962 Stop_log_event(Stop_log_event &&) noexcept = delete;
1963 Stop_log_event &operator=(Stop_log_event &&) noexcept = delete;
1964 Stop_log_event(const Stop_log_event &) = delete;
1965 Stop_log_event &operator=(const Stop_log_event &) = delete;
1967#ifdef MYSQL_SERVER
1972 }
1973
1974#else
1975 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1976#endif
1977
1979 const char *buf,
1980 const mysql::binlog::event::Format_description_event *description_event)
1981 : mysql::binlog::event::Stop_event(buf, description_event),
1982 Log_event(header(), footer()) {
1983 DBUG_TRACE;
1984 return;
1987 ~Stop_log_event() override = default;
1990 }
1991
1992 void claim_memory_ownership(bool claim) override;
1993
1994 private:
1995#if defined(MYSQL_SERVER)
1996 int do_update_pos(Relay_log_info *rli) override;
1998 /*
1999 Events from ourself should be skipped, but they should not
2000 decrease the slave skip counter.
2001 */
2002 if (this->server_id == ::server_id)
2004 else
2006 }
2007#endif
2008};
2009
2010/**
2011 @class Rotate_log_event
2012
2013 This will be deprecated when we move to using sequence ids.
2014 This class is a subclass of Rotate_event, defined in binlogevent, and is used
2015 by the slave for updating the position in the relay log.
2016
2017 It is used by the master inorder to write the rotate event in the binary log.
2018
2019 @internal
2020 The inheritance structure in the current design for the classes is
2021 as follows:
2022
2023 Binary_log_event
2024 ^
2025 |
2026 |
2027 Rotate_event Log_event
2028 \ /
2029 \ /
2030 \ /
2031 Rotate_log_event
2032 @endinternal
2033*/
2035 public Log_event {
2036 public:
2037 // disable copy-move semantics
2038 Rotate_log_event(Rotate_log_event &&) noexcept = delete;
2039 Rotate_log_event &operator=(Rotate_log_event &&) noexcept = delete;
2040 Rotate_log_event(const Rotate_log_event &) = delete;
2041 Rotate_log_event &operator=(const Rotate_log_event &) = delete;
2042
2043#ifdef MYSQL_SERVER
2044 Rotate_log_event(const char *new_log_ident_arg, size_t ident_len_arg,
2045 ulonglong pos_arg, uint flags);
2046 int pack_info(Protocol *protocol) override;
2047#else
2048 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2049#endif
2050
2052 const char *buf,
2054 ~Rotate_log_event() override = default;
2055 size_t get_data_size() override {
2056 return ident_len +
2058 }
2059
2060 void claim_memory_ownership(bool claim) override;
2061
2062#ifdef MYSQL_SERVER
2063 bool write(Basic_ostream *ostream) override;
2064#endif
2065
2066 private:
2067#if defined(MYSQL_SERVER)
2068 int do_update_pos(Relay_log_info *rli) override;
2070#endif
2071};
2072
2073/**
2074 @class Append_block_log_event
2075
2076 This event is created to contain the file data. One LOAD_DATA_INFILE
2077 can have 0 or more instances of this event written to the binary log
2078 depending on the size of the file.
2079
2080 @internal
2081 The inheritance structure is as follows
2082
2083 Binary_log_event
2084 ^
2085 |
2086 |
2087 B_l:A_B_E Log_event
2088 \ /
2089 \ /
2090 <<vir>>\ /
2091 \ /
2092 Append_block_log_event
2093 B_l: Namespace Binary_log
2094 A_B_E: class Append_block_event
2095 @endinternal
2097*/
2100 public Log_event {
2101 public:
2102 // disable copy-move semantics
2103 Append_block_log_event(Append_block_log_event &&) noexcept = delete;
2105 delete;
2107 Append_block_log_event &operator=(const Append_block_log_event &) = delete;
2108
2109#ifdef MYSQL_SERVER
2110 Append_block_log_event(THD *thd, const char *db_arg, uchar *block_arg,
2111 uint block_len_arg, bool using_trans);
2112 int pack_info(Protocol *protocol) override;
2113 virtual int get_create_or_append() const;
2114#else
2115 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2116#endif
2117
2119 const char *buf,
2120 const mysql::binlog::event::Format_description_event *description_event);
2121 ~Append_block_log_event() override = default;
2122
2123 void claim_memory_ownership(bool claim) override;
2124
2125 size_t get_data_size() override {
2126 return block_len +
2128 }
2129#ifdef MYSQL_SERVER
2130 bool write(Basic_ostream *ostream) override;
2131 const char *get_db() override { return db; }
2132#endif
2133
2134 bool is_sbr_logging_format() const override { return true; }
2135
2136 private:
2137#if defined(MYSQL_SERVER)
2138 int do_apply_event(Relay_log_info const *rli) override;
2139#endif
2140};
2141
2142/**
2143 @class Delete_file_log_event
2144
2145 Delete_file_log_event is created when the LOAD_DATA query fails on the
2146 master for some reason, and the slave should be notified to abort the
2147 load. The event is required since the master starts writing the loaded
2148 block into the binary log before the statement ends. In case of error,
2149 the slave should abort, and delete any temporary file created while
2150 applying the (NEW_)LOAD_EVENT.
2151
2152 @internal
2153 The inheritance structure is as follows
2154
2155 Binary_log_event
2156 ^
2157 |
2158 |
2159 B_l:D_F_E Log_event
2160 \ /
2161 \ /
2162 \ /
2163 \ /
2164 Delete_file_log_event
2165
2166 B_l: Namespace Binary_log
2167 D_F_E: class Delete_file_event
2168 @endinternal
2170*/
2172 public Log_event {
2173 public:
2174 // disable copy-move semantics
2176 Delete_file_log_event &operator=(Delete_file_log_event &&) noexcept = delete;
2178 Delete_file_log_event &operator=(const Delete_file_log_event &) = delete;
2179
2180#ifdef MYSQL_SERVER
2181 Delete_file_log_event(THD *thd, const char *db_arg, bool using_trans);
2182 int pack_info(Protocol *protocol) override;
2183#else
2184 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2185 void print(FILE *file, PRINT_EVENT_INFO *print_event_info, bool enable_local);
2186#endif
2187
2189 const char *buf,
2190 const mysql::binlog::event::Format_description_event *description_event);
2191 ~Delete_file_log_event() override = default;
2192
2193 void claim_memory_ownership(bool claim) override;
2194
2195 size_t get_data_size() override {
2197 }
2198#ifdef MYSQL_SERVER
2199 bool write(Basic_ostream *ostream) override;
2200 const char *get_db() override { return db; }
2201#endif
2202
2203 bool is_sbr_logging_format() const override { return true; }
2204
2205 private:
2206#if defined(MYSQL_SERVER)
2207 int do_apply_event(Relay_log_info const *rli) override;
2208#endif
2209};
2210
2211/**
2212 @class Begin_load_query_log_event
2213
2214 Event for the first block of file to be loaded, its only difference from
2215 Append_block event is that this event creates or truncates existing file
2216 before writing data.
2217
2218 @internal
2219 The inheritance structure is as follows
2220
2221 Binary_log_event
2222 ^
2223 |
2224 |
2225 |
2226 Log_event B_l:A_B_E
2227 ^ /\
2228 | / \
2229 | <<vir>>/ \ <<vir>>
2230 | / \
2231 | / \
2232 | / \
2233 Append_block_log_event B_l:B_L_Q_E
2234 \ /
2235 \ /
2236 \ /
2237 \ /
2238 \ /
2239 Begin_load_query_log_event
2240
2241 B_l: Namespace Binary_log
2242 A_B_E: class Append_block_event
2243 B_L_Q_E: Begin_load_query_event
2244 @endinternal
2245
2246 @section Begin_load_query_log_event_binary_format Binary Format
2247*/
2249 : public Append_block_log_event,
2251 public:
2252 // disable copy-move semantics
2255 Begin_load_query_log_event &&) noexcept = delete;
2258 delete;
2259
2260#ifdef MYSQL_SERVER
2261 Begin_load_query_log_event(THD *thd_arg, const char *db_arg, uchar *block_arg,
2262 uint block_len_arg, bool using_trans);
2264 int get_create_or_append() const override;
2265#endif
2267 const char *buf,
2268 const mysql::binlog::event::Format_description_event *description_event);
2269 ~Begin_load_query_log_event() override = default;
2270
2271 void claim_memory_ownership(bool claim) override;
2272
2273 private:
2274#if defined(MYSQL_SERVER)
2276#endif
2277};
2278
2279/**
2280 @class Execute_load_query_log_event
2281
2282 Event responsible for LOAD DATA execution, it similar to Query_log_event
2283 but before executing the query it substitutes original filename in LOAD DATA
2284 query with name of temporary file.
2285
2286 @internal
2287 The inheritance structure is as follows:
2288
2289 Binary_log_event
2290 ^
2291 |
2292 |
2293 |
2294 Log_event B_l:Query_event
2295 ^ /\
2296 | / \
2297 | <<vir>>/ \ <<vir>>
2298 | / \
2299 | / \
2300 | / \
2301 Query_log_event B_l:E_L_Q_E
2302 \ /
2303 \ /
2304 \ /
2305 \ /
2306 \ /
2307 Execute_load_query_log_event
2308
2309 B_l: Namespace Binary_log
2310 E_L_Q_E: class Execute_load_query
2311 @endinternal
2312
2313 @section Execute_load_query_log_event_binary_format Binary Format
2314*/
2316 : public Query_log_event,
2318 public:
2319#ifdef MYSQL_SERVER
2321 THD *thd, const char *query_arg, ulong query_length,
2322 uint fn_pos_start_arg, uint fn_pos_end_arg,
2324 bool using_trans, bool immediate, bool suppress_use, int errcode);
2325 int pack_info(Protocol *protocol) override;
2326#else
2327 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2328 /* Prints the query as LOAD DATA LOCAL and with rewritten filename */
2329 void print(FILE *file, PRINT_EVENT_INFO *print_event_info,
2330 const char *local_fname) const;
2331#endif
2333 const char *buf,
2334 const mysql::binlog::event::Format_description_event *description_event);
2335 ~Execute_load_query_log_event() override = default;
2336
2337 ulong get_post_header_size_for_derived() override;
2338#ifdef MYSQL_SERVER
2339 bool write_post_header_for_derived(Basic_ostream *ostream) override;
2340#endif
2341
2342 bool is_sbr_logging_format() const override { return true; }
2343
2344 void claim_memory_ownership(bool claim) override;
2345
2346 private:
2347#if defined(MYSQL_SERVER)
2348 int do_apply_event(Relay_log_info const *rli) override;
2349#endif
2350};
2352#if defined MYSQL_SERVER
2354 public:
2355 Load_query_generator(THD *thd_arg, const sql_exchange *ex, const char *db_arg,
2356 const char *table_name_arg, bool is_concurrent_arg,
2357 bool replace, bool ignore);
2358
2359 const String *generate(size_t *fn_start, size_t *fn_end);
2361 private:
2362 const size_t BUF_SIZE = 2048;
2363 String str;
2364 char *buf[2048];
2368 const char *db;
2369 const char *table_name;
2370 const char *fname;
2373 bool has_replace;
2374 bool has_ignore;
2375};
2376#endif
2377#ifndef MYSQL_SERVER
2378/**
2379 @class Unknown_log_event
2380
2381*/
2382class Unknown_log_event : public mysql::binlog::event::Unknown_event,
2383 public Log_event {
2384 public:
2385 // disable copy-move semantics
2386 Unknown_log_event(Unknown_log_event &&) noexcept = delete;
2387 Unknown_log_event &operator=(Unknown_log_event &&) noexcept = delete;
2388 Unknown_log_event(const Unknown_log_event &) = delete;
2389 Unknown_log_event &operator=(const Unknown_log_event &) = delete;
2390
2391 /**
2392 Even if this is an unknown event, we still pass description_event to
2393 Log_event's ctor, this way we can extract maximum information from the
2394 event's header (the unique ID for example).
2395 */
2396 Unknown_log_event(
2397 const char *buf,
2398 const mysql::binlog::event::Format_description_event *description_event)
2399 : mysql::binlog::event::Unknown_event(buf, description_event),
2400 Log_event(header(), footer()) {
2401 DBUG_TRACE;
2402 if (!is_valid()) return;
2403 common_header->set_is_valid(true);
2404 return;
2405 }
2406
2407 ~Unknown_log_event() override = default;
2408 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2411 }
2412};
2413#endif
2414char *str_to_hex(char *to, const char *from, size_t len);
2415
2416/**
2417 @class Table_map_log_event
2418
2419 Table_map_log_event which maps a table definition to a number.
2420
2421 @internal
2422 The inheritance structure in the current design for the classes is
2423 as follows:
2424
2425 Binary_log_event
2426 ^
2427 |
2428 |
2429 Table_map_event Log_event
2430 \ /
2431 \ /
2432 \ /
2433 Table_map_log_event
2434 @endinternal
2435*/
2437 public Log_event {
2438 public:
2439 // disable copy-move semantics
2441 Table_map_log_event &operator=(Table_map_log_event &&) noexcept = delete;
2442 Table_map_log_event(const Table_map_log_event &) = delete;
2443 Table_map_log_event &operator=(const Table_map_log_event &) = delete;
2445 /** Constants */
2447
2448 /**
2449 Enumeration of the errors that can be returned.
2452 ERR_OPEN_FAILURE = -1, /**< Failure to open table */
2453 ERR_OK = 0, /**< No error */
2454 ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
2455 ERR_OUT_OF_MEM = 2, /**< Out of memory */
2456 ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
2457 ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
2459
2460 enum enum_flag {
2461 /**
2462 Nothing here right now, but the flags support is there in
2463 preparation for changes that are coming. Need to add a
2464 constant to make it compile under HP-UX: aCC does not like
2465 empty enumerations.
2468 };
2469
2470 /** Special constants representing sets of flags */
2471 enum {
2473 TM_BIT_LEN_EXACT_F = (1U << 0),
2474 TM_REFERRED_FK_DB_F = (1U << 1),
2475 /**
2476 Table has generated invisible primary key. MySQL generates primary key
2477 while creating a table if sql_generate_invisible_primary_key is "ON" and
2478 table is PK-less.
2480 TM_GENERATED_INVISIBLE_PK_F = (1U << 2)
2482
2483 flag_set get_flags(flag_set flag) const { return m_flags & flag; }
2484
2485#ifdef MYSQL_SERVER
2486 Table_map_log_event(THD *thd_arg, TABLE *tbl,
2488 bool using_trans);
2489#endif
2491 const char *buf,
2492 const mysql::binlog::event::Format_description_event *description_event);
2493
2494 void claim_memory_ownership(bool claim) override;
2495
2496 ~Table_map_log_event() override;
2497
2498#ifndef MYSQL_SERVER
2499 table_def *create_table_def() {
2500 assert(m_colcnt > 0);
2501 uint vector_column_count =
2503 std::vector<unsigned int> vector_dimensionality;
2504 if (vector_column_count > 0) {
2507 vector_dimensionality = fields.m_vector_dimensionality;
2508 }
2511 vector_dimensionality);
2512 }
2513 static bool rewrite_db_in_buffer(
2514 char **buf, ulong *event_len,
2516#endif
2520 const char *get_table_name() const { return m_tblnam.c_str(); }
2521 const char *get_db_name() const { return m_dbnam.c_str(); }
2522
2523 size_t get_data_size() override { return m_data_size; }
2524#ifdef MYSQL_SERVER
2525 virtual int save_field_metadata();
2526 bool write_data_header(Basic_ostream *ostream) override;
2527 bool write_data_body(Basic_ostream *ostream) override;
2528 const char *get_db() override { return m_dbnam.c_str(); }
2529 uint8 mts_number_dbs() override {
2531 }
2532 /**
2533 @param[out] arg pointer to a struct containing char* array
2534 pointers be filled in and the number of filled instances.
2535 @param rpl_filter pointer to a replication filter.
2536
2537 @return number of databases in the array: either one or
2538 OVER_MAX_DBS_IN_EVENT_MTS, when the Table map event reports
2539 foreign keys constraint.
2540 */
2542 const char *db_name = get_db();
2543
2545 size_t dummy_len;
2546 const char *db_filtered = rpl_filter->get_rewrite_db(db_name, &dummy_len);
2547 // db_name != db_filtered means that db_name is rewritten.
2548 if (strcmp(db_name, db_filtered)) db_name = db_filtered;
2549 }
2550
2551 if (!get_flags(TM_REFERRED_FK_DB_F)) arg->name[0] = db_name;
2552
2553 return arg->num = mts_number_dbs();
2554 }
2555
2556#endif
2557
2558#if defined(MYSQL_SERVER)
2559 int pack_info(Protocol *protocol) override;
2560#endif
2561
2562#ifndef MYSQL_SERVER
2563 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2564
2565 /**
2566 Print column metadata. Its format looks like:
2567 # Columns(colume_name type, colume_name type, ...)
2568 if colume_name field is not logged into table_map_log_event, then
2569 only type is printed.
2570
2571 @param[out] file the place where colume metadata is printed
2572 @param[in] fields The metadata extracted from optional metadata fields
2573 */
2574 void print_columns(IO_CACHE *file,
2575 const Optional_metadata_fields &fields) const;
2576 /**
2577 Print primary information. Its format looks like:
2578 # Primary Key(colume_name, column_name(prifix), ...)
2579 if colume_name field is not logged into table_map_log_event, then
2580 colume index is printed.
2581
2582 @param[out] file the place where primary key is printed
2583 @param[in] fields The metadata extracted from optional metadata fields
2584 */
2585 void print_primary_key(IO_CACHE *file,
2586 const Optional_metadata_fields &fields) const;
2587#endif
2588
2590
2591 bool is_rbr_logging_format() const override { return true; }
2592
2593 private:
2594#if defined(MYSQL_SERVER)
2595 int do_apply_event(Relay_log_info const *rli) override;
2596 int do_update_pos(Relay_log_info *rli) override;
2598#endif
2600#ifdef MYSQL_SERVER
2601 TABLE *m_table;
2603 // Metadata fields buffer
2605
2606 /**
2607 Wrapper around `TABLE *m_table` that abstracts the table field set iteration
2608 logic, since it is not mandatory that all table fields are to be
2609 replicated. For details, @see ReplicatedColumnsView class documentation.
2610
2611 A smart pointer is used here as the developer might want to instantiate the
2612 view using different classes in runtime depending on the given context.
2613 As of now the column view is only used on outbound scenarios
2614 */
2616
2617 /**
2618 Capture the optional metadata fields which should be logged into
2619 table_map_log_event and serialize them into m_metadata_buf.
2620 */
2621 void init_metadata_fields();
2622 bool init_signedness_field();
2623 /**
2624 Capture and serialize character sets. Character sets for
2625 character columns (TEXT etc) and character sets for ENUM and SET
2626 columns are stored in different metadata fields. The reason is
2627 that TEXT character sets are included even when
2628 binlog_row_metadata=MINIMAL, whereas ENUM and SET character sets
2629 are included only when binlog_row_metadata=FULL.
2630
2631 @param include_type Predicate to determine if a given Field object
2632 is to be included in the metadata field.
2633
2634 @param default_charset_type Type code when storing in "default
2635 charset" format. (See comment above Table_maps_log_event in
2636 mysql/binlog/event/rows_event.h)
2637
2638 @param column_charset_type Type code when storing in "column
2639 charset" format. (See comment above Table_maps_log_event in
2640 mysql/binlog/event/rows_event.h)
2641 */
2642 bool init_charset_field(std::function<bool(const Field *)> include_type,
2643 Optional_metadata_field_type default_charset_type,
2644 Optional_metadata_field_type column_charset_type);
2652#endif
2653
2654#ifndef MYSQL_SERVER
2655 class Charset_iterator;
2656 class Default_charset_iterator;
2657 class Column_charset_iterator;
2658#endif
2659};
2660
2661#ifdef HAVE_PSI_STAGE_INTERFACE
2662/*
2663 Helper class for PSI context while applying a Rows_log_event.
2664 */
2666 private:
2669
2670 /**
2671 A cached pointer to this stage PSI_stage_progress.
2672 */
2674
2675 /**
2676 Counter that is unconditionally incremented on each row that is processed.
2677 This is helpful in case estimation is needed after started processing
2678 a Rows_log_event.
2679 */
2682 public:
2684
2685 void set_progress(PSI_stage_progress *progress) { m_progress = progress; }
2686
2687 /**
2688 If instrumentation is enabled this member function SHALL return true.
2689 @return true if instrumentation is enabled for the given stage, false
2690 otherwise.
2691 */
2692 bool is_enabled() { return m_progress != nullptr; }
2693
2694 /**
2695 This member function shall update the progress and reestimate the remaining
2696 work needed. This MUST be called after setting n_rows_applied correctly
2697 by calling inc_n_rows_applied beforehand.
2698
2699 Cursor, begin and end are used in case estimation is needed.
2700
2701 @param cursor Pointer to where we are in the buffer of rows to be processed.
2702 @param begin Pointer to the beginning of the rows buffer.
2703 @param end Pointer to the end of the rows buffer.
2704 */
2705 void update_work_estimated_and_completed(const uchar *cursor,
2706 const uchar *begin,
2707 const uchar *end) {
2708 if (!is_enabled()) return;
2709
2711
2712 /* Estimate if need be. */
2713 if (estimated == 0) {
2714 assert(cursor > begin);
2715 const ulonglong avg_row_change_size = (cursor - begin) / m_n_rows_applied;
2716 estimated = (end - begin) / avg_row_change_size;
2718 }
2719
2720 /* reset estimated if done more work than estimated */
2721 if (m_n_rows_applied > estimated)
2724 }
2725
2726 /**
2727 Resets this object.
2728 */
2729 void end_work() {
2730 m_progress = nullptr;
2731 m_n_rows_applied = 0;
2732 }
2733
2734 /**
2735 Updates the counter of processed rows.
2736 @param delta the amount of increment to be done.
2737 */
2738 void inc_n_rows_applied(ulonglong delta) { m_n_rows_applied += delta; }
2739
2740 /**
2741 Gets the value of the counter of rows that have been processed.
2742 @return the value of the counter of rows processed so far.
2743 */
2745};
2746#endif
2747
2748/**
2749 @class Rows_log_event
2750
2751 Common base class for all row-containing log events.
2752
2753 RESPONSIBILITIES
2754
2755 Encode the common parts of all events containing rows, which are:
2756 - Write data header and data body to an IO_CACHE.
2757
2758 Virtual inheritance is required here to handle the diamond problem in
2759 the class Write_rows_log_event, Update_rows_log_event and
2760 Delete_rows_log_event.
2761 The diamond structure is explained in @c Write_rows_log_event,
2762 @c Update_rows_log_event,
2763 @c Delete_rows_log_event
2764
2765 @internal
2766 The inheritance structure in the current design for the classes is
2767 as follows:
2768
2769 Binary_log_event
2770 ^
2771 |
2772 |
2773 Rows_event Log_event
2774 \ /
2775 <<vir>>\ /
2776 \ /
2777 Rows_log_event
2778 @endinternal
2780*/
2782 public Log_event {
2783#ifdef HAVE_PSI_STAGE_INTERFACE
2784 protected:
2786#endif
2787
2788 public:
2789 // disable copy-move semantics
2790 Rows_log_event(Rows_log_event &&) noexcept = delete;
2791 Rows_log_event &operator=(Rows_log_event &&) noexcept = delete;
2792 Rows_log_event(const Rows_log_event &) = delete;
2793 Rows_log_event &operator=(const Rows_log_event &) = delete;
2794
2803 };
2804
2805 /**
2806 Enumeration of the errors that can be returned.
2809 ERR_OPEN_FAILURE = -1, /**< Failure to open table */
2810 ERR_OK = 0, /**< No error */
2811 ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
2812 ERR_OUT_OF_MEM = 2, /**< Out of memory */
2813 ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
2814 ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
2815 };
2817 /* Special constants representing sets of flags */
2818 enum { RLE_NO_FLAGS = 0U };
2819
2822 void set_flags(flag_set flags_arg) { m_flags |= flags_arg; }
2823 void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
2824 flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
2827 get_general_type_code() = 0; /* General rows op type, no version */
2828
2829#if defined(MYSQL_SERVER)
2830 int pack_info(Protocol *protocol) override;
2831#endif
2832
2833#ifndef MYSQL_SERVER
2834 void print_verbose(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info);
2835 size_t print_verbose_one_row(IO_CACHE *file, table_def *td,
2836 PRINT_EVENT_INFO *print_event_info,
2837 MY_BITMAP *cols_bitmap, const uchar *ptr,
2838 const uchar *prefix,
2839 enum_row_image_type row_image_type);
2840#endif
2842#ifdef MYSQL_SERVER
2843 int add_row_data(uchar *data, size_t length) {
2844 return do_add_row_data(data, length);
2845 }
2846#endif
2847
2848 /* Member functions to implement superclass interface */
2849 size_t get_data_size() override;
2851 MY_BITMAP const *get_cols() const { return &m_cols; }
2852 MY_BITMAP const *get_cols_ai() const { return &m_cols_ai; }
2854 return m_table_id;
2855 }
2856
2857#if defined(MYSQL_SERVER)
2858 /**
2859 Compares the table's read/write_set with the columns included in
2860 this event's before-image and/or after-image. Each subclass
2861 (Write/Update/Delete) implements this function by comparing on the
2862 image(s) pertinent to the subclass.
2863
2864 @param[in] table The table to compare this events bitmaps
2865 against.
2866
2867 @retval true if sets match
2868 @retval false otherwise (following bitmap_cmp return logic).
2869 */
2870 virtual bool read_write_bitmaps_cmp(const TABLE *table) const = 0;
2871#endif
2872
2873#ifdef MYSQL_SERVER
2874 bool write_data_header(Basic_ostream *ostream) override;
2875 bool write_data_body(Basic_ostream *ostream) override;
2876 const char *get_db() override { return m_table->s->db.str; }
2877#endif
2878
2879 uint m_row_count; /* The number of rows added to the event */
2880
2881 protected:
2882 /*
2883 The constructors are protected since you're supposed to inherit
2884 this class, not create instances of this class.
2885 */
2886#ifdef MYSQL_SERVER
2888 MY_BITMAP const *cols, bool is_transactional,
2890 const unsigned char *extra_row_ndb_info);
2891#endif
2893 const char *row_data,
2894 const mysql::binlog::event::Format_description_event *description_event);
2895
2896#ifndef MYSQL_SERVER
2897 void print_helper(FILE *, PRINT_EVENT_INFO *) const;
2898#endif
2899
2900#ifdef MYSQL_SERVER
2901 virtual int do_add_row_data(uchar *data, size_t length);
2902#endif
2904#ifdef MYSQL_SERVER
2905 TABLE *m_table; /* The table the rows belong to */
2906#endif
2907 MY_BITMAP m_cols; /* Bitmap denoting columns available */
2908 /**
2909 Bitmap denoting columns available in the image as they appear in the table
2910 setup. On some setups, the number and order of columns may differ from
2911 master to slave so, a bitmap for local available columns is computed using
2912 `ReplicatedColumnsView` utility class.
2913 */
2915#ifdef MYSQL_SERVER
2916 /**
2917 Hash table that will hold the entries for while using HASH_SCAN
2918 algorithm to search and update/delete rows.
2919 */
2921
2922 /**
2923 The algorithm to use while searching for rows using the before
2924 image.
2925 */
2927#endif
2928 /**
2929 Bitmap for columns available in the after image, if present. These
2930 fields are only available for Update_rows events. Observe that the
2931 width of both the before image COLS vector and the after image
2932 COLS vector is the same: the number of columns of the table on the
2933 master.
2934 */
2936 /**
2937 Bitmap denoting columns available in the after-image as they appear in the
2938 table setup. On some setups, the number and order of columns may differ from
2939 master to slave so, a bitmap for local available columns is computed using
2940 `ReplicatedColumnsView` utility class.
2941 */
2944 /* Bit buffers in the same memory as the class */
2945 uint32 m_bitbuf[128 / (sizeof(uint32) * 8)];
2946 uint32 m_bitbuf_ai[128 / (sizeof(uint32) * 8)];
2947
2948 /*
2949 is_valid depends on the value of m_rows_buf, so while changing the value
2950 of m_rows_buf check if is_valid also needs to be modified
2952 uchar *m_rows_buf; /* The rows in packed format */
2953 uchar *m_rows_cur; /* One-after the end of the data */
2954 uchar *m_rows_end; /* One-after the end of the allocated space */
2955
2956 /* helper functions */
2958#if defined(MYSQL_SERVER)
2959 const uchar *m_curr_row; /* Start of the row being processed */
2960 const uchar *m_curr_row_end; /* One-after the end of the current row */
2961 uchar *m_key; /* Buffer to keep key value during searches */
2963 KEY *m_key_info; /* Points to description of index #m_key_index */
2964 class Key_compare {
2965 public:
2966 /**
2967 @param ki Where to find KEY description
2968 @note m_distinct_keys is instantiated when Rows_log_event is constructed;
2969 it stores a Key_compare object internally. However at that moment, the
2970 index (KEY*) to use for comparisons, is not yet known. So, at
2971 instantiation, we indicate the Key_compare the place where it can
2972 find the KEY* when needed (this place is Rows_log_event::m_key_info),
2973 Key_compare remembers the place in member m_key_info.
2974 Before we need to do comparisons - i.e. before we need to insert
2975 elements, we update Rows_log_event::m_key_info once for all.
2977 Key_compare(KEY **ki = nullptr) : m_key_info(ki) {}
2978 bool operator()(uchar *k1, uchar *k2) const {
2979 return key_cmp2((*m_key_info)->key_part, k1, (*m_key_info)->key_length,
2980 k2, (*m_key_info)->key_length) < 0;
2981 }
2983 private:
2986 std::set<uchar *, Key_compare> m_distinct_keys;
2987 std::set<uchar *, Key_compare>::iterator m_itr;
2988 /**
2989 A spare buffer which will be used when saving the distinct keys
2990 for doing an index scan with HASH_SCAN search algorithm.
2991 */
2993
2994 /**
2995 Unpack the current row image from the event into m_table->record[0].
2996
2997 @param rli The applier context.
2998
2999 @param cols The bitmap of columns included in the update.
3000
3001 @param is_after_image Should be true if this is an after-image,
3002 false if it is a before-image.
3003
3004 @param only_seek unpack_row()
3005
3006 @retval 0 Success
3007
3008 @retval ER_* On error, it is guaranteed that the error has been
3009 reported through my_error, and the corresponding ER_* code is
3010 returned. Currently the error codes are: EE_OUTOFMEMORY,
3011 ER_REPLICA_CORRUPT_EVENT, or various JSON errors when applying JSON
3012 diffs (ER_COULD_NOT_APPLY_JSON_DIFF, ER_INVALID_JSON_BINARY_DATA,
3013 and maybe others).
3014 */
3015 int unpack_current_row(const Relay_log_info *const rli, MY_BITMAP const *cols,
3016 bool is_after_image, bool only_seek = false);
3017 /**
3018 Updates the generated columns of the `TABLE` object referenced by
3019 `m_table`, that have an active bit in the parameter bitset
3020 `fields_to_update`.
3021
3022 @param fields_to_update A bitset where the bit at the index of
3023 generated columns to update must be set to `1`
3024
3025 @return 0 if the operation terminated successfully, 1 otherwise.
3026 */
3027 int update_generated_columns(MY_BITMAP const &fields_to_update);
3028 /*
3029 This member function is called when deciding the algorithm to be used to
3030 find the rows to be updated on the slave during row based replication.
3031 This this functions sets the m_rows_lookup_algorithm and also the
3032 m_key_index with the key index to be used if the algorithm is dependent on
3033 an index.
3034 */
3036
3037 /*
3038 Encapsulates the operations to be done before applying
3039 row event for update and delete.
3040 */
3042
3043 /*
3044 Encapsulates the operations to be done after applying
3045 row event for update and delete.
3046 */
3048
3049 /**
3050 Helper function to check whether there is an auto increment
3051 column on the table where the event is to be applied.
3052 GIPKs when not present in the source table are also considered a
3053 auto inc column in a extra column.
3054
3055 @param rli the relay log object associated to the replicated table
3056
3057 @return true if there is an autoincrement field on the extra
3058 columns, false otherwise.
3059 */
3060 bool is_auto_inc_in_extra_columns(const Relay_log_info *const rli);
3061
3062 /**
3063 Helper function to check whether the storage engine error
3064 allows for the transaction to be retried or not.
3065
3066 @param error Storage engine error
3067 @retval true if the error is retryable.
3068 @retval false if the error is non-retryable.
3069 */
3071#endif
3072
3073 bool is_rbr_logging_format() const override { return true; }
3074
3075 private:
3076#if defined(MYSQL_SERVER)
3077
3078 /**
3079 Wrapper around `TABLE *m_table` that abstracts the table field set iteration
3080 logic, since it is not mandatory that all table fields are to be
3081 replicated. For details, @see ReplicatedColumnsView class documentation.
3082
3083 A smart pointer is used here as the developer might want to instantiate the
3084 view using different classes in runtime depending on the given context.
3085 */
3087
3088 int do_apply_event(Relay_log_info const *rli) override;
3089 int do_update_pos(Relay_log_info *rli) override;
3091
3092 /*
3093 Primitive to prepare for a sequence of row executions.
3094
3095 DESCRIPTION
3096
3097 Before doing a sequence of do_prepare_row() and do_exec_row()
3098 calls, this member function should be called to prepare for the
3099 entire sequence. Typically, this member function will allocate
3100 space for any buffers that are needed for the two member
3101 functions mentioned above.
3102
3103 RETURN VALUE
3104
3105 The member function will return 0 if all went OK, or a non-zero
3106 error code otherwise.
3107 */
3108 virtual int do_before_row_operations(const Relay_log_info *const log) = 0;
3109
3110 /*
3111 Primitive to clean up after a sequence of row executions.
3112
3113 DESCRIPTION
3114
3115 After doing a sequence of do_prepare_row() and do_exec_row(),
3116 this member function should be called to clean up and release
3117 any allocated buffers.
3118
3119 The error argument, if non-zero, indicates an error which happened during
3120 row processing before this function was called. In this case, even if
3121 function is successful, it should return the error code given in the
3122 argument.
3123 */
3124 virtual int do_after_row_operations(const Relay_log_info *const log,
3125 int error) = 0;
3126
3127 /*
3128 Primitive to do the actual execution necessary for a row.
3129
3130 DESCRIPTION
3131 The member function will do the actual execution needed to handle a row.
3132 The row is located at m_curr_row. When the function returns,
3133 m_curr_row_end should point at the next row (one byte after the end
3134 of the current row).
3135
3136 RETURN VALUE
3137 0 if execution succeeded, 1 if execution failed.
3139 */
3140 virtual int do_exec_row(const Relay_log_info *const rli) = 0;
3141
3142 /**
3143 Private member function called while handling idempotent errors.
3144
3145 @param rli Pointer to relay log info structure.
3146 @param [in,out] err the error to handle. If it is listed as
3147 idempotent/ignored related error, then it is cleared.
3148 @returns true if the slave should stop executing rows.
3149 */
3151
3152 /**
3153 Private member function called after updating/deleting a row. It
3154 performs some assertions and more importantly, it updates
3155 m_curr_row so that the next row is processed during the row
3156 execution main loop (@c Rows_log_event::do_apply_event()).
3157
3158 @param rli Pointer to relay log info structure.
3159 @param err the current error code.
3160 */
3161 void do_post_row_operations(Relay_log_info const *rli, int err);
3162
3163 /**
3164 Commodity wrapper around do_exec_row(), that deals with resetting
3165 the thd reference in the table.
3166 */
3167 int do_apply_row(Relay_log_info const *rli);
3168
3169 /**
3170 Implementation of the index scan and update algorithm. It uses
3171 PK, UK or regular Key to search for the record to update. When
3172 found it updates it.
3173 */
3175
3176 /**
3177 Implementation of the hash_scan and update algorithm. It collects
3178 rows positions in a hashtable until the last row is
3179 unpacked. Then it scans the table to update and when a record in
3180 the table matches the one in the hashtable, the update/delete is
3181 performed.
3182 */
3184
3185 /**
3186 Implementation of the legacy table_scan and update algorithm. For
3187 each unpacked row it scans the storage engine table for a
3188 match. When a match is found, the update/delete operations are
3189 performed.
3190 */
3192
3193 /**
3194 Seek past the after-image of an update event, in case a row was processed
3195 without reading the after-image.
3196
3197 An update event may process a row without reading the after-image,
3198 e.g. in case of ignored or idempotent errors. To ensure that the
3199 read position for the next row is correct, we need to seek past
3200 the after-image.
3201
3202 @param rli The applier context
3203
3204 @param curr_bi_start The read position of the beginning of the
3205 before-image. (The function compares this with m_curr_row to know
3206 if the after-image has been read or not.)
3207
3208 @retval 0 Success
3209 @retval ER_* Error code returned by unpack_current_row
3210 */
3212 [[maybe_unused]],
3213 const uchar *curr_bi_start
3214 [[maybe_unused]]) {
3215 return 0;
3216 }
3217
3218 /**
3219 Initializes scanning of rows. Opens an index and initializes an iterator
3220 over a list of distinct keys (m_distinct_keys) if it is a HASH_SCAN
3221 over an index or the table if its a HASH_SCAN over the table.
3222 */
3223 int open_record_scan();
3224
3225 /**
3226 Does the cleanup
3227 - closes the index if opened by open_record_scan
3228 - closes the table if opened for scanning.
3229 */
3230 int close_record_scan();
3231
3232 /**
3233 Fetches next row. If it is a HASH_SCAN over an index, it populates
3234 table->record[0] with the next row corresponding to the index. If
3235 the indexes are in non-contigous ranges it fetches record corresponding
3236 to the key value in the next range.
3237
3238 @param first_read signifying if this is the first time we are reading a row
3239 over an index.
3240 @return error code when there are no more records to be fetched or some
3241 other error occurred,
3242 - 0 otherwise.
3243 */
3244 int next_record_scan(bool first_read);
3245
3246 /**
3247 Populates the m_distinct_keys with unique keys to be modified
3248 during HASH_SCAN over keys.
3249 @returns 0 success, or the error code.
3250 */
3252
3253 /**
3254 Populates the m_hash when using HASH_SCAN. Thence, it:
3255 - unpacks the before image (BI)
3256 - saves the positions
3257 - saves the positions into the hash map, using the
3258 BI checksum as key
3259 - unpacks the after image (AI) if needed, so that
3260 m_curr_row_end gets updated correctly.
3261
3262 @param rli The reference to the relay log info object.
3263 @returns 0 on success. Otherwise, the error code.
3264 */
3265 int do_hash_row(Relay_log_info const *rli);
3266
3267 /**
3268 This member function scans the table and applies the changes
3269 that had been previously hashed. As such, m_hash MUST be filled
3270 by do_hash_row before calling this member function.
3271
3272 @param rli The reference to the relay log info object.
3273 @returns 0 on success. Otherwise, the error code.
3274 */
3275 int do_scan_and_update(Relay_log_info const *rli);
3276#endif /* defined(MYSQL_SERVER) */
3277
3278 friend class Old_rows_log_event;
3279
3280 /**
3281 This bitmap is used as a backup for the write set while we calculate
3282 the values for any hidden generated columns (functional indexes). In order
3283 to calculate the values, the columns must be marked in the write set. After
3284 the values are calculated, we set the write set back to its original value.
3285 */
3287};
3288
3289/**
3290 @class Write_rows_log_event
3291
3292 Log row insertions and updates. The event contain several
3293 insert/update rows for a table. Note that each event contains only
3294 rows for one table.
3295
3296 @internal
3297 The inheritance structure is as follows
3298
3299 Binary_log_event
3300 ^
3301 |
3302 |
3303 |
3304 Log_event B_l:Rows_event
3305 ^ /\
3306 | / \
3307 | <<vir>>/ \ <<vir>>
3308 | / \
3309 | / \
3310 | / \
3311 Rows_log_event B_l:W_R_E
3312 \ /
3313 \ /
3314 \ /
3315 \ /
3316 \ /
3317 \/
3318 Write_rows_log_event
3319
3320 B_l: Namespace Binary_log
3321 W_R_E: class Write_rows_event
3322 @endinternal
3324*/
3327 public:
3328 enum {
3329 /* Support interface to THD::binlog_prepare_pending_rows_event */
3331 };
3332
3333#if defined(MYSQL_SERVER)
3335 const mysql::binlog::event::Table_id &table_id,
3336 bool is_transactional,
3337 const unsigned char *extra_row_ndb_info);
3338#endif
3340 const char *buf,
3341 const mysql::binlog::event::Format_description_event *description_event);
3342#if defined(MYSQL_SERVER)
3344 bool is_transactional,
3345 const uchar *before_record
3346 [[maybe_unused]],
3347 const uchar *after_record);
3348 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3349 return bitmap_cmp(get_cols(), table->write_set);
3350 }
3351#endif
3352
3353 void claim_memory_ownership(bool claim) override;
3354
3355 protected:
3356 int write_row(const Relay_log_info *const, const bool);
3358 private:
3361 }
3362
3363#ifndef MYSQL_SERVER
3364 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3365#endif
3366
3367#if defined(MYSQL_SERVER)
3368 int do_before_row_operations(const Relay_log_info *const) override;
3369 int do_after_row_operations(const Relay_log_info *const, int) override;
3370 int do_exec_row(const Relay_log_info *const) override;
3371#endif
3372};
3373
3374/**
3375 @class Update_rows_log_event
3376
3377 Log row updates with a before image. The event contain several
3378 update rows for a table. Note that each event contains only rows for
3379 one table.
3380
3381 Also note that the row data consists of pairs of row data: one row
3382 for the old data and one row for the new data.
3383
3384 @internal
3385 The inheritance structure is as follows
3386
3387 Binary_log_event
3388 ^
3389 |
3390 |
3391 |
3392 Log_event B_l:Rows_event
3393 ^ /\
3394 | / \
3395 | <<vir>>/ \ <<vir>>
3396 | / \
3397 | / \
3398 | / \
3399 Rows_log_event B_l:U_R_E
3400 \ /
3401 \ /
3402 \ /
3403 \ /
3404 \ /
3405 \/
3406 Update_rows_log_event
3407
3408
3409 B_l: Namespace Binary_log
3410 U_R_E: class Update_rows_event
3411 @eninternal
3413*/
3416 public:
3417 enum {
3418 /* Support interface to THD::binlog_prepare_pending_rows_event */
3420 };
3422#ifdef MYSQL_SERVER
3424 const mysql::binlog::event::Table_id &table_id,
3425 MY_BITMAP const *cols_bi, MY_BITMAP const *cols_ai,
3426 bool is_transactional,
3427 const unsigned char *extra_row_ndb_info);
3428
3430 const mysql::binlog::event::Table_id &table_id,
3431 bool is_transactional,
3432 const unsigned char *extra_row_ndb_info);
3433
3434 void init(MY_BITMAP const *cols);
3435#endif
3436
3437 ~Update_rows_log_event() override;
3438
3440 const char *buf,
3441 const mysql::binlog::event::Format_description_event *description_event);
3442
3443#ifdef MYSQL_SERVER
3445 bool is_transactional,
3446 const uchar *before_record,
3447 const uchar *after_record);
3448 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3449 return (bitmap_cmp(get_cols(), table->read_set) &&
3450 bitmap_cmp(get_cols_ai(), table->write_set));
3451 }
3452#endif
3453
3454 void claim_memory_ownership(bool claim) override;
3456 protected:
3459 }
3460
3461#ifndef MYSQL_SERVER
3462 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3463#endif
3464
3465#if defined(MYSQL_SERVER)
3466 int do_before_row_operations(const Relay_log_info *const) override;
3467 int do_after_row_operations(const Relay_log_info *const, int) override;
3468 int do_exec_row(const Relay_log_info *const) override;
3469
3471 const uchar *curr_bi_start) override;
3472
3473 private:
3474 /**
3475 Auxiliary function used in the (THD*, ...) constructor to
3476 determine the type code based on configuration options.
3477
3478 @param thd_arg The THD object for the session.
3479
3480 @return One of PARTIAL_UPDATE_ROWS_EVENT, or UPDATE_ROWS_EVENT.
3481 */
3483 const THD *thd_arg);
3484#endif /* defined(MYSQL_SERVER) */
3485};
3486
3487/**
3488 @class Delete_rows_log_event
3489
3490 Log row deletions. The event contain several delete rows for a
3491 table. Note that each event contains only rows for one table.
3492
3493 RESPONSIBILITIES
3494
3495 - Act as a container for rows that has been deleted on the master
3496 and should be deleted on the slave.
3497
3498 COLLABORATION
3499
3500 Row_writer
3501 Create the event and add rows to the event.
3502 Row_reader
3503 Extract the rows from the event.
3504
3505 @internal
3506 The inheritance structure is as follows
3507
3508 Binary_log_event
3509 ^
3510 |
3511 |
3512 |
3513 Log_event B_l:Rows_event
3514 ^ /\
3515 | / \
3516 | <<vir>>/ \ <<vir>>
3517 | / \
3518 | / \
3519 | / \
3520 Rows_log_event B_l:D_R_E
3521 \ /
3522 \ /
3523 \ /
3524 \ /
3525 \ /
3526 \/
3527 Delete_rows_log_event
3528
3529 B_l: Namespace Binary_log
3530 D_R_E: class Delete_rows_event
3531 @endinternal
3533*/
3536 public:
3537 enum {
3538 /* Support interface to THD::binlog_prepare_pending_rows_event */
3540 };
3541
3542#ifdef MYSQL_SERVER
3544 bool is_transactional,
3545 const unsigned char *extra_row_ndb_info);
3546#endif
3548 const char *buf,
3549 const mysql::binlog::event::Format_description_event *description_event);
3550#ifdef MYSQL_SERVER
3552 bool is_transactional,
3553 const uchar *before_record,
3554 const uchar *after_record
3555 [[maybe_unused]]);
3556 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3557 return bitmap_cmp(get_cols(), table->read_set);
3558 }
3559#endif
3560
3561 void claim_memory_ownership(bool claim) override;
3563 protected:
3566 }
3567
3568#ifndef MYSQL_SERVER
3569 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3570#endif
3571
3572#if defined(MYSQL_SERVER)
3573 int do_before_row_operations(const Relay_log_info *const) override;
3574 int do_after_row_operations(const Relay_log_info *const, int) override;
3575 int do_exec_row(const Relay_log_info *const) override;
3576#endif
3577};
3578
3579/**
3580 @class Incident_log_event
3581
3582 Class representing an incident, an occurrence out of the ordinary,
3583 that happened on the master.
3584
3585 The event is used to inform the slave that something out of the
3586 ordinary happened on the master that might cause the database to be
3587 in an inconsistent state.
3588
3589 It's the derived class of Incident_event
3590
3591 @internal
3592 The inheritance structure is as follows
3593
3594 Binary_log_event
3595 ^
3596 |
3597 |
3598 B_l:Incident_event Log_event
3599 \ /
3600 \ /
3601 \ /
3602 \ /
3603 Incident_log_event
3604
3605 B_l: Namespace Binary_log
3606 @endinternal
3608*/
3610 public Log_event {
3611 public:
3612 // disable copy-move semantics
3614 Incident_log_event &operator=(Incident_log_event &&) noexcept = delete;
3615 Incident_log_event(const Incident_log_event &) = delete;
3616 Incident_log_event &operator=(const Incident_log_event &) = delete;
3618#ifdef MYSQL_SERVER
3619 Incident_log_event(THD *thd_arg, enum_incident incident_arg,
3620 std::string_view msg)
3621 : mysql::binlog::event::Incident_event(incident_arg),
3624 DBUG_TRACE;
3625 DBUG_PRINT("enter", ("incident: %d", incident_arg));
3626 common_header->set_is_valid(incident_arg > INCIDENT_NONE &&
3627 incident_arg < INCIDENT_COUNT);
3628 assert(message == nullptr && message_length == 0);
3630 msg.length() + 1, MYF(MY_WME)))) {
3631 // The allocation failed. Mark this binlog event as invalid.
3633 return;
3634 }
3635 strmake(message, msg.data(), msg.length());
3636 message_length = msg.length();
3637 return;
3638 }
3639#endif
3640
3641#ifdef MYSQL_SERVER
3642 int pack_info(Protocol *) override;
3643#endif
3644
3646 const char *buf,
3647 const mysql::binlog::event::Format_description_event *description_event);
3648
3649 ~Incident_log_event() override;
3650
3651 void claim_memory_ownership(bool claim) override;
3652
3653#ifndef MYSQL_SERVER
3654 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3655#endif
3656
3657#if defined(MYSQL_SERVER)
3658 int do_apply_event(Relay_log_info const *rli) override;
3659 bool write_data_header(Basic_ostream *ostream) override;
3660 bool write_data_body(Basic_ostream *ostream) override;
3661#endif
3662
3663 size_t get_data_size() override {
3667
3668 bool ends_group() const override { return true; }
3669
3670 private:
3671 const char *description() const;
3672};
3673
3674/**
3675 @class Ignorable_log_event
3676
3677 Base class for ignorable log events is Ignorable_event.
3678 Events deriving from this class can be safely ignored
3679 by slaves that cannot recognize them.
3680
3681 Its the derived class of Ignorable_event
3682
3683 @internal
3684 The inheritance structure is as follows
3685
3686 Binary_log_event
3687 ^
3688 |
3689 |
3690 B_l:Ignorable_event Log_event
3691 \ /
3692 <<virtual>>\ /
3693 \ /
3694 Ignorable_log_event
3695
3696 B_l: Namespace Binary_log
3697 @endinternal
3698*/
3701 public Log_event {
3702 public:
3703 // disable copy-move semantics
3705 Ignorable_log_event &operator=(Ignorable_log_event &&) noexcept = delete;
3706 Ignorable_log_event(const Ignorable_log_event &) = delete;
3707 Ignorable_log_event &operator=(const Ignorable_log_event &) = delete;
3709#ifdef MYSQL_SERVER
3710 Ignorable_log_event(THD *thd_arg)
3713 DBUG_TRACE;
3715 return;
3716 }
3717#endif
3718
3720 const char *buf,
3722 ~Ignorable_log_event() override;
3723
3724 void claim_memory_ownership(bool claim) override;
3725
3726#ifdef MYSQL_SERVER
3727 int pack_info(Protocol *) override;
3728#endif
3729
3730#ifndef MYSQL_SERVER
3731 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3732#endif
3733
3734 size_t get_data_size() override {
3736 }
3737};
3738
3739/**
3740 @class Rows_query_log_event
3741 It is used to record the original query for the rows
3742 events in RBR.
3743 It is the subclass of Ignorable_log_event and Rows_query_event
3744
3745 @internal
3746 The inheritance structure in the current design for the classes is
3747 as follows:
3748 Binary_log_event
3749 ^
3750 |
3751 |
3752 |
3753 Log_event B_l:Ignorable_event
3754 ^ /\
3755 | / \
3756 | <<vir>>/ \ <<vir>>
3757 | / \
3758 | / \
3759 | / \
3760 Ignorable_log_event B_l:Rows_query_event
3761 \ /
3762 \ /
3763 \ /
3764 \ /
3765 \ /
3766 \/
3767 Rows_query_log_event
3768
3769 B_l : namespace namespace mysql::binlog::event
3770 @endinternal
3771*/
3774 public:
3775#ifdef MYSQL_SERVER
3776 Rows_query_log_event(THD *thd_arg, const char *query, size_t query_len)
3777 : Ignorable_log_event(thd_arg) {
3778 DBUG_TRACE;
3780 m_rows_query_length = query_len;
3781 if (!(m_rows_query =
3784 return;
3787 "rows_query_alter", size_t i = 0; while (i < m_rows_query_length) {
3788 if (m_rows_query[i] == '\\') {
3789 m_rows_query[i] = '\0';
3790 i++;
3791 for (auto j = i; j < m_rows_query_length - 1; j++) {
3792 m_rows_query[j] = m_rows_query[j + 1];
3793 }
3795 } else
3796 i++;
3797 });
3798 DBUG_PRINT("enter", ("%s", m_rows_query));
3799 return;
3800 }
3801#endif
3802
3803#ifdef MYSQL_SERVER
3804 int pack_info(Protocol *) override;
3805 int do_apply_event(Relay_log_info const *rli) override;
3806 bool write_data_body(Basic_ostream *ostream) override;
3807#endif
3808
3810 const char *buf,
3812
3813 void claim_memory_ownership(bool claim) override;
3814
3815 ~Rows_query_log_event() override {
3817 m_rows_query = nullptr;
3818 }
3819#ifndef MYSQL_SERVER
3820 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3821#endif
3822 size_t get_data_size() override {
3825 }
3827
3828static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
3829 FILE *file,
3830 bool flush_stream) {
3831 return my_b_copy_to_file(cache, file) ||
3832 (flush_stream ? (fflush(file) || ferror(file)) : 0) ||
3833 reinit_io_cache(cache, WRITE_CACHE, 0, false, true);
3834}
3835
3836#ifdef MYSQL_SERVER
3837/*****************************************************************************
3838
3839 Heartbeat Log Event class
3840
3841 The class is not logged to a binary log, and is not applied on to the slave.
3842 The decoding of the event on the slave side is done by its superclass,
3843 mysql::binlog::event::Heartbeat_event.
3845 ****************************************************************************/
3847 public Log_event {
3848 public:
3850 const char *buf,
3851 const mysql::binlog::event::Format_description_event *description_event);
3853
3855 public Log_event {
3856 public:
3858 const char *buf,
3859 const mysql::binlog::event::Format_description_event *description_event);
3860};
3861/**
3862 The function is called by slave applier in case there are
3863 active table filtering rules to force gathering events associated
3864 with Query-log-event into an array to execute
3865 them once the fate of the Query is determined for execution.
3866*/
3868#endif
3869
3870int append_query_string(const THD *thd, const CHARSET_INFO *csinfo,
3871 String const *from, String *to);
3873
3876 public Log_event {
3877 public:
3878#ifdef MYSQL_SERVER
3879
3880 Transaction_payload_log_event(THD *thd_arg, const char *payload,
3881 uint64_t payload_size,
3882 uint16_t compression_type,
3883 uint64_t uncompressed_size)
3884 : Transaction_payload_event(payload, payload_size, compression_type,
3885 uncompressed_size),
3886 Log_event(thd_arg, 0 /* flags */, Log_event::EVENT_TRANSACTIONAL_CACHE,
3888
3889 Transaction_payload_log_event(THD *thd_arg, const char *payload,
3890 uint64_t payload_size)
3892 thd_arg, payload, payload_size,
3893 mysql::binlog::event::compression::type::NONE, payload_size) {}
3894
3896 : Transaction_payload_log_event(thd_arg, nullptr, (uint64_t)0) {}
3897#endif
3898
3900 const char *buf,
3903
3904 ~Transaction_payload_log_event() override = default;
3905
3906 void claim_memory_ownership(bool claim) override;
3907
3908#ifndef MYSQL_SERVER
3909 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3910#endif
3911
3912 size_t get_event_length() { return LOG_EVENT_HEADER_LEN + get_data_size(); }
3913 size_t get_data_size() override;
3914
3915#if defined(MYSQL_SERVER)
3916
3917 public:
3918 int do_apply_event(Relay_log_info const *rli) override;
3919 bool apply_payload_event(Relay_log_info const *rli, const uchar *event_buf);
3921 int pack_info(Protocol *protocol) override;
3922 bool ends_group() const override;
3923 bool write(Basic_ostream *ostream) override;
3924#endif
3925};
3926
3927/**
3928 @class Gtid_log_event
3929
3930 This is a subclass if Gtid_event and Log_event. It contains
3931 per-transaction fields, including the GTID and logical timestamps
3932 used by MTS.
3933
3934 @internal
3935 The inheritance structure is as follows
3936
3937 Binary_log_event
3938 ^
3939 |
3940 |
3941 B_l:Gtid_event Log_event
3942 \ /
3943 \ /
3944 \ /
3945 \ /
3946 Gtid_log_event
3947
3948 B_l: Namespace Binary_log
3949 @endinternal
3950*/
3952 public Log_event {
3953 public:
3954 // disable copy-move semantics
3955 Gtid_log_event(Gtid_log_event &&) noexcept = delete;
3956 Gtid_log_event &operator=(Gtid_log_event &&) noexcept = delete;
3957 Gtid_log_event(const Gtid_log_event &) = delete;
3958 Gtid_log_event &operator=(const Gtid_log_event &) = delete;
3959
3960#ifdef MYSQL_SERVER
3961 /**
3962 Create a new event using the GTID owned by the given thread.
3963 */
3964 Gtid_log_event(THD *thd_arg, bool using_trans, int64 last_committed_arg,
3965 int64 sequence_number_arg, bool may_have_sbr_stmts_arg,
3966 ulonglong original_commit_timestamp_arg,
3967 ulonglong immediate_commit_timestamp_arg,
3968 uint32_t original_server_version_arg,
3969 uint32_t immediate_server_version_arg);
3970
3971 /**
3972 Create a new event using the GTID from the given Gtid_specification
3973 without a THD object.
3974 */
3975 Gtid_log_event(uint32 server_id_arg, bool using_trans,
3976 int64 last_committed_arg, int64 sequence_number_arg,
3977 bool may_have_sbr_stmts_arg,
3978 ulonglong original_commit_timestamp_arg,
3979 ulonglong immediate_commit_timestamp_arg,
3980 const Gtid_specification spec_arg,
3981 uint32_t original_server_version_arg,
3982 uint32_t immediate_server_version_arg);
3983#endif
3984
3985#ifdef MYSQL_SERVER
3986 int pack_info(Protocol *) override;
3987#endif
3989 const char *buffer,
3991
3992 ~Gtid_log_event() override = default;
3993
3994 void claim_memory_ownership(bool claim) override;
3995
3997
3998 size_t get_data_size() override {
3999 if (is_tagged()) {
4000 auto size_calculated = Encoder_type::get_size(*this);
4001 DBUG_EXECUTE_IF("add_unknown_ignorable_fields_to_gtid_log_event",
4002 { size_calculated += 2; });
4003 return size_calculated;
4004 }
4005 DBUG_EXECUTE_IF("do_not_write_rpl_timestamps", return POST_HEADER_LENGTH;);
4009 }
4010
4011 /// @brief Clears tsid and spec
4012 void clear_gtid_and_spec();
4013
4014 /// @brief Updates parent tsid and gtid info structure
4016
4017 size_t get_event_length() { return LOG_EVENT_HEADER_LEN + get_data_size(); }
4018
4019 /// Used internally by both print() and pack_info().
4020 size_t to_string(char *buf) const;
4021
4022 private:
4023#ifdef MYSQL_SERVER
4024 /**
4025 Writes the post-header to the given output stream.
4026
4027 This is an auxiliary function typically used by the write() member
4028 function.
4029
4030 @param ostream The output stream to write to.
4031
4032 @retval true Error.
4033 @retval false Success.
4034 */
4035 bool write_data_header(Basic_ostream *ostream) override;
4036 bool write_data_body(Basic_ostream *ostream) override;
4037 /**
4038 Writes the post-header to the given memory buffer.
4039
4040 This is an auxiliary function used by write_to_memory.
4041
4042 @param[in,out] buffer Buffer to which the post-header will be written.
4043
4044 @return The number of bytes written, i.e., always
4045 Gtid_log_event::POST_HEADER_LENGTH.
4046 */
4048
4049 /**
4050 Writes the body to the given memory buffer.
4051
4052 This is an auxiliary function used by write_to_memory.
4053
4054 @param [in,out] buff Buffer to which the data will be written.
4055
4056 @return The number of bytes written, i.e.,
4057 If the transaction did not originated on this server
4058 Gtid_event::IMMEDIATE_COMMIT_TIMESTAMP_LENGTH.
4059 else
4060 FULL_COMMIT_TIMESTAMP_LENGTH.
4061 */
4063
4064 /// @copydoc write_body_to_memory
4065 /// @details Version for tagged Gtid log event
4067
4068#endif
4069
4070 public:
4071#ifndef MYSQL_SERVER
4072 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4073#endif
4074
4075#if defined(MYSQL_SERVER)
4076 int do_apply_event(Relay_log_info const *rli) override;
4077 int do_update_pos(Relay_log_info *rli) override;
4079#endif
4080
4081 /**
4082 Return the gtid type for this Gtid_log_event: this can be
4083 either ANONYMOUS_GTID, AUTOMATIC_GTID, or ASSIGNED_GTID.
4084 */
4085 enum_gtid_type get_type() const { return spec.type; }
4086
4087 /**
4088 Return the TSID for this GTID. The TSID is shared with the
4089 Log_event so it should not be modified.
4090 */
4091 const Tsid &get_tsid() const { return tsid; }
4092 /**
4093 Return the SIDNO relative to the global tsid_map for this GTID.
4094
4095 This requires a lookup and possibly even update of global_tsid_map,
4096 hence global_tsid_lock must be held. If global_tsid_lock is not
4097 held, the caller must pass need_lock=true. If there is an error
4098 (e.g. out of memory) while updating global_tsid_map, this function
4099 returns a negative number.
4100
4101 @param need_lock If true, the read lock on global_tsid_lock is
4102 acquired and released inside this function; if false, the read
4103 lock or write lock must be held prior to calling this function.
4104 @retval SIDNO if successful
4105 @retval negative if adding TSID to global_tsid_map causes an error.
4106 */
4107 rpl_sidno get_sidno(bool need_lock);
4108
4109 /**
4110 Return the SIDNO relative to the given Tsid_map for this GTID.
4111
4112 This assumes that the Tsid_map is local to the thread, and thus
4113 does not use locks.
4114
4115 @param tsid_map The tsid_map to use.
4116 @retval SIDNO if successful.
4117 @retval negative if adding TSID to tsid_map causes an error.
4118 */
4119 rpl_sidno get_sidno(Tsid_map *tsid_map) { return tsid_map->add_tsid(tsid); }
4120 /// Return the GNO for this GTID.
4121 rpl_gno get_gno() const override { return spec.gtid.gno; }
4122
4123 /// @returns The GTID event specification
4126 /// string holding the text "SET @@GLOBAL.GTID_NEXT = '"
4127 static const char *SET_STRING_PREFIX;
4128
4129 private:
4130 /// Length of SET_STRING_PREFIX
4131 static const size_t SET_STRING_PREFIX_LENGTH = 26;
4132 /// The maximal length of the entire "SET ..." query.
4133 static const size_t MAX_SET_STRING_LENGTH = SET_STRING_PREFIX_LENGTH +
4136
4137 private:
4138 /**
4139 Internal representation of the GTID. The SIDNO will be
4140 uninitialized (value -1) until the first call to get_sidno(bool).
4141 */
4143 /// TSID for this GTID.
4144 Tsid tsid;
4145
4146 public:
4147 /**
4148 Set the transaction length information based on binlog cache size.
4149
4150 Note that is_checksum_enabled and event_counter are optional parameters.
4151 When not specified, the function will assume that no checksum will be used
4152 and the informed cache_size is the final transaction size without
4153 considering the GTID event size.
4154
4155 The high level formula that will be used by the function is:
4156
4157 trx_length = cache_size +
4158 cache_checksum_active * cache_events * CRC32_payload +
4159 gtid_length +
4160 cache_checksum_active * CRC32_payload; // For the GTID.
4161
4162 @param cache_size The size of the binlog cache in bytes.
4163 @param is_checksum_enabled If checksum will be added to events on flush.
4164 @param event_counter The amount of events in the cache.
4165 */
4167 bool is_checksum_enabled = false,
4168 int event_counter = 0);
4169
4170 /// @copydoc set_trx_length_by_cache_size
4171 /// @detail tagged version of event
4173 bool is_checksum_enabled = false,
4174 int event_counter = 0);
4175};
4176
4177/**
4178 @class Previous_gtids_log_event
4179
4180 This is the subclass of Previous_gtids_event and Log_event
4181 It is used to record the gtid_executed in the last binary log file,
4182 for ex after flush logs, or at the starting of the binary log file
4183
4184 @internal
4185 The inheritance structure is as follows
4186
4187 Binary_log_event
4188 ^
4189 |
4190 |
4191B_l:Previous_gtids_event Log_event
4192 \ /
4193 \ /
4194 \ /
4195 \ /
4196 Previous_gtids_log_event
4197
4198 B_l: Namespace Binary_log
4199 @endinternal
4200*/
4203 public Log_event {
4204 public:
4205 // disable copy-move semantics
4208 delete;
4211 delete;
4212
4213#ifdef MYSQL_SERVER
4215#endif
4216
4217#ifdef MYSQL_SERVER
4218 int pack_info(Protocol *) override;
4219#endif
4220
4222 const char *buf,
4223 const mysql::binlog::event::Format_description_event *description_event);
4224 ~Previous_gtids_log_event() override = default;
4225
4226 size_t get_data_size() override { return buf_size; }
4227
4228 void claim_memory_ownership(bool claim) override;
4229
4230#ifndef MYSQL_SERVER
4231 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4232#endif
4233#ifdef MYSQL_SERVER
4234 bool write(Basic_ostream *ostream) override {
4235#ifndef NDEBUG
4236 if (DBUG_EVALUATE_IF("skip_writing_previous_gtids_log_event", 1, 0) &&
4237 /*
4238 The skip_writing_previous_gtids_log_event debug point was designed
4239 for skipping the writing of the previous_gtids_log_event on binlog
4240 files only.
4241 */
4242 !is_relay_log_event()) {
4243 DBUG_PRINT("info",
4244 ("skip writing Previous_gtids_log_event because of"
4245 "debug option 'skip_writing_previous_gtids_log_event'"));
4246 return false;
4247 }
4248
4249 if (DBUG_EVALUATE_IF("write_partial_previous_gtids_log_event", 1, 0) &&
4250 /*
4251 The write_partial_previous_gtids_log_event debug point was designed
4252 for writing a partial previous_gtids_log_event on binlog files only.
4253 */
4254 !is_relay_log_event()) {
4255 DBUG_PRINT("info",
4256 ("writing partial Previous_gtids_log_event because of"
4257 "debug option 'write_partial_previous_gtids_log_event'"));
4258 return (Log_event::write_header(ostream, get_data_size()) ||
4260 }
4261#endif
4262
4263 return (Log_event::write_header(ostream, get_data_size()) ||
4264 Log_event::write_data_header(ostream) || write_data_body(ostream) ||
4265 Log_event::write_footer(ostream));
4266 }
4267 bool write_data_body(Basic_ostream *ostream) override;
4268#endif
4270 /// Return the encoded buffer, or NULL on error.
4271 const uchar *get_buf() { return buf; }
4272 /**
4273 Return the formatted string, or NULL on error.
4274 The string is allocated using my_malloc and it is the
4275 responsibility of the caller to free it.
4276 */
4277 char *get_str(size_t *length,
4279 /// Add all GTIDs from this event to the given Gtid_set.
4280 int add_to_set(Gtid_set *gtid_set) const;
4281 /*
4282 Previous Gtid Log events should always be skipped
4283 there is nothing to apply there, whether it is
4284 relay log's (generated on Slave) or it is binary log's
4285 (generated on Master, copied to slave as relay log).
4286 Also, we should not increment slave_skip_counter
4287 for this event, hence return EVENT_SKIP_IGNORE.
4289#if defined(MYSQL_SERVER)
4291 {
4292 return EVENT_SKIP_IGNORE;
4294
4295 int do_apply_event(Relay_log_info const *) override { return 0; }
4296 int do_update_pos(Relay_log_info *rli) override;
4297#endif
4298};
4299
4300/**
4301 @class Transaction_context_log_event
4302
4303 This is the subclass of Transaction_context_event and Log_event
4304 This class encodes the transaction_context_log_event.
4305
4306 @internal
4307 The inheritance structure is as follows
4308
4309 Binary_log_event
4310 ^
4311 |
4312 |
4313B_l:Transaction_context_event Log_event
4314 \ /
4315 \ /
4316 \ /
4317 \ /
4318 Transaction_context_log_event
4319
4320 B_l: Namespace Binary_log
4321 @endinternal
4322*/
4325 public Log_event {
4326 private:
4327 /// The Tsid_map to use for creating the Gtid_set.
4329 /// A gtid_set which is used to store the transaction set used for
4330 /// conflict detection.
4332
4333#ifdef MYSQL_SERVER
4334 bool write_data_header(Basic_ostream *ostream) override;
4335
4336 bool write_data_body(Basic_ostream *ostream) override;
4337
4339
4340 bool write_data_set(Basic_ostream *ostream, std::list<const char *> *set);
4341#endif
4342
4344
4345 static int get_data_set_size(std::list<const char *> *set);
4346
4347 size_t to_string(char *buf, ulong len) const;
4348
4349 public:
4350#ifdef MYSQL_SERVER
4351
4352 Transaction_context_log_event(const char *server_uuid_arg, bool using_trans,
4353 my_thread_id thread_id_arg,
4354 bool is_gtid_specified);
4355
4356#endif
4357
4359 const char *buffer,
4361
4363
4364 void claim_memory_ownership(bool claim) override;
4365
4366 size_t get_data_size() override;
4367
4368 size_t get_event_length();
4369
4370#ifdef MYSQL_SERVER
4371 int pack_info(Protocol *protocol) override;
4372#endif
4373
4374#ifndef MYSQL_SERVER
4375 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4376#endif
4378#if defined(MYSQL_SERVER)
4379 int do_apply_event(Relay_log_info const *) override { return 0; }
4380 int do_update_pos(Relay_log_info *rli) override;
4381#endif
4382
4383 /**
4384 Add a hash which identifies a inserted/updated/deleted row on the
4385 ongoing transaction.
4386
4387 @param[in] hash row identifier
4388 */
4389 void add_write_set(const char *hash);
4390
4391 /**
4392 Return a pointer to write-set list.
4393 */
4394 std::list<const char *> *get_write_set() { return &write_set; }
4395
4396 /**
4397 Add a hash which identifies a read row on the ongoing transaction.
4398
4399 @param[in] hash row identifier
4400 */
4401 void add_read_set(const char *hash);
4402
4403 /**
4404 Return a pointer to read-set list.
4405 */
4406 std::list<const char *> *get_read_set() { return &read_set; }
4407
4408 /**
4409 Read snapshot version from encoded buffers.
4410 Cannot be executed during data read from file (event constructor),
4411 since its required locks will collide with the server gtid state
4412 initialization procedure.
4413 */
4414 bool read_snapshot_version();
4415
4416 /**
4417 Return the transaction snapshot timestamp.
4418 */
4420
4421 /**
4422 Return the server uuid.
4423 */
4424 const char *get_server_uuid() { return server_uuid; }
4425
4426 /**
4427 Return the id of the committing thread.
4428 */
4429 my_thread_id get_thread_id() const {
4430 return static_cast<my_thread_id>(thread_id);
4431 }
4432
4433 /**
4434 Return true if transaction has GTID fully specified, false otherwise.
4435 */
4436 bool is_gtid_specified() const { return gtid_specified; }
4437};
4438
4439/**
4440 @class View_change_log_event
4441
4442 This is the subclass of View_change_log_event and Log_event
4443 This class created the view_change_log_event which is used as a marker in
4444 case a new node joins or leaves the group.
4445
4446 @internal
4447 The inheritance structure is as follows
4448
4449 Binary_log_event
4450 ^
4451 |
4452 |
4453B_l: View_change_event Log_event
4454 \ /
4455 \ /
4456 \ /
4457 \ /
4458 View_change_log_event
4459
4460 B_l: Namespace Binary_log
4461 @endinternal
4463
4465 public Log_event {
4466 private:
4467 size_t to_string(char *buf, ulong len) const;
4468
4469#ifdef MYSQL_SERVER
4470 bool write_data_header(Basic_ostream *ostream) override;
4471
4472 bool write_data_body(Basic_ostream *ostream) override;
4473
4474 bool write_data_map(Basic_ostream *ostream,
4475 std::map<std::string, std::string> *map);
4476#endif
4477
4478 size_t get_size_data_map(std::map<std::string, std::string> *map);
4479
4480 public:
4481 // disable copy-move semantics
4483 View_change_log_event &operator=(View_change_log_event &&) noexcept = delete;
4485 View_change_log_event &operator=(const View_change_log_event &) = delete;
4486
4487 View_change_log_event(const char *view_id);
4488
4490 const char *buffer,
4491 const mysql::binlog::event::Format_description_event *descr_event);
4492
4493 ~View_change_log_event() override;
4494
4495 void claim_memory_ownership(bool claim) override;
4496
4497 size_t get_data_size() override;
4498
4499#ifdef MYSQL_SERVER
4500 int pack_info(Protocol *protocol) override;
4501#endif
4502
4503#ifndef MYSQL_SERVER
4504 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4505#endif
4506
4507#if defined(MYSQL_SERVER)
4508 int do_apply_event(Relay_log_info const *rli) override;
4509 int do_update_pos(Relay_log_info *rli) override;
4510#endif
4511
4512 /**
4513 Returns the view id.
4514 */
4515 char *get_view_id() { return view_id; }
4516
4517 /**
4518 Sets the certification info in the event
4519
4520 @note size is calculated on this method as the size of the data
4521 might render the log even invalid. Also due to its size doing it
4522 here avoid looping over the data multiple times.
4523
4524 @param[in] info certification info to be written
4525 @param[out] event_size the event size after this operation
4526 */
4527 void set_certification_info(std::map<std::string, std::string> *info,
4528 size_t *event_size);
4529
4530 /**
4531 Returns the certification info
4532 */
4533 std::map<std::string, std::string> *get_certification_info() {
4534 return &certification_info;
4535 }
4536
4537 /**
4538 Set the certification sequence number
4539
4540 @param number the sequence number
4541 */
4542 void set_seq_number(rpl_gno number) { seq_number = number; }
4543
4544 /**
4545 Returns the certification sequence number
4546 */
4547 rpl_gno get_seq_number() { return seq_number; }
4549
4550inline bool is_any_gtid_event(const Log_event *evt) {
4552 evt->get_type_code()));
4553}
4554
4555/**
4556 Check if the given event is a session control event, one of
4557 `User_var_event`, `Intvar_event` or `Rand_event`.
4558
4559 @param evt The event to check.
4560
4561 @return true if the given event is of type `User_var_event`,
4562 `Intvar_event` or `Rand_event`, false otherwise.
4563 */
4564inline bool is_session_control_event(Log_event *evt) {
4568}
4569
4570/**
4571 The function checks the argument event properties to deduce whether
4572 it represents an atomic DDL.
4573
4574 @param evt a reference to Log_event
4575 @return true when the DDL properties are found,
4576 false otherwise
4577*/
4578inline bool is_atomic_ddl_event(Log_event const *evt) {
4579 return evt != nullptr &&
4581 static_cast<Query_log_event const *>(evt)->ddl_xid !=
4583}
4584
4585/**
4586 The function lists all DDL instances that are supported
4587 for crash-recovery (WL9175).
4588 todo: the supported feature list is supposed to grow. Once
4589 a feature has been readied for 2pc through WL7743,9536(7141/7016) etc
4590 it needs registering in the function.
4591
4592 @param thd an Query-log-event creator thread handle
4593 @param using_trans
4594 The caller must specify the value according to the following
4595 rules:
4596 @c true when
4597 - on master the current statement is not processing
4598 a table in SE which does not support atomic DDL
4599 - on slave the relay-log repository is transactional.
4600 @c false otherwise.
4601 @return true when the being created (master) or handled (slave) event
4602 is 2pc-capable, @c false otherwise.
4603*/
4604bool is_atomic_ddl(THD *thd, bool using_trans);
4605
4606#ifdef MYSQL_SERVER
4607/**
4608 Serialize an binary event to the given output stream. It is more general
4609 than call ev->write() directly. The caller will not be affected if any
4610 change happens in serialization process. For example, serializing the
4611 event in different format.
4613template <class EVENT>
4614bool binary_event_serialize(EVENT *ev, Basic_ostream *ostream) {
4615 return ev->write(ostream);
4616}
4617
4618/*
4619 This is an utility function that adds a quoted identifier into the a buffer.
4620 This also escapes any existence of the quote string inside the identifier.
4621 */
4622size_t my_strmov_quoted_identifier(THD *thd, char *buffer,
4623 const char *identifier, size_t length);
4624#else
4625size_t my_strmov_quoted_identifier(char *buffer, const char *identifier);
4626#endif
4628 const char *identifier,
4629 size_t length);
4630
4631/**
4632 Read an integer in net_field_length format, guarding against read out of
4633 bounds and advancing the position.
4634
4635 @param[in,out] packet Pointer to buffer to read from. On successful
4636 return, the buffer position will be incremented to point to the next
4637 byte after what was read.
4638
4639 @param[in,out] max_length Pointer to the number of bytes in the
4640 buffer. If the function would need to look at more than *max_length
4641 bytes in order to decode the number, the function will do nothing
4642 and return true.
4643
4644 @param[out] out Pointer where the value will be stored.
4645
4646 @retval false Success.
4647 @retval true Failure, i.e., reached end of buffer.
4648*/
4649template <typename T>
4650bool net_field_length_checked(const uchar **packet, size_t *max_length, T *out);
4651
4652/**
4653 Extract basic info about an event: type, query, is it ignorable
4654
4655 @param log_event the event to extract info from
4656 @return a pair first param is true if an error occurred, false otherwise
4657 second param is the event info
4658 */
4659std::pair<bool, mysql::binlog::event::Log_event_basic_info>
4661
4662/**
4663 Extract basic info about an event: type, query, is it ignorable
4664
4665 @param buf The event info buffer
4666 @param length The length of the buffer
4667 @param fd_event The Format description event associated
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 const char *buf, size_t length,
4675
4676/**
4677 @} (end of group Replication)
4678*/
4679
4680#endif /* _log_event_h */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
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:435
This event is created to contain the file data.
Definition: log_event.h:2098
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6829
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:6856
virtual int get_create_or_append() const
Definition: log_event.cc:6879
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:2132
size_t get_data_size() override
Definition: log_event.h:2123
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6866
~Append_block_log_event() override=default
const char * get_db() override
Definition: log_event.h:2129
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:6909
The abstract class for basic output streams which provides write operation.
Definition: basic_ostream.h:36
Event for the first block of file to be loaded, its only difference from Append_block event is that t...
Definition: log_event.h:2248
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:7130
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:7120
~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:7126
Delete_file_log_event is created when the LOAD_DATA query fails on the master for some reason,...
Definition: log_event.h:2170
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:7070
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:7048
size_t get_data_size() override
Definition: log_event.h:2193
~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:2201
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:7025
const char * get_db() override
Definition: log_event.h:2198
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:7058
Log row deletions.
Definition: log_event.h:3533
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:3554
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:12260
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12313
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:12280
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:12249
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3562
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12320
@ TYPE_CODE
Definition: log_event.h:3537
int do_before_row_operations(const Relay_log_info *const) override
Definition: log_event.cc:12287
Event responsible for LOAD DATA execution, it similar to Query_log_event but before executing the que...
Definition: log_event.h:2315
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:7284
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:2340
bool write_post_header_for_derived(Basic_ostream *ostream) override
Definition: log_event.cc:7194
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:7253
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:7188
ulong get_post_header_size_for_derived() override
Definition: log_event.cc:7184
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:7143
~Execute_load_query_log_event() override=default
Definition: field.h:570
For binlog version 4.
Definition: log_event.h:1531
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:5145
std::atomic< int32 > atomic_usage_counter
Definition: log_event.h:1549
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5151
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:5324
size_t get_data_size() override
Definition: log_event.h:1562
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5161
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5295
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5244
Format_description_log_event()
Format_description_log_event 1st ctor.
Definition: log_event.cc:5036
This is a subclass if Gtid_event and Log_event.
Definition: log_event.h:3950
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:13406
rpl_gno get_gno() const override
Return the GNO for this GTID.
Definition: log_event.h:4119
rpl_sidno get_sidno(bool need_lock)
Return the SIDNO relative to the global tsid_map for this GTID.
Definition: log_event.cc:13437
~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:13120
Gtid_log_event(Gtid_log_event &&) noexcept=delete
size_t get_event_length()
Definition: log_event.h:4015
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13387
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:4083
uint32 write_body_to_memory(uchar *buff)
Writes the body to the given memory buffer.
Definition: log_event.cc:13157
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:13130
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:13231
uint32 write_post_header_to_memory(uchar *buffer)
Writes the post-header to the given memory buffer.
Definition: log_event.cc:13060
static const size_t SET_STRING_PREFIX_LENGTH
Length of SET_STRING_PREFIX.
Definition: log_event.h:4129
Tsid tsid
TSID for this GTID.
Definition: log_event.h:4142
const Tsid & get_tsid() const
Return the TSID for this GTID.
Definition: log_event.h:4089
Gtid_specification get_gtid_spec()
Definition: log_event.cc:13450
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13222
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:13416
static const size_t MAX_SET_STRING_LENGTH
The maximal length of the entire "SET ..." query.
Definition: log_event.h:4131
void update_parent_gtid_info()
Updates parent tsid and gtid info structure.
Definition: log_event.cc:12885
static const char * SET_STRING_PREFIX
string holding the text "SET @@GLOBAL.GTID_NEXT = '"
Definition: log_event.h:4125
void clear_gtid_and_spec()
Clears tsid and spec.
Definition: log_event.cc:12891
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:12975
Gtid_specification spec
Internal representation of the GTID.
Definition: log_event.h:4140
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12956
size_t get_data_size() override
Definition: log_event.h:3996
size_t to_string(char *buf) const
Used internally by both print() and pack_info().
Definition: log_event.cc:12964
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:13401
Represents a set of GTIDs.
Definition: rpl_gtid.h:1557
Definition: rpl_utility.h:110
Definition: log_event.h:3853
Heartbeat_log_event_v2(const char *buf, const mysql::binlog::event::Format_description_event *description_event)
Definition: log_event.cc:14272
Definition: log_event.h:3845
Heartbeat_log_event(const char *buf, const mysql::binlog::event::Format_description_event *description_event)
Definition: log_event.cc:14265
Base class for ignorable log events is Ignorable_event.
Definition: log_event.h:3699
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12657
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:12650
size_t get_data_size() override
Definition: log_event.h:3732
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:3608
Incident_log_event(const Incident_log_event &)=delete
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:12602
size_t get_data_size() override
Definition: log_event.h:3661
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:12628
~Incident_log_event() override
Definition: log_event.cc:12516
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:12562
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12535
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:12529
const char * description() const
Definition: log_event.cc:12520
bool ends_group() const override
Definition: log_event.h:3666
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:1607
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5640
~Intvar_log_event() override=default
Intvar_log_event(Intvar_log_event &&) noexcept=delete
size_t get_data_size() override
Definition: log_event.h:1636
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:5719
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:5650
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:5615
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:1644
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5694
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5714
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:928
Definition: key.h:113
Definition: sql_list.h:494
Definition: log_event.h:2351
bool has_replace
Definition: log_event.h:2371
const size_t BUF_SIZE
Definition: log_event.h:2360
const char * table_name
Definition: log_event.h:2367
const char * fname
Definition: log_event.h:2368
const sql_exchange * sql_ex
Definition: log_event.h:2365
THD * thd
Definition: log_event.h:2364
bool has_ignore
Definition: log_event.h:2372
String str
Definition: log_event.h:2361
const char * db
Definition: log_event.h:2366
bool is_concurrent
Definition: log_event.h:2370
const String * generate(size_t *fn_start, size_t *fn_end)
Definition: log_event.cc:7393
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:7376
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:1256
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_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:2474
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:2881
virtual int do_apply_event(Relay_log_info const *rli)
Primitive to apply an event to the database.
Definition: log_event.h:1168
virtual const char * get_db()
Definition: log_event.cc:1059
static enum enum_mts_event_exec_mode get_mts_execution_mode(bool mts_in_group, mysql::binlog::event::Log_event_type type_code, uint32 server_id, uint32 log_pos)
Definition: log_event.h:952
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:1064
uint32 write_header_to_memory(uchar *buf)
Writes the common header of this event to the given memory buffer.
Definition: log_event.cc:1217
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:1100
uint32 server_id
Definition: log_event.h:664
enum_mts_event_exec_mode
Definition: log_event.h:933
@ EVENT_EXEC_PARALLEL
Definition: log_event.h:937
@ EVENT_EXEC_SYNC
Definition: log_event.h:945
@ EVENT_EXEC_CAN_NOT
Definition: log_event.h:949
@ EVENT_EXEC_ASYNC
Definition: log_event.h:941
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:1143
bool is_valid()
Definition: log_event.cc:1309
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:1067
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:1195
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 is_mts_sequential_exec() const
Is called from get_mts_execution_mode() to.
Definition: log_event.h:909
bool m_free_temp_buf_in_destructor
Definition: log_event.h:655
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:1135
virtual int do_apply_event_worker(Slave_worker *w)
Definition: log_event.cc:983
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:899
time_t get_time()
Prints a "session_var=value" string.
Definition: log_event.cc:876
bool write_footer(Basic_ostream *ostream)
Definition: log_event.cc:1204
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
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:1005
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:1046
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:2838
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:935
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:1079
void free_temp_buf()
Definition: log_event.h:869
bool is_mts_group_isolated()
Definition: log_event.h:1086
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:1054
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:1087
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:997
virtual bool ends_group() const
Definition: log_event.h:1105
bool need_checksum()
A decider of whether to trigger checksum computation or not.
Definition: log_event.cc:1116
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:2579
This is the subclass of Previous_gtids_event and Log_event It is used to record the gtid_executed in ...
Definition: log_event.h:4201
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13541
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:13548
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:13522
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13485
int do_apply_event(Relay_log_info const *) override
Primitive to apply an event to the database.
Definition: log_event.h:4293
int add_to_set(Gtid_set *gtid_set) const
Add all GTIDs from this event to the given Gtid_set.
Definition: log_event.cc:13511
size_t get_data_size() override
Definition: log_event.h:4224
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:4288
bool write(Basic_ostream *ostream) override
Definition: log_event.h:4232
~Previous_gtids_log_event() override=default
const uchar * get_buf()
Return the encoded buffer, or NULL on error.
Definition: log_event.h:4269
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:13459
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:1291
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:4917
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:1497
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:1467
Query_log_event(const Query_log_event &)=delete
bool is_trans_keyword() const
Definition: log_event.h:1435
mysql::binlog::event::Log_event_header::Byte * data_buf
Definition: log_event.h:1293
bool m_skip_temp_tables_handling_by_worker
Instructs the applier to skip temporary tables handling.
Definition: log_event.h:1335
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:4967
Query_log_event()
The simplest constructor that could possibly work.
Definition: log_event.cc:3439
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:4931
virtual ulong get_post_header_size_for_derived()
Definition: log_event.h:1419
bool starts_group() const override
Notice, DDL queries are logged without BEGIN/COMMIT parentheses and identification of such single-que...
Definition: log_event.h:1475
uchar mts_number_dbs() override
Definition: log_event.h:1386
my_thread_id slave_proxy_id
Definition: log_event.h:1308
void set_skip_temp_tables_handling_by_worker()
Definition: log_event.h:1337
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:5020
bool has_ddl_committed
The flag indicates whether the DDL query has been (already) committed or not.
Definition: log_event.h:1328
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:4185
~Query_log_event() override
Definition: log_event.h:1404
void attach_temp_tables_worker(THD *, const Relay_log_info *)
Associating slave Worker thread to a subset of temporary tables.
Definition: log_event.cc:4162
bool write(Basic_ostream *ostream) override
Query_log_event::write().
Definition: log_event.cc:3141
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:1316
bool is_query_prefix_match(const char *pattern, uint p_len)
Definition: log_event.h:1491
uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter) override
Definition: log_event.h:1361
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:1501
const char * get_db() override
Definition: log_event.h:1348
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:3090
bool ends_group() const override
Definition: log_event.h:1480
bool is_skip_temp_tables_handling_by_worker()
Definition: log_event.h:1341
virtual bool write_post_header_for_derived(Basic_ostream *)
Definition: log_event.h:1412
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:4176
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
Definition: log_event.h:1680
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5760
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:1714
~Rand_log_event() override=default
size_t get_data_size() override
Definition: log_event.h:1709
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:5805
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5786
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5736
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5800
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:5754
Definition: rpl_rli.h:205
This will be deprecated when we move to using sequence ids.
Definition: log_event.h:2033
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5449
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5337
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:5591
~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:5410
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5420
size_t get_data_size() override
Definition: log_event.h:2053
Definition: log_event.h:2663
bool is_enabled()
If instrumentation is enabled this member function SHALL return true.
Definition: log_event.h:2690
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:2736
ulonglong m_n_rows_applied
Counter that is unconditionally incremented on each row that is processed.
Definition: log_event.h:2678
ulonglong get_n_rows_applied()
Gets the value of the counter of rows that have been processed.
Definition: log_event.h:2742
Rows_applier_psi_stage()
Definition: log_event.h:2681
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:2703
void set_progress(PSI_stage_progress *progress)
Definition: log_event.h:2683
void end_work()
Resets this object.
Definition: log_event.h:2727
PSI_stage_progress * m_progress
A cached pointer to this stage PSI_stage_progress.
Definition: log_event.h:2671
Definition: log_event.h:2962
KEY ** m_key_info
Definition: log_event.h:2982
Key_compare(KEY **ki=nullptr)
Definition: log_event.h:2975
bool operator()(uchar *k1, uchar *k2) const
Definition: log_event.h:2976
Common base class for all row-containing log events.
Definition: log_event.h:2780
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:3284
uint32 m_bitbuf[128/(sizeof(uint32) *8)]
Definition: log_event.h:2943
uchar * m_rows_end
Definition: log_event.h:2952
int close_record_scan()
Does the cleanup.
Definition: log_event.cc:8654
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:8599
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:10194
virtual int do_before_row_operations(const Relay_log_info *const log)=0
uchar * m_rows_buf
Definition: log_event.h:2950
void decide_row_lookup_algorithm_and_key()
Definition: log_event.cc:8207
uint m_rows_lookup_algorithm
The algorithm to use while searching for rows using the before image.
Definition: log_event.h:2924
TABLE * m_table
Definition: log_event.h:2903
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:3084
bool is_rbr_logging_format() const override
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:3071
int do_hash_row(Relay_log_info const *rli)
Populates the m_hash when using HASH_SCAN.
Definition: log_event.cc:9036
@ RLE_NO_FLAGS
Definition: log_event.h:2816
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:2918
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:2990
int do_hash_scan_and_update(Relay_log_info const *rli)
Implementation of the hash_scan and update algorithm.
Definition: log_event.cc:9280
int add_row_data(uchar *data, size_t length)
Definition: log_event.h:2841
uint m_key_index
Definition: log_event.h:2960
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:8629
int row_operations_scan_and_key_setup()
Definition: log_event.cc:8305
MY_BITMAP const * get_cols_ai() const
Definition: log_event.h:2850
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:10056
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:2940
uchar * m_key
Definition: log_event.h:2959
int do_index_scan_and_update(Relay_log_info const *rli)
Implementation of the index scan and update algorithm.
Definition: log_event.cc:8805
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:9104
virtual int do_add_row_data(uchar *data, size_t length)
Definition: log_event.cc:7940
Rows_applier_psi_stage m_psi_progress
Definition: log_event.h:2783
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:8396
size_t get_data_size() override
Definition: log_event.cc:7907
const char * get_db() override
Definition: log_event.h:2874
uint16 flag_set
Definition: log_event.h:2793
row_lookup_mode
Definition: log_event.h:2795
@ ROW_LOOKUP_INDEX_SCAN
Definition: log_event.h:2798
@ ROW_LOOKUP_UNDEFINED
Definition: log_event.h:2796
@ ROW_LOOKUP_NOT_NEEDED
Definition: log_event.h:2797
@ ROW_LOOKUP_TABLE_SCAN
Definition: log_event.h:2799
@ ROW_LOOKUP_HASH_SCAN
Definition: log_event.h:2800
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:3209
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:8378
uchar * m_rows_cur
Definition: log_event.h:2951
const mysql::binlog::event::Table_id & get_table_id() const
Definition: log_event.h:2851
uint m_row_count
Definition: log_event.h:2877
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:9384
int next_record_scan(bool first_read)
Fetches next row.
Definition: log_event.cc:8667
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:10300
int do_table_scan_and_update(Relay_log_info const *rli)
Implementation of the legacy table_scan and update algorithm.
Definition: log_event.cc:9301
MY_BITMAP m_local_cols
Bitmap denoting columns available in the image as they appear in the table setup.
Definition: log_event.h:2912
int open_record_scan()
Initializes scanning of rows.
Definition: log_event.cc:8729
void clear_flags(flag_set flags_arg)
Definition: log_event.h:2821
virtual int do_exec_row(const Relay_log_info *const rli)=0
std::set< uchar *, Key_compare >::iterator m_itr
Definition: log_event.h:2985
enum_error
Enumeration of the errors that can be returned.
Definition: log_event.h:2806
@ ERR_TABLE_LIMIT_EXCEEDED
No more room for tables.
Definition: log_event.h:2809
@ ERR_BAD_TABLE_DEF
Table definition does not match.
Definition: log_event.h:2811
@ ERR_OPEN_FAILURE
Failure to open table.
Definition: log_event.h:2807
@ ERR_RBR_TO_SBR
daisy-chanining RBR to SBR not allowed
Definition: log_event.h:2812
@ ERR_OUT_OF_MEM
Out of memory.
Definition: log_event.h:2810
@ ERR_OK
No error.
Definition: log_event.h:2808
int row_operations_scan_and_key_teardown(int error)
Definition: log_event.cc:8348
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:7884
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:2849
std::set< uchar *, Key_compare > m_distinct_keys
Definition: log_event.h:2984
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:8511
Rows_log_event(Rows_log_event &&) noexcept=delete
const uchar * m_curr_row
Definition: log_event.h:2957
MY_BITMAP m_cols_ai
Bitmap for columns available in the after image, if present.
Definition: log_event.h:2933
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:8785
KEY * m_key_info
Definition: log_event.h:2961
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:7791
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:10162
~Rows_log_event() override
Definition: log_event.cc:7771
void set_flags(flag_set flags_arg)
Definition: log_event.h:2820
friend class Old_rows_log_event
Definition: log_event.h:3276
const uchar * m_curr_row_end
Definition: log_event.h:2958
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:10267
uint32 m_bitbuf_ai[128/(sizeof(uint32) *8)]
Definition: log_event.h:2944
MY_BITMAP m_cols
Definition: log_event.h:2905
It is used to record the original query for the rows events in RBR.
Definition: log_event.h:3771
size_t get_data_size() override
Definition: log_event.h:3820
~Rows_query_log_event() override
Definition: log_event.h:3813
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:12789
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:12772
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:12687
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12694
Rows_query_log_event(THD *thd_arg, const char *query, size_t query_len)
Definition: log_event.h:3774
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:468
Definition: log_event.h:1957
mysql::binlog::event::Log_event_type get_type_code() const override
Definition: log_event.h:1986
Stop_log_event()
Definition: log_event.h:1966
~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:6750
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:1995
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:6770
String class wrapper with a preallocated buffer of size buff_sz.
Definition: sql_string.h:672
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
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:2435
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:10826
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:10691
Table_map_log_event(const Table_map_log_event &)=delete
uint8 mts_number_dbs() override
Definition: log_event.h:2527
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:10835
const char * get_db_name() const
Definition: log_event.h:2519
virtual int save_field_metadata()
Save the field metadata based on the real_type of the field.
Definition: log_event.cc:10388
bool init_set_str_value_field()
Definition: log_event.cc:11143
flag_set get_flags(flag_set flag) const
Definition: log_event.h:2481
~Table_map_log_event() override
bool init_geometry_type_field()
Definition: log_event.cc:11191
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:11037
bool init_primary_key_field()
Definition: log_event.cc:11222
enum_flag
Definition: log_event.h:2458
@ ENUM_FLAG_COUNT
Nothing here right now, but the flags support is there in preparation for changes that are coming.
Definition: log_event.h:2465
bool is_rbr_logging_format() const override
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:2589
const mysql::binlog::event::Table_id & get_table_id() const
Definition: log_event.h:2515
bool init_column_visibility_field()
Definition: log_event.cc:11270
const char * get_table_name() const
Definition: log_event.h:2518
uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter) override
Definition: log_event.h:2539
@ TYPE_CODE
Definition: log_event.h:2444
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:10840
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:10854
bool init_enum_str_value_field()
Definition: log_event.cc:11170
bool init_column_name_field()
Definition: log_event.cc:11131
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:2613
const char * get_db() override
Definition: log_event.h:2526
size_t get_data_size() override
Definition: log_event.h:2521
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:11302
TABLE * m_table
Definition: log_event.h:2599
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:10572
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:10983
enum_error
Enumeration of the errors that can be returned.
Definition: log_event.h:2449
@ ERR_OK
No error.
Definition: log_event.h:2451
@ ERR_TABLE_LIMIT_EXCEEDED
No more room for tables.
Definition: log_event.h:2452
@ ERR_OPEN_FAILURE
Failure to open table.
Definition: log_event.h:2450
@ ERR_OUT_OF_MEM
Out of memory.
Definition: log_event.h:2453
@ ERR_BAD_TABLE_DEF
Table definition does not match.
Definition: log_event.h:2454
@ ERR_RBR_TO_SBR
daisy-chanining RBR to SBR not allowed
Definition: log_event.h:2455
bool has_generated_invisible_primary_key() const
Definition: log_event.cc:10568
bool init_vector_dimensionality_field()
Definition: log_event.cc:11208
StringBuffer< 1024 > m_metadata_buf
Definition: log_event.h:2602
@ TM_GENERATED_INVISIBLE_PK_F
Table has generated invisible primary key.
Definition: log_event.h:2478
@ TM_BIT_LEN_EXACT_F
Definition: log_event.h:2471
@ TM_NO_FLAGS
Definition: log_event.h:2470
@ TM_REFERRED_FK_DB_F
Definition: log_event.h:2472
bool init_signedness_field()
Definition: log_event.cc:11006
This is the subclass of Transaction_context_event and Log_event This class encodes the transaction_co...
Definition: log_event.h:4323
static int get_data_set_size(std::list< const char * > *set)
Definition: log_event.cc:13783
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:13795
my_thread_id get_thread_id() const
Return the id of the committing thread.
Definition: log_event.h:4427
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:13557
void add_read_set(const char *hash)
Add a hash which identifies a read row on the ongoing transaction.
Definition: log_event.cc:13800
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13675
Gtid_set * get_snapshot_version()
Return the transaction snapshot timestamp.
Definition: log_event.h:4417
size_t get_data_size() override
Definition: log_event.cc:13682
int do_apply_event(Relay_log_info const *) override
Primitive to apply an event to the database.
Definition: log_event.h:4377
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13650
bool read_snapshot_version()
Read snapshot version from encoded buffers.
Definition: log_event.cc:13763
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:13642
Gtid_set * snapshot_version
A gtid_set which is used to store the transaction set used for conflict detection.
Definition: log_event.h:4329
size_t get_event_length()
Definition: log_event.cc:13694
Tsid_map * tsid_map
The Tsid_map to use for creating the Gtid_set.
Definition: log_event.h:4326
std::list< const char * > * get_read_set()
Return a pointer to read-set list.
Definition: log_event.h:4404
size_t get_snapshot_version_size()
Definition: log_event.cc:13777
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:13699
bool is_gtid_specified() const
Return true if transaction has GTID fully specified, false otherwise.
Definition: log_event.h:4434
~Transaction_context_log_event() override
Definition: log_event.cc:13625
bool write_data_set(Basic_ostream *ostream, std::list< const char * > *set)
Definition: log_event.cc:13743
std::list< const char * > * get_write_set()
Return a pointer to write-set list.
Definition: log_event.h:4392
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13715
size_t to_string(char *buf, ulong len) const
Definition: log_event.cc:13636
const char * get_server_uuid()
Return the server uuid.
Definition: log_event.h:4422
bool write_snapshot_version(Basic_ostream *ostream)
Definition: log_event.cc:13727
Definition: log_event.h:3874
size_t get_event_length()
Definition: log_event.h:3910
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:14027
bool apply_payload_event(Relay_log_info const *rli, const uchar *event_buf)
Definition: log_event.cc:14084
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:14172
bool ends_group() const override
Definition: log_event.cc:14219
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:14177
~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:14209
size_t get_data_size() override
Definition: log_event.cc:14019
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:3878
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:14033
Represents a bidirectional map between TSID and SIDNO.
Definition: rpl_gtid.h:750
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:3413
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12458
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:12345
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:12373
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:3446
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:12418
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12451
@ TYPE_CODE
Definition: log_event.h:3417
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:12425
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3455
~Update_rows_log_event() override
Definition: log_event.cc:12396
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:8978
void init(MY_BITMAP const *cols)
Definition: log_event.cc:12380
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:1888
~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:1942
bool is_deferred()
Definition: log_event.h:1931
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:6698
query_id_t query_id
Definition: log_event.h:1898
void set_deferred(query_id_t qid)
Definition: log_event.h:1936
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6319
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:6588
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:6717
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:6703
bool deferred
Definition: log_event.h:1897
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6417
This is the subclass of View_change_log_event and Log_event This class created the view_change_log_ev...
Definition: log_event.h:4463
std::map< std::string, std::string > * get_certification_info()
Returns the certification info.
Definition: log_event.h:4531
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13940
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:13867
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13957
void set_seq_number(rpl_gno number)
Set the certification sequence number.
Definition: log_event.h:4540
char * get_view_id()
Returns the view id.
Definition: log_event.h:4513
size_t get_size_data_map(std::map< std::string, std::string > *map)
Definition: log_event.cc:13848
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13873
size_t get_data_size() override
Definition: log_event.cc:13839
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:13946
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:13899
rpl_gno get_seq_number()
Returns the certification sequence number.
Definition: log_event.h:4545
bool write_data_map(Basic_ostream *ostream, std::map< std::string, std::string > *map)
Definition: log_event.cc:13965
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:14001
View_change_log_event(const View_change_log_event &)=delete
size_t to_string(char *buf, ulong len) const
Definition: log_event.cc:13862
Log row insertions and updates.
Definition: log_event.h:3324
int do_before_row_operations(const Relay_log_info *const) override
Definition: log_event.cc:11788
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:12235
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3357
@ TYPE_CODE
Definition: log_event.h:3328
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:11758
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:3346
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12212
int write_row(const Relay_log_info *const, const bool)
Write the current row into event's table.
Definition: log_event.cc:11977
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:11896
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:11768
Similar to Xid_log_event except that.
Definition: log_event.h:1827
static const int xid_bufs_size
Definition: log_event.h:1830
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:6275
XA_prepare_log_event(THD *thd_arg, XID *xid_arg, bool one_phase_arg=false)
Definition: log_event.h:1834
size_t get_data_size() override
Definition: log_event.h:1850
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6213
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:6241
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6199
mysql::binlog::event::Log_event_type get_type_code() const override
Definition: log_event.h:1847
Definition: log_event.h:1753
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:6185
bool ends_group() const override
Definition: log_event.h:1766
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:1756
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:5940
~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:6013
This is the subclass of Xid_event defined in libbinlogevent, An XID event is generated for a commit o...
Definition: log_event.h:1776
~Xid_log_event() override=default
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5866
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:5843
size_t get_data_size() override
Definition: log_event.h:1802
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:5899
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:5860
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:874
@ IGNORABLE_HEADER_LEN
Definition: binlog_event.h:888
@ FORMAT_DESCRIPTION_HEADER_LEN
Definition: binlog_event.h:878
@ INCIDENT_HEADER_LEN
Definition: binlog_event.h:886
@ DELETE_FILE_HEADER_LEN
Definition: binlog_event.h:875
@ ROTATE_HEADER_LEN
Definition: binlog_event.h:872
const Log_event_header * header() const
Return a const pointer to the header of the log event.
Definition: binlog_event.h:951
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:959
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:240
GTID stands for Global Transaction IDentifier It is composed of two parts:
Definition: control_events.h:1017
int get_server_version_length() const
We only store the immediate_server_version if both server versions are the same.
Definition: control_events.h:1237
int get_commit_timestamp_length() const
Definition: control_events.h:1227
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:1316
static const int POST_HEADER_LENGTH
Total length of post header.
Definition: control_events.h:1255
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1670
Replication event to ensure to replica that source is alive.
Definition: control_events.h:1744
Base class for ignorable log events.
Definition: control_events.h:675
Class representing an incident, an occurrence out of the ordinary, that happened on the master.
Definition: control_events.h:441
char * message
Definition: control_events.h:492
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:462
size_t message_length
Definition: control_events.h:493
enum_incident
Enumeration of the incidents that can occur for the server.
Definition: control_events.h:446
@ INCIDENT_NONE
No incident.
Definition: control_events.h:448
@ INCIDENT_COUNT
Shall be last event of the enumeration.
Definition: control_events.h:452
An Intvar_event will be created just before a Query_event, if the query uses one of the variables LAS...
Definition: statement_events.h:922
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:677
unsigned long long log_pos
Definition: binlog_event.h:708
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:723
Log_event_type type_code
Event type extracted from the header.
Definition: binlog_event.h:693
void set_is_valid(bool is_valid)
Set if the event object shall be considered valid or not.
Definition: binlog_event.h:757
uint16_t flags
Definition: binlog_event.h:716
Definition: control_events.h:1381
size_t buf_size
Definition: control_events.h:1409
const unsigned char * buf
Definition: control_events.h:1410
A Query_event is created for each query that modifies the database, unless the query is logged row-ba...
Definition: statement_events.h:452
const char * db
Definition: statement_events.h:536
const char * query
Definition: statement_events.h:535
unsigned char mts_accessed_dbs
Definition: statement_events.h:641
char mts_accessed_db_names[MAX_DBS_IN_EVENT_MTS][NAME_LEN]
Definition: statement_events.h:642
size_t q_len
Definition: statement_events.h:588
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
Definition: statement_events.h:1034
Rand_event(unsigned long long seed1_arg, unsigned long long seed2_arg)
Definition: statement_events.h:1044
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:117
unsigned int flags
Definition: control_events.h:121
size_t ident_len
Definition: control_events.h:120
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:380
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:386
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:1469
bool gtid_specified
Definition: control_events.h:1505
uint32_t thread_id
Definition: control_events.h:1504
std::list< const char * > read_set
Definition: control_events.h:1509
const char * server_uuid
Definition: control_events.h:1503
std::list< const char * > write_set
Definition: control_events.h:1508
Event that encloses all the events of a transaction.
Definition: control_events.h:736
Transaction_payload_event(const Transaction_payload_event &)=delete
An unknown event should never occur.
Definition: binlog_event.h:989
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:805
const char * name
Definition: statement_events.h:854
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:821
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:1569
long long int seq_number
Definition: control_events.h:1623
std::map< std::string, std::string > certification_info
Definition: control_events.h:1625
char view_id[ENCODED_VIEW_ID_MAX_LEN]
Definition: control_events.h:1621
Log row insertions.
Definition: rows_event.h:1099
An XA_prepare event is generated for a XA prepared transaction.
Definition: control_events.h:589
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:618
void * xid
Definition: control_events.h:609
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:524
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:531
uint64_t xid
Definition: control_events.h:541
Represents Transaction Source Identifier which is composed of source UUID and transaction tag.
Definition: tsid.h:44
static std::size_t get_size(const T &arg)
Definition: serializer_impl.hpp:70
Definition: partition_info.h:209
Definition: sql_exchange.h:196
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:74
Contains the classes representing events operating in the replication stream properties.
#define U
Definition: ctype-tis620.cc:73
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:109
#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:122
#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:116
void close_cached_file(IO_CACHE *cache)
Definition: mf_cache.cc:87
bool my_b_inited(const IO_CACHE *info)
Definition: my_sys.h:488
#define MY_WME
Definition: my_sys.h:133
int my_b_copy_to_file(IO_CACHE *cache, FILE *file)
Definition: mf_iocache2.cc:73
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:321
@ 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:14332
size_t my_strmov_quoted_identifier(THD *thd, char *buffer, const char *identifier, size_t length)
Definition: log_event.cc:14292
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:4576
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:802
bool binary_event_serialize(EVENT *ev, Basic_ostream *ostream)
Serialize an binary event to the given output stream.
Definition: log_event.h:4612
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:762
TYPELIB binlog_checksum_typelib
Definition: log_event.cc:222
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:3512
int ignored_error_code(int err_code)
Ignore error code specified on command line.
Definition: log_event.cc:608
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:4548
size_t my_strmov_quoted_identifier_helper(int q, char *buffer, const char *identifier, size_t length)
Definition: log_event.cc:14305
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:4562
PSI_memory_key key_memory_Rows_query_log_event_rows_query
Definition: log_event.cc:197
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:3826
PSI_memory_key key_memory_Incident_log_event_message
Definition: log_event.cc:196
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:5825
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:820
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:7546
#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
#define T
Definition: jit_executor_value.cc:373
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:513
#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 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:87
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:60
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:1285
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:200
const char * delimiter
Definition: mysqlslap.cc:161
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:924
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:38
Log_event_type
Enumeration type for the different types of log events.
Definition: binlog_event.h:278
@ INCIDENT_EVENT
Something out of the ordinary happened on the master.
Definition: binlog_event.h:322
@ FORMAT_DESCRIPTION_EVENT
Definition: binlog_event.h:304
@ EXECUTE_LOAD_QUERY_EVENT
Definition: binlog_event.h:307
@ ROWS_QUERY_LOG_EVENT
Definition: binlog_event.h:337
@ WRITE_ROWS_EVENT
Version 2 of the Row events.
Definition: binlog_event.h:340
@ DELETE_ROWS_EVENT
Definition: binlog_event.h:342
@ XA_PREPARE_LOG_EVENT
Definition: binlog_event.h:354
@ QUERY_EVENT
Definition: binlog_event.h:292
@ UNKNOWN_EVENT
Every time you add a type, you have to.
Definition: binlog_event.h:286
@ PREVIOUS_GTIDS_LOG_EVENT
Definition: binlog_event.h:347
@ UPDATE_ROWS_EVENT
Definition: binlog_event.h:341
@ RAND_EVENT
Definition: binlog_event.h:302
@ TABLE_MAP_EVENT
Definition: binlog_event.h:309
@ STOP_EVENT
Definition: binlog_event.h:293
@ INTVAR_EVENT
Definition: binlog_event.h:295
@ USER_VAR_EVENT
Definition: binlog_event.h:303
@ ROTATE_EVENT
Definition: binlog_event.h:294
@ SLAVE_EVENT
Definition: binlog_event.h:297
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:38
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
static void log_event(const std::string &msg, loglevel lvl)
Helper function that calls the logging API to log errors.
Definition: handler.cc:59
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2888
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2898
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:113
const int MAX_GNO_TEXT_LENGTH
The length of MAX_GNO when printed in decimal.
Definition: rpl_gtid.h:287
enum_gtid_type
Enumeration of different types of values for Gtid_specification, i.e, the different internal states t...
Definition: rpl_gtid.h:3882
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:109
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:1258
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:1903
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:3999
enum_gtid_type type
The type of this GTID.
Definition: rpl_gtid.h:4012
Gtid gtid
The GTID: { SIDNO, GNO } if type == GTID; { 0, 0 } if type == AUTOMATIC or ANONYMOUS.
Definition: rpl_gtid.h:4018
rpl_gno gno
GNO of this Gtid.
Definition: rpl_gtid.h:1107
Definition: my_sys.h:339
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:794
Definition: table.h:1435
TABLE_SHARE * s
Definition: table.h:1436
Definition: typelib.h:35
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:391
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:595
synode_no q[FIFO_SIZE]
Definition: xcom_base.cc:4112
static uint64_t cache_size
Definition: xcom_cache.cc:363