MySQL 26.7.0
Source Code Documentation
log_event.h
Go to the documentation of this file.
1/* Copyright (c) 2000, 2026, 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 uint8_t enable_cascade_triggers;
431
432 PRINT_EVENT_INFO();
433
434 ~PRINT_EVENT_INFO() {
435 close_cached_file(&head_cache);
436 close_cached_file(&body_cache);
437 close_cached_file(&footer_cache);
438 }
439 bool init_ok() /* tells if construction was successful */
440 {
441 return my_b_inited(&head_cache) && my_b_inited(&body_cache) &&
442 my_b_inited(&footer_cache);
443 }
444
445 /* Settings on how to print the events */
446 // True if the --short-form flag was specified
447 bool short_form;
448 // The X in --base64-output=X
449 enum_base64_output_mode base64_output_mode;
450 // True if the --skip-gtids flag was specified.
451 bool skip_gtids;
452
453 /*
454 This is set whenever a Format_description_event is printed.
455 Later, when an event is printed in base64, this flag is tested: if
456 no Format_description_event has been seen, it is unsafe to print
457 the base64 event, so an error message is generated.
458 */
459 bool printed_fd_event;
460 my_off_t hexdump_from;
461 uint8 common_header_len;
462 char delimiter[16];
463
464 uint verbose;
465 table_mapping m_table_map;
466 table_mapping m_table_map_ignored;
467
468 /*
469 These three caches are used by the row-based replication events to
470 collect the header information and the main body of the events
471 making up a statement and in footer section any verbose related details
472 or comments related to the statement.
473 */
474 IO_CACHE head_cache;
475 IO_CACHE body_cache;
476 IO_CACHE footer_cache;
477 /* Indicate if the body cache has unflushed events */
478 bool have_unflushed_events;
479
480 /*
481 True if an event was skipped while printing the events of
482 a transaction and no COMMIT statement or XID event was ever
483 output (ie, was filtered out as well). This can be triggered
484 by the --database option of mysqlbinlog.
485
486 False, otherwise.
487 */
488 bool skipped_event_in_transaction;
489
490 bool print_table_metadata;
491
492 /**
493 True if --require_row_format is passed.
494 If true
495 It prints at start SET @@session.require_row_format = 1
496 It omits the SET @@session.pseudo_thread_id printed on Query events
497 */
498 bool require_row_format;
499
500 /**
501 The version of the last server that sent the transaction
502 */
503 uint32_t immediate_server_version;
504};
505#endif
506
507/*
508 A specific to the database-scheduled MTS type.
511 const char *name[MAX_DBS_IN_EVENT_MTS]{nullptr};
512 int num{0};
513
514 Mts_db_names() = default;
515
516 void reset_and_dispose() {
517 for (int i = 0; i < MAX_DBS_IN_EVENT_MTS; i++) {
518 free(const_cast<char *>(name[i]));
519 name[i] = nullptr;
520 }
521 num = 0;
522 }
523};
524
525/**
526 @class Log_event
527
528 This is the abstract base class for binary log events.
529
530 @section Log_event_binary_format Binary Format
531
532 The format of the event is described @ref Binary_log_event_format "here".
533
534 @subsection Log_event_format_of_atomic_primitives Format of Atomic Primitives
535
536 - All numbers, whether they are 16-, 24-, 32-, or 64-bit numbers,
537 are stored in little endian, i.e., the least significant byte first,
538 unless otherwise specified.
540*/
541class Log_event {
542 public:
543 /**
544 Enumeration of what kinds of skipping (and non-skipping) that can
545 occur when the slave executes an event.
546
547 @see shall_skip
548 @see do_shall_skip
549 */
550 enum enum_skip_reason {
551 /**
552 Don't skip event.
553 */
555
556 /**
557 Skip event by ignoring it.
558
559 This means that the slave skip counter will not be changed.
560 */
562
563 /**
564 Skip event and decrease skip counter.
565 */
567 };
569 protected:
572 /*
573 If possible the event should use a non-transactional cache before
574 being flushed to the binary log. This means that it must be flushed
575 right after its correspondent statement is completed.
576 */
578 /*
579 The event should use a transactional cache before being flushed to
580 the binary log. This means that it must be flushed upon commit or
581 rollback.
582 */
584 /*
585 The event must be written directly to the binary log without going
586 through any cache.
587 */
589 /*
590 If there is a need for different types, introduce them before this.
591 */
593 };
597 /*
598 The event must be written to a cache and upon commit or rollback
599 written to the binary log.
600 */
602 /*
603 The event must be written to an empty cache and immediately written
604 to the binary log without waiting for any other event.
605 */
607 /*
608 If there is a need for different types, introduce them before this.
609 */
611 };
612
613 /**
614 Writes the common header of this event to the given memory buffer.
615
616 This does not update the checksum.
617
618 @note This has the following form:
619
620 +---------+---------+---------+------------+-----------+-------+
621 |timestamp|type code|server_id|event_length|end_log_pos|flags |
622 |4 bytes |1 byte |4 bytes |4 bytes |4 bytes |2 bytes|
623 +---------+---------+---------+------------+-----------+-------+
624
625 @param buf Memory buffer to write to. This must be at least
626 LOG_EVENT_HEADER_LEN bytes long.
627
628 @return The number of bytes written, i.e., always
629 LOG_EVENT_HEADER_LEN.
630 */
632 /**
633 Writes the common-header of this event to the given output stream and
634 updates the checksum.
635
636 @param ostream The event will be written to this output stream.
637
638 @param data_length The length of the post-header section plus the
639 length of the data section; i.e., the length of the event minus
640 the common-header and the checksum.
641 */
642 bool write_header(Basic_ostream *ostream, size_t data_length);
643 bool write_footer(Basic_ostream *ostream);
644 bool need_checksum();
645
646 public:
647 /*
648 A temp buffer for read_log_event; it is later analysed according to the
649 event's type, and its content is distributed in the event-specific fields.
650 */
651 char *temp_buf;
652
653 /*
654 This variable determines whether the event is responsible for deallocating
655 the memory pointed by temp_buf. When set to true temp_buf is deallocated
656 and when it is set to false just make temp_buf point to NULL.
657 */
660 /* The number of seconds the query took to run on the master. */
661 ulong exec_time;
662
663 /*
664 The master's server id (is preserved in the relay log; used to
665 prevent from infinite loops in circular replication).
666 */
668
669 /**
670 A storage to cache the global system variable's value.
671 Handling of a separate event will be governed its member.
672 */
673 ulong rbr_exec_mode;
674
675 /**
676 Defines the type of the cache, if any, where the event will be
677 stored before being flushed to disk.
678 */
680
681 /**
682 Defines when information, i.e. event or cache, will be flushed
683 to disk.
684 */
686 /**
687 Placeholder for event checksum while writing to binlog.
688 */
690 /**
691 Index in @c rli->gaq array to indicate a group that this event is
692 purging. The index is set by Coordinator to a group terminator
693 event is checked by Worker at the event execution. The indexed
694 data represent the Worker progress status.
695 */
696 ulong mts_group_idx;
697
698 /**
699 The Log_event_header class contains the variable present
700 in the common header
701 */
703
704 /**
705 The Log_event_footer class contains the variable present
706 in the common footer. Currently, footer contains only the checksum_alg.
707 */
709 /**
710 MTS: associating the event with either an assigned Worker or Coordinator.
711 Additionally the member serves to tag deferred (IRU) events to avoid
712 the event regular time destruction.
713 */
715
716 /**
717 A copy of the main rli value stored into event to pass to MTS worker rli
718 */
720
721 /**
722 When requested (m_claim_at_destruction equal to true), will claim
723 memory ownership before Log_event destruction
724 */
725 bool m_claim_at_destruction{false};
727#ifdef MYSQL_SERVER
728 THD *thd;
729 /**
730 Partition info associate with event to deliver to MTS event applier
731 */
732 db_worker_hash_entry *mts_assigned_partitions[MAX_DBS_IN_EVENT_MTS];
733
736 enum_event_cache_type cache_type_arg,
737 enum_event_logging_type logging_type_arg);
738 Log_event(THD *thd_arg, uint16 flags_arg,
739 enum_event_cache_type cache_type_arg,
740 enum_event_logging_type logging_type_arg,
743 /*
744 init_show_field_list() prepares the column names and types for the
745 output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
746 EVENTS.
747 */
748 static void init_show_field_list(mem_root_deque<Item *> *field_list);
749
750 int net_send(Protocol *protocol, const char *log_name, my_off_t pos);
751
752 /**
753 Stores a string representation of this event in the Protocol.
754 This is used by SHOW BINLOG EVENTS.
755
756 @retval 0 success
757 @retval nonzero error
758 */
759 virtual int pack_info(Protocol *protocol);
760
761 virtual const char *get_db();
762#else // ifdef MYSQL_SERVER
763 /* print*() functions are used by mysqlbinlog */
764 virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const = 0;
765 void print_timestamp(IO_CACHE *file, time_t *ts) const;
766 void print_header(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info,
767 bool is_more) const;
768 void print_base64(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info,
769 bool is_more) const;
770#endif // ifdef MYSQL_SERVER ... else
771
772 void *operator new(size_t size);
773
774 static void operator delete(void *ptr, size_t) { my_free(ptr); }
776 /* Placement version of the above operators */
777 static void *operator new(size_t, void *ptr) { return ptr; }
778 static void operator delete(void *, void *) {}
779 /**
780 Write the given buffer to the given output stream, updating the
781 checksum if checksums are enabled.
782
783 @param ostream The output stream to write to.
784 @param buf The buffer to write.
785 @param data_length The number of bytes to write.
786
787 @retval false Success.
788 @retval true Error.
789 */
790 bool wrapper_my_b_safe_write(Basic_ostream *ostream, const uchar *buf,
791 size_t data_length);
793#ifdef MYSQL_SERVER
794 virtual bool write(Basic_ostream *ostream) {
795 return (write_header(ostream, get_data_size()) ||
796 write_data_header(ostream) || write_data_body(ostream) ||
797 write_footer(ostream));
798 }
799
800 time_t get_time();
802 virtual bool write_data_header(Basic_ostream *) { return false; }
803 virtual bool write_data_body(Basic_ostream *) { return false; }
804#endif
805
807 return common_header->type_code;
808 }
809
810 /**
811 Return true if the event has to be logged using SBR for DMLs.
812 */
813 virtual bool is_sbr_logging_format() const { return false; }
814 /**
815 Return true if the event has to be logged using RBR for DMLs.
816 */
817 virtual bool is_rbr_logging_format() const { return false; }
818
819 /*
820 is_valid is event specific sanity checks to determine that the
821 object is correctly initialized.
822 */
823 bool is_valid();
824 void set_artificial_event() {
826 /*
827 Artificial events are automatically generated and do not exist
828 in master's binary log, so log_pos should be set to 0.
829 */
833 bool is_artificial_event() const {
835 }
836 bool is_relay_log_event() const {
838 }
839 bool is_ignorable_event() const {
841 }
842 bool is_no_filter_event() const {
844 }
845 inline bool is_using_trans_cache() const {
847 }
848 inline bool is_using_stmt_cache() const {
850 }
851 inline bool is_using_immediate_logging() const {
853 }
854
855 /*
856 For the events being decoded in BAPI, common_header should
857 point to the header object which is contained within the class
858 Binary_log_event.
859 */
862
863 /**
864 Allow thread to CLAIM or DISCLAIM the ownership of this object
865 depends on the parameter value passed
866
867 @param claim
868 True - claim ownership of the memory
869 False - disclaim ownership of the memory
870 */
871 virtual void claim_memory_ownership([[maybe_unused]] bool claim) {}
872
873 /**
874 When requested (claim equal to true), will claim
875 memory ownership before Log_event destruction
876
877 @param claim
878 True - claim ownership before destruction
879 False - do nothing before destruction
880 */
881 void claim_at_destruction(bool claim) { m_claim_at_destruction = claim; }
883 virtual ~Log_event() { free_temp_buf(); }
884 void register_temp_buf(char *buf, bool free_in_destructor = true) {
885 m_free_temp_buf_in_destructor = free_in_destructor;
887 }
888 void free_temp_buf() {
891 }
892 if (temp_buf) {
894 temp_buf = nullptr;
895 }
896 }
897 /*
898 Get event length for simple events. For complicated events the length
899 is calculated during write()
900 */
901 virtual size_t get_data_size() { return 0; }
902 /**
903 Returns the human readable name of the given event type.
904 */
906 /// Get the name of an event type, or "Unknown" if out of range.
907 /// @param type The type as an int
908 /// @retval name of an event type, if it is one
909 /// @retval "Unknown" if the value is out of range
910 static const char *get_type_str(uint type);
911 /**
912 Returns the human readable name of this event's type.
913 */
914 const char *get_type_str() const;
915 /* Return start of query time or current time */
916
917#if defined(MYSQL_SERVER)
918 /**
919 Is called from get_mts_execution_mode() to
920
921 @return true if the event needs applying with synchronization
922 against Workers, otherwise
923 false
924
925 @note There are incompatile combinations such as referred further events
926 are wrapped with BEGIN/COMMIT. Such cases should be identified
927 by the caller and treats correspondingly.
928
929 todo: to mts-support Old master Load-data related events
930 */
931 bool is_mts_sequential_exec() const {
934
935 static bool is_mts_sequential_exec(
937 switch (type_code) {
943 return true;
944 default:
945 return false;
946 }
947 }
948
949 /*
950 possible decisions by get_mts_execution_mode().
951 The execution mode can be PARALLEL or not (thereby sequential
952 unless impossible at all). When it's sequential it further breaks into
953 ASYNChronous and SYNChronous.
954 */
956 /*
957 Event is run by a Worker.
958 */
960 /*
961 Event is run by Coordinator.
962 */
964 /*
965 Event is run by Coordinator and requires synchronization with Workers.
966 */
968 /*
969 Event can't be executed neither by Workers nor Coordinator.
970 */
972 };
973
975 bool mts_in_group, mysql::binlog::event::Log_event_type type_code,
976 uint32 server_id, uint32 log_pos) {
977 /*
978 Slave workers are unable to handle Format_description_log_event,
979 Rotate_log_event and Previous_gtids_log_event correctly.
980 However, when a transaction spans multiple relay logs, these
981 events occur in the middle of a transaction. The way we handle
982 this is by marking the events as 'ASYNC', meaning that the
983 coordinator thread will handle the events without stopping the
984 worker threads.
985
986 @todo Refactor this: make Log_event::get_slave_worker handle
987 transaction boundaries in a more robust way, so that it is able
988 to process Format_description_log_event, Rotate_log_event, and
989 Previous_gtids_log_event. Then, when these events occur in the
990 middle of a transaction, make them part of the transaction so
991 that the worker that handles the transaction handles these
992 events too. /Sven
993 */
994 if (
995 /*
996 When a Format_description_log_event occurs in the middle of
997 a transaction, it either has the slave's server_id, or has
998 end_log_pos==0.
999
1000 @todo This does not work when master and slave have the same
1001 server_id and replicate-same-server-id is enabled, since
1002 events that are not in the middle of a transaction will be
1003 executed in ASYNC mode in that case.
1004 */
1006 ((server_id == (uint32)::server_id) || (log_pos == 0))) ||
1007 /*
1008 All Previous_gtids_log_events in the relay log are generated
1009 by the slave. They don't have any meaning to the applier, so
1010 they can always be ignored by the applier. So we can process
1011 them asynchronously by the coordinator. It is also important
1012 to not feed them to workers because that confuses
1013 get_slave_worker.
1014 */
1016 /*
1017 Rotate_log_event can occur in the middle of a transaction.
1018 When this happens, either it is a Rotate event generated on
1019 the slave which has the slave's server_id, or it is a Rotate
1020 event that originates from a master but has end_log_pos==0.
1021 */
1022 (type_code == mysql::binlog::event::ROTATE_EVENT &&
1023 ((server_id == (uint32)::server_id) ||
1024 (log_pos == 0 && mts_in_group))))
1025 return EVENT_EXEC_ASYNC;
1026 else if (is_mts_sequential_exec(type_code))
1027 return EVENT_EXEC_SYNC;
1028 else
1029 return EVENT_EXEC_PARALLEL;
1030 }
1031
1032 private:
1033 /**
1034 MTS Coordinator finds out a way how to execute the current event.
1035
1036 Besides the parallelizable case, some events have to be applied by
1037 Coordinator concurrently with Workers and some to require synchronization
1038 with Workers (@c see wait_for_workers_to_finish) before to apply them.
1039
1040 @param mts_in_group the being group parsing status, true
1041 means inside the group
1042
1043 @retval EVENT_EXEC_PARALLEL if event is executed by a Worker
1044 @retval EVENT_EXEC_ASYNC if event is executed by Coordinator
1045 @retval EVENT_EXEC_SYNC if event is executed by Coordinator
1046 with synchronization against the Workers
1047 */
1048 enum enum_mts_event_exec_mode get_mts_execution_mode(bool mts_in_group) {
1049 return get_mts_execution_mode(mts_in_group, get_type_code(), server_id,
1051 }
1052
1053 /**
1054 @return index in [0, M] range to indicate
1055 to be assigned worker;
1056 M is the max index of the worker pool.
1057 */
1059
1060 /*
1061 Group of events can be marked to force its execution
1062 in isolation from any other Workers.
1063 Typically that is done for a transaction that contains
1064 a query accessing more than OVER_MAX_DBS_IN_EVENT_MTS databases.
1065 Factually that's a sequential mode where a Worker remains to
1066 be the applier.
1067 */
1068 virtual void set_mts_isolate_group() {
1069 assert(ends_group() ||
1073 }
1074
1075 public:
1076 /**
1077 The method fills in pointers to event's database name c-strings
1078 to a supplied array.
1079 In other than Query-log-event case the returned array contains
1080 just one item.
1081 @param[out] arg pointer to a struct containing char* array
1082 pointers to be filled in and the number
1083 of filled instances.
1084 @param rpl_filter pointer to a replication filter.
1085
1086 @return number of the filled instances indicating how many
1087 databases the event accesses.
1088 */
1089 virtual uint8 get_mts_dbs(Mts_db_names *arg,
1090 Rpl_filter *rpl_filter [[maybe_unused]]) {
1091 arg->name[0] = get_db();
1092
1093 return arg->num = mts_number_dbs();
1094 }
1095
1096 /*
1097 @return the number of updated by the event databases.
1098
1099 @note In other than Query-log-event case that's one.
1100 */
1101 virtual uint8 mts_number_dbs() { return 1; }
1102
1103 /**
1104 @return true if the terminal event of a group is marked to
1105 execute in isolation from other Workers,
1106 false otherwise
1107 */
1108 bool is_mts_group_isolated() {
1110 }
1111
1112 /**
1113 Events of a certain type can start or end a group of events treated
1114 transactionally wrt binlog.
1115
1116 Public access is required by implementation of recovery + skip.
1117
1118 @return true if the event starts a group (transaction)
1119 false otherwise
1121#endif
1122 virtual bool starts_group() const { return false; }
1123 /**
1124 @return true if the event ends a group (transaction)
1125 false otherwise
1126 */
1127 virtual bool ends_group() const { return false; }
1128#ifdef MYSQL_SERVER
1129 /**
1130 Apply the event to the database.
1131
1132 This function represents the public interface for applying an
1133 event.
1134
1135 @see do_apply_event
1136 */
1137 int apply_event(Relay_log_info *rli);
1138
1139 /// @brief Applier_context Current applier context, attached to the agent
1141
1142 /**
1143 Apply the GTID event in curr_group_data to the database.
1144
1145 @param rli Pointer to coordinato's relay log info.
1146
1147 @retval 0 success
1148 @retval 1 error
1149 */
1150 inline int apply_gtid_event(Relay_log_info *rli);
1151
1152 /**
1153 Update the relay log position.
1154
1155 This function represents the public interface for "stepping over"
1156 the event and will update the relay log information.
1157
1158 @see do_update_pos
1159 */
1160 int update_pos(Relay_log_info *rli) { return do_update_pos(rli); }
1161
1162 /**
1163 Decide if the event shall be skipped, and the reason for skipping
1164 it.
1165
1166 @see do_shall_skip
1167 */
1169 DBUG_TRACE;
1171 DBUG_PRINT("info", ("skip reason=%d=%s", ret,
1172 ret == EVENT_SKIP_NOT ? "NOT"
1173 : ret == EVENT_SKIP_IGNORE ? "IGNORE"
1174 : "COUNT"));
1175 return ret;
1176 }
1177
1178 /**
1179 Primitive to apply an event to the database.
1180
1181 This is where the change to the database is made.
1182
1183 @note The primitive is protected instead of private, since there
1184 is a hierarchy of actions to be performed in some cases.
1185
1186 @see Format_description_log_event::do_apply_event()
1187
1188 @param rli Pointer to relay log info structure
1189
1190 @retval 0 Event applied successfully
1191 @retval errno Error code if event application failed
1192 */
1193 virtual int do_apply_event(Relay_log_info const *rli [[maybe_unused]]) {
1194 return 0; /* Default implementation does nothing */
1195 }
1196
1197 virtual int do_apply_event_worker(Slave_worker *w);
1198
1199 protected:
1200 /**
1201 Helper function to ignore an event w.r.t. the slave skip counter.
1202
1203 This function can be used inside do_shall_skip() for functions
1204 that cannot end a group. If the slave skip counter is 1 when
1205 seeing such an event, the event shall be ignored, the counter
1206 left intact, and processing continue with the next event.
1207
1208 A typical usage is:
1209 @code
1210 enum_skip_reason do_shall_skip(Relay_log_info *rli) {
1211 return continue_group(rli);
1212 }
1213 @endcode
1214
1215 @return Skip reason
1216 */
1218
1219 /**
1220 Advance relay log coordinates.
1221
1222 This function is called to advance the relay log coordinates to
1223 just after the event. It is essential that both the relay log
1224 coordinate and the group log position is updated correctly, since
1225 this function is used also for skipping events.
1226
1227 Normally, each implementation of do_update_pos() shall:
1228
1229 - Update the event position to refer to the position just after
1230 the event.
1231
1232 - Update the group log position to refer to the position just
1233 after the event <em>if the event is last in a group</em>
1234
1235 @param rli Pointer to relay log info structure
1236
1237 @retval 0 Coordinates changed successfully
1238 @retval errno Error code if advancing failed (usually just
1239 1). Observe that handler errors are returned by the
1240 do_apply_event() function, and not by this one.
1241 */
1242 virtual int do_update_pos(Relay_log_info *rli);
1243
1244 /**
1245 Decide if this event shall be skipped or not and the reason for
1246 skipping it.
1247
1248 The default implementation decide that the event shall be skipped
1249 if either:
1250
1251 - the server id of the event is the same as the server id of the
1252 server and <code>rli->replicate_same_server_id</code> is true,
1253 or
1254
1255 - if <code>rli->slave_skip_counter</code> is greater than zero.
1256
1257 @see do_apply_event
1258 @see do_update_pos
1259
1260 @retval Log_event::EVENT_SKIP_NOT
1261 The event shall not be skipped and should be applied.
1262
1263 @retval Log_event::EVENT_SKIP_IGNORE
1264 The event shall be skipped by just ignoring it, i.e., the slave
1265 skip counter shall not be changed. This happends if, for example,
1266 the originating server id of the event is the same as the server
1267 id of the slave.
1268
1269 @retval Log_event::EVENT_SKIP_COUNT
1270 The event shall be skipped because the slave skip counter was
1271 non-zero. The caller shall decrease the counter by one.
1272 */
1274#endif
1275};
1276
1277/*
1278 One class for each type of event.
1279 Two constructors for each class:
1280 - one to create the event for logging (when the server acts as a master),
1281 called after an update to the database is done,
1282 which accepts parameters like the query, the database, the options for LOAD
1283 DATA INFILE...
1284 - one to create the event from a packet (when the server acts as a slave),
1285 called before reproducing the update, which accepts parameters (like a
1286 buffer). Used to read from the master, from the relay log, and in
1287 mysqlbinlog. This constructor must be format-tolerant.
1288*/
1289
1290/**
1291 A Query event is written to the binary log whenever the database is
1292 modified on the master, unless row based logging is used.
1293
1294 Query_log_event is created for logging, and is called after an update to the
1295 database is done. It is used when the server acts as the master.
1296
1297 Virtual inheritance is required here to handle the diamond problem in
1298 the class @c Execute_load_query_log_event.
1299 The diamond structure is explained in @c Excecute_load_query_log_event
1300
1301 @internal
1302 The inheritance structure is as follows:
1303
1304 Binary_log_event
1305 ^
1306 |
1307 |
1308 Query_event Log_event
1309 \ /
1310 <<virtual>>\ /
1311 \ /
1312 Query_log_event
1313 @endinternal
1314*/
1316 public Log_event {
1317 protected:
1319
1320 public:
1321 // disable copy-move semantics
1324 Query_log_event(const Query_log_event &) = delete;
1325 Query_log_event &operator=(const Query_log_event &) = delete;
1326
1327 /*
1328 For events created by Query_log_event::do_apply_event (and
1329 Load_log_event::do_apply_event()) we need the *original* thread
1330 id, to be able to log the event with the original (=master's)
1331 thread id (fix for BUG#1686).
1332 */
1334
1335 /**
1336 True if this is a ROLLBACK event injected by the mts coordinator to finish a
1337 group corresponding to a partial transaction in the relay log.
1338 False otherwise and by default, as it must be explicitly set to true by the
1339 coordinator.
1340 */
1341 bool rollback_injected_by_coord = false;
1342
1343 /**
1344 The flag indicates whether the DDL query has been (already)
1345 committed or not. It's initialized as OFF at the event instantiation,
1346 flips ON when the DDL transaction has been committed with
1347 all its possible extra statement due to replication or GTID.
1348
1349 The flag status is also checked in few places to catch uncommitted
1350 transactions which can normally happen due to filtering out. In
1351 such a case the commit is deferred to @c Log_event::do_update_pos().
1352 */
1353 bool has_ddl_committed;
1354
1355#ifdef MYSQL_SERVER
1356
1357 /**
1358 Instructs the applier to skip temporary tables handling.
1359 */
1361
1365
1368 }
1369
1370 Query_log_event(THD *thd_arg, const char *query_arg, size_t query_length,
1371 bool using_trans, bool immediate, bool suppress_use,
1372 int error, bool ignore_command = false);
1373 const char *get_db() override { return db; }
1374
1375 /**
1376 @param[out] arg pointer to a struct containing char* array
1377 pointers be filled in and the number of
1378 filled instances.
1379 In case the number exceeds MAX_DBS_IN_EVENT_MTS,
1380 the overfill is indicated with assigning the number to
1381 OVER_MAX_DBS_IN_EVENT_MTS.
1382 @param rpl_filter pointer to a replication filter.
1383
1384 @return number of databases in the array or OVER_MAX_DBS_IN_EVENT_MTS.
1385 */
1388 // the empty string db name is special to indicate sequential applying
1389 mts_accessed_db_names[0][0] = 0;
1390 } else {
1391 for (uchar i = 0; i < mts_accessed_dbs; i++) {
1392 const char *db_name = mts_accessed_db_names[i];
1393
1394 // Only default database is rewritten.
1395 if (!rpl_filter->is_rewrite_empty() && !strcmp(get_db(), db_name)) {
1396 size_t dummy_len;
1397 const char *db_filtered =
1398 rpl_filter->get_rewrite_db(db_name, &dummy_len);
1399 // db_name != db_filtered means that db_name is rewritten.
1400 if (strcmp(db_name, db_filtered)) db_name = db_filtered;
1401 }
1402 arg->name[i] = db_name;
1403 }
1404 }
1405 return arg->num = mts_accessed_dbs;
1406 }
1407
1410
1411 uchar mts_number_dbs() override { return mts_accessed_dbs; }
1412
1413 int pack_info(Protocol *protocol) override;
1414#else
1415 void print_query_header(IO_CACHE *file,
1416 PRINT_EVENT_INFO *print_event_info) const;
1417 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1418 static bool rewrite_db_in_buffer(
1419 char **buf, ulong *event_len,
1421#endif
1422
1424
1426 const char *buf,
1429 ~Query_log_event() override {
1431 }
1432
1433 void claim_memory_ownership(bool claim) override;
1434
1435#ifdef MYSQL_SERVER
1436 bool write(Basic_ostream *ostream) override;
1437 virtual bool write_post_header_for_derived(Basic_ostream *) { return false; }
1438#endif
1439
1440 /*
1441 Returns number of bytes additionally written to post header by derived
1442 events (so far it is only Execute_load_query event).
1443 */
1444 virtual ulong get_post_header_size_for_derived() { return 0; }
1445 /* Writes derived event-specific part of post header. */
1446
1447 public: /* !!! Public in this patch to allow old usage */
1448#if defined(MYSQL_SERVER)
1450 int do_apply_event(Relay_log_info const *rli) override;
1451 int do_update_pos(Relay_log_info *rli) override;
1452
1453 int do_apply_event(Relay_log_info const *rli, const char *query_arg,
1454 size_t q_len_arg);
1455#endif /* MYSQL_SERVER */
1456 /*
1457 If true, the event always be applied by slave SQL thread or be printed by
1458 mysqlbinlog
1459 */
1460 bool is_trans_keyword() const {
1461 /*
1462 Before the patch for bug#50407, The 'SAVEPOINT and ROLLBACK TO'
1463 queries input by user was written into log events directly.
1464 So the keywords can be written in both upper case and lower case
1465 together, strncasecmp is used to check both cases. they also could be
1466 binlogged with comments in the front of these keywords. for examples:
1467 / * bla bla * / SAVEPOINT a;
1468 / * bla bla * / ROLLBACK TO a;
1469 but we don't handle these cases and after the patch, both quiries are
1470 binlogged in upper case with no comments.
1471 */
1472 return !strncmp(query, "BEGIN", q_len) ||
1473 !strncmp(query, "COMMIT", q_len) ||
1474 !native_strncasecmp(query, "SAVEPOINT", 9) ||
1475 !native_strncasecmp(query, "ROLLBACK", 8) ||
1476 !native_strncasecmp(query, STRING_WITH_LEN("XA START")) ||
1478 !native_strncasecmp(query, STRING_WITH_LEN("XA PREPARE")) ||
1479 !native_strncasecmp(query, STRING_WITH_LEN("XA COMMIT")) ||
1480 !native_strncasecmp(query, STRING_WITH_LEN("XA ROLLBACK"));
1481 }
1482
1483 /**
1484 When a query log event contains a non-transaction control statement, we
1485 assume that it is changing database content (DML) and was logged using
1486 binlog_format=statement.
1487
1488 @return True the event represents a statement that was logged using SBR
1489 that can change database content.
1490 False for transaction control statements.
1491 */
1492 bool is_sbr_logging_format() const override { return !is_trans_keyword(); }
1493
1494 /**
1495 Notice, DDL queries are logged without BEGIN/COMMIT parentheses
1496 and identification of such single-query group
1497 occurs within logics of @c get_slave_worker().
1499
1500 bool starts_group() const override {
1501 return !strncmp(query, "BEGIN", q_len) ||
1502 !strncmp(query, STRING_WITH_LEN("XA START"));
1504
1505 bool ends_group() const override {
1506 return !strncmp(query, "COMMIT", q_len) ||
1507 (!native_strncasecmp(query, STRING_WITH_LEN("ROLLBACK")) &&
1508 native_strncasecmp(query, STRING_WITH_LEN("ROLLBACK TO "))) ||
1509 !strncmp(query, STRING_WITH_LEN("XA ROLLBACK"));
1510 }
1511 static size_t get_query(
1512 const char *buf, size_t length,
1514 const char **query_arg);
1515
1516 bool is_query_prefix_match(const char *pattern, uint p_len) {
1517 return !strncmp(query, pattern, p_len);
1518 }
1519
1520 /** Whether or not the statement represented by this event requires
1521 `Q_SQL_REQUIRE_PRIMARY_KEY` to be logged along aside. */
1522 bool need_sql_require_primary_key{false};
1523
1524 /** Whether or not the statement represented by this event requires
1525 `Q_DEFAULT_TABLE_ENCRYPTION` to be logged along aside. */
1527
1528 /** Whether or not the statement represented by this event requires
1529 `Q_ENABLE_CASCADE_TRIGGERS` to be logged along aside. */
1530 bool need_enable_cascade_triggers{false};
1531};
1532
1533/**
1534 @class Format_description_log_event
1535
1536 For binlog version 4.
1537 This event is saved by threads which read it, as they need it for future
1538 use (to decode the ordinary events).
1539 This is the subclass of Format_description_event
1540
1541 @internal
1542 The inheritance structure in the current design for the classes is
1543 as follows:
1544
1545 Binary_log_event
1546 ^
1547 |
1548 |
1549 Format_description_event Log_event
1550 \ /
1551 \ /
1552 \ /
1553 Format_description_log_event
1554 @endinternal
1555 @section Format_description_log_event_binary_format Binary Format
1557
1560 public Log_event {
1561 public:
1562 /*
1563 MTS Workers and Coordinator share the event and that affects its
1564 destruction. Instantiation is always done by Coordinator/SQL thread.
1565 Workers are allowed to destroy only "obsolete" instances, those
1566 that are not actual for Coordinator anymore but needed to Workers
1567 that are processing queued events depending on the old instance.
1568 The counter of a new FD is incremented by Coordinator or Worker at
1569 time of {Relay_log_info,Slave_worker}::set_rli_description_event()
1570 execution.
1571 In the same methods the counter of the "old" FD event is decremented
1572 and when it drops to zero the old FD is deleted.
1573 The latest read from relay-log event is to be
1574 destroyed by Coordinator/SQL thread at its thread exit.
1575 Notice the counter is processed even in the single-thread mode where
1576 decrement and increment are done by the single SQL thread.
1577 */
1578 std::atomic<int32> atomic_usage_counter{0};
1579
1582 const char *buf,
1583 const mysql::binlog::event::Format_description_event *description_event);
1584#ifdef MYSQL_SERVER
1585 bool write(Basic_ostream *ostream) override;
1586 int pack_info(Protocol *protocol) override;
1587#else
1588 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1589#endif
1590
1591 size_t get_data_size() override {
1592 /*
1593 The vector of post-header lengths is considered as part of the
1594 post-header, because in a given version it never changes (contrary to the
1595 query in a Query_log_event).
1596 */
1599 }
1600
1601 void claim_memory_ownership(bool claim) override;
1602
1603 protected:
1604#if defined(MYSQL_SERVER)
1605 int do_apply_event(Relay_log_info const *rli) override;
1606 int do_update_pos(Relay_log_info *rli) override;
1608#endif
1609};
1610
1611/**
1612 @class Intvar_log_event
1613
1614 The class derives from the class Intvar_event in Binlog API,
1615 defined in the header binlog_event.h. An Intvar_log_event is
1616 created just before a Query_log_event, if the query uses one
1617 of the variables LAST_INSERT_ID or INSERT_ID. This class is used
1618 by the slave for applying the event.
1619
1620 @internal
1621 The inheritance structure in the current design for the classes is
1622 as follows:
1623
1624 Binary_log_event
1625 ^
1626 |
1627 |
1628 Intvar_event Log_event
1629 \ /
1630 \ /
1631 \ /
1632 Intvar_log_event
1633 @endinternal
1634*/
1636 public Log_event {
1637 public:
1638 // disable copy-move semantics
1641 Intvar_log_event(const Intvar_log_event &) = delete;
1642 Intvar_log_event &operator=(const Intvar_log_event &) = delete;
1644#ifdef MYSQL_SERVER
1645 Intvar_log_event(THD *thd_arg, uchar type_arg, ulonglong val_arg,
1646 enum_event_cache_type cache_type_arg,
1647 enum_event_logging_type logging_type_arg)
1648 : mysql::binlog::event::Intvar_event(type_arg, val_arg),
1649 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1650 footer()) {
1652 }
1653 int pack_info(Protocol *protocol) override;
1654#else
1655 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1656#endif
1657
1659 const char *buf,
1660 const mysql::binlog::event::Format_description_event *description_event);
1661 ~Intvar_log_event() override = default;
1662
1663 void claim_memory_ownership(bool claim) override;
1664
1665 size_t get_data_size() override {
1666 return 9; /* sizeof(type) + sizeof(val) */
1667 ;
1668 }
1669#ifdef MYSQL_SERVER
1670 bool write(Basic_ostream *ostream) override;
1671#endif
1672
1673 bool is_sbr_logging_format() const override { return true; }
1674
1675 private:
1676#if defined(MYSQL_SERVER)
1677 int do_apply_event(Relay_log_info const *rli) override;
1678 int do_update_pos(Relay_log_info *rli) override;
1680#endif
1681};
1682
1683/**
1684 @class Rand_log_event
1685
1686 Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
1687 4.1.1 does not need it (it's repeatable again) so this event needn't be
1688 written in 4.1.1 for PASSWORD() (but the fact that it is written is just a
1689 waste, it does not cause bugs).
1690
1691 The state of the random number generation consists of 128 bits,
1692 which are stored internally as two 64-bit numbers.
1693
1694 @internal
1695 The inheritance structure in the current design for the classes is
1696 as follows:
1697 Binary_log_event
1698 ^
1699 |
1700 |
1701 Rand_event Log_event
1702 \ /
1703 \ /
1704 \ /
1705 Rand_log_event
1706 @endinternal
1707*/
1709 public Log_event {
1710 public:
1711 // disable copy-move semantics
1713 Rand_log_event &operator=(Rand_log_event &&) noexcept = delete;
1714 Rand_log_event(const Rand_log_event &) = delete;
1715 Rand_log_event &operator=(const Rand_log_event &) = delete;
1717#ifdef MYSQL_SERVER
1718 Rand_log_event(THD *thd_arg, ulonglong seed1_arg, ulonglong seed2_arg,
1719 enum_event_cache_type cache_type_arg,
1720 enum_event_logging_type logging_type_arg)
1721 : mysql::binlog::event::Rand_event(seed1_arg, seed2_arg),
1722 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1723 footer()) {
1725 }
1726 int pack_info(Protocol *protocol) override;
1727#else
1728 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1729#endif
1730
1732 const char *buf,
1733 const mysql::binlog::event::Format_description_event *description_event);
1734 ~Rand_log_event() override = default;
1735
1736 void claim_memory_ownership(bool claim) override;
1737
1738 size_t get_data_size() override { return 16; /* sizeof(ulonglong) * 2*/ }
1739#ifdef MYSQL_SERVER
1740 bool write(Basic_ostream *ostream) override;
1741#endif
1742
1743 bool is_sbr_logging_format() const override { return true; }
1744
1745 private:
1746#if defined(MYSQL_SERVER)
1747 int do_apply_event(Relay_log_info const *rli) override;
1748 int do_update_pos(Relay_log_info *rli) override;
1750#endif
1751};
1752
1753/**
1754 @class Xid_log_event
1755
1756 This is the subclass of Xid_event defined in libbinlogevent,
1757 An XID event is generated for a commit of a transaction that modifies one or
1758 more tables of an XA-capable storage engine
1759 Logs xid of the transaction-to-be-committed in the 2pc protocol.
1760 Has no meaning in replication, slaves ignore it
1761 The inheritance structure in the current design for the classes is
1762 as follows
1763
1764 @internal
1765 The inheritance structure in the current design for the classes is
1766 as follows:
1767 Binary_log_event
1768 ^
1769 |
1770 |
1771 Xid_event Log_event
1772 \ /
1773 \ /
1774 \ /
1775 Xid_log_event
1776 @endinternal
1777*/
1778#ifndef MYSQL_SERVER
1779typedef ulonglong my_xid; // this line is the same as in handler.h
1780#endif
1781
1782class Xid_apply_log_event : public Log_event {
1783 protected:
1784#ifdef MYSQL_SERVER
1785 Xid_apply_log_event(THD *thd_arg,
1789 Log_event::EVENT_NORMAL_LOGGING, header_arg, footer_arg) {}
1790#endif
1793 : Log_event(header_arg, footer_arg) {}
1794 ~Xid_apply_log_event() override = default;
1795 bool ends_group() const override { return true; }
1796#if defined(MYSQL_SERVER)
1798 int do_apply_event(Relay_log_info const *rli) override;
1799 int do_apply_event_worker(Slave_worker *rli) override;
1800 virtual bool do_commit(THD *thd_arg) = 0;
1801#endif
1803
1805 public Xid_apply_log_event {
1806 public:
1807 // disable copy-move semantics
1809 Xid_log_event &operator=(Xid_log_event &&) noexcept = delete;
1810 Xid_log_event(const Xid_log_event &) = delete;
1811 Xid_log_event &operator=(const Xid_log_event &) = delete;
1813#ifdef MYSQL_SERVER
1814 Xid_log_event(THD *thd_arg, my_xid x)
1815 : mysql::binlog::event::Xid_event(x),
1816 Xid_apply_log_event(thd_arg, header(), footer()) {
1818 }
1819 int pack_info(Protocol *protocol) override;
1820#else
1821 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1822#endif
1823
1825 const char *buf,
1826 const mysql::binlog::event::Format_description_event *description_event);
1827 ~Xid_log_event() override = default;
1828
1829 void claim_memory_ownership(bool claim) override;
1830
1831 size_t get_data_size() override { return sizeof(xid); }
1832#ifdef MYSQL_SERVER
1833 bool write(Basic_ostream *ostream) override;
1834#endif
1835 private:
1836#if defined(MYSQL_SERVER)
1837 bool do_commit(THD *thd_arg) override;
1838#endif
1839};
1840
1841/**
1842 @class XA_prepare_log_event
1843
1844 Similar to Xid_log_event except that
1845 - it is specific to XA transaction
1846 - it carries out the prepare logics rather than the final committing
1847 when @c one_phase member is off.
1848 From the groupping perspective the event finalizes the current "prepare" group
1849 started with XA START Query-log-event.
1850 When @c one_phase is false Commit of Rollback for XA transaction are
1851 logged separately to the prepare-group events so being a groups of
1852 their own.
1854
1856 public Xid_apply_log_event {
1857 private:
1858 /* Total size of buffers to hold serialized members of XID struct */
1859 static const int xid_bufs_size = 12;
1860
1861 public:
1862#ifdef MYSQL_SERVER
1863 XA_prepare_log_event(THD *thd_arg, XID *xid_arg, bool one_phase_arg = false)
1864 : mysql::binlog::event::XA_prepare_event((void *)xid_arg, one_phase_arg),
1866#endif
1868 const char *buf,
1869 const mysql::binlog::event::Format_description_event *description_event)
1870 : mysql::binlog::event::XA_prepare_event(buf, description_event),
1872 DBUG_TRACE;
1873 xid = nullptr;
1874 return;
1875 }
1878 }
1879 size_t get_data_size() override {
1880 return xid_bufs_size + my_xid.gtrid_length + my_xid.bqual_length;
1881 }
1882
1883 void claim_memory_ownership(bool claim) override;
1884
1885#ifdef MYSQL_SERVER
1886 bool write(Basic_ostream *ostream) override;
1887#else
1888 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1889#endif
1890#if defined(MYSQL_SERVER)
1891 int pack_info(Protocol *protocol) override;
1892 bool do_commit(THD *thd) override;
1893#endif
1894};
1895
1896/**
1897 @class User_var_log_event
1898
1899 Every time a query uses the value of a user variable, a User_var_log_event is
1900 written before the Query_log_event, to set the user variable.
1901
1902 @internal
1903 The inheritance structure in the current design for the classes is
1904 as follows:
1905 Binary_log_event
1906 ^
1907 |
1908 |
1909 User_var_event Log_event
1910 \ /
1911 \ /
1912 \ /
1913 User_var_log_event
1914 @endinternal
1915*/
1917 public Log_event {
1918 public:
1919 // disable copy-move semantics
1922 User_var_log_event(const User_var_log_event &) = delete;
1923 User_var_log_event &operator=(const User_var_log_event &) = delete;
1925#ifdef MYSQL_SERVER
1928 User_var_log_event(THD *thd_arg, const char *name_arg, uint name_len_arg,
1929 char *val_arg, ulong val_len_arg, Item_result type_arg,
1930 uint charset_number_arg, uchar flags_arg,
1931 enum_event_cache_type cache_type_arg,
1932 enum_event_logging_type logging_type_arg)
1933 : mysql::binlog::event::User_var_event(name_arg, name_len_arg, val_arg,
1934 val_len_arg, type_arg,
1935 charset_number_arg, flags_arg),
1936 Log_event(thd_arg, 0, cache_type_arg, logging_type_arg, header(),
1937 footer()),
1938 deferred(false) {
1939 common_header->set_is_valid(name != nullptr);
1940 }
1941 int pack_info(Protocol *protocol) override;
1942#else
1943 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
1944#endif
1945
1947 const char *buf,
1948 const mysql::binlog::event::Format_description_event *description_event);
1949 ~User_var_log_event() override = default;
1950
1951 void claim_memory_ownership(bool claim) override;
1952
1953#ifdef MYSQL_SERVER
1954 bool write(Basic_ostream *ostream) override;
1955 /*
1956 Getter and setter for deferred User-event.
1957 Returns true if the event is not applied directly
1958 and which case the applier adjusts execution path.
1959 */
1960 bool is_deferred() { return deferred; }
1961 /*
1962 In case of the deferred applying the variable instance is flagged
1963 and the parsing time query id is stored to be used at applying time.
1964 */
1965 void set_deferred(query_id_t qid) {
1966 deferred = true;
1967 query_id = qid;
1968 }
1969#endif
1970
1971 bool is_sbr_logging_format() const override { return true; }
1972
1973 private:
1974#if defined(MYSQL_SERVER)
1975 int do_apply_event(Relay_log_info const *rli) override;
1976 int do_update_pos(Relay_log_info *rli) override;
1978#endif
1979};
1980
1981/**
1982 @class Stop_log_event
1984*/
1986 public Log_event {
1987 public:
1988 // disable copy-move semantics
1990 Stop_log_event &operator=(Stop_log_event &&) noexcept = delete;
1991 Stop_log_event(const Stop_log_event &) = delete;
1992 Stop_log_event &operator=(const Stop_log_event &) = delete;
1994#ifdef MYSQL_SERVER
1999 }
2000
2001#else
2002 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2003#endif
2004
2006 const char *buf,
2007 const mysql::binlog::event::Format_description_event *description_event)
2008 : mysql::binlog::event::Stop_event(buf, description_event),
2009 Log_event(header(), footer()) {
2010 DBUG_TRACE;
2011 return;
2014 ~Stop_log_event() override = default;
2017 }
2018
2019 void claim_memory_ownership(bool claim) override;
2020
2021 private:
2022#if defined(MYSQL_SERVER)
2023 int do_update_pos(Relay_log_info *rli) override;
2025 /*
2026 Events from ourself should be skipped, but they should not
2027 decrease the slave skip counter.
2028 */
2029 if (this->server_id == ::server_id)
2031 else
2033 }
2034#endif
2035};
2036
2037/**
2038 @class Rotate_log_event
2039
2040 This will be deprecated when we move to using sequence ids.
2041 This class is a subclass of Rotate_event, defined in binlogevent, and is used
2042 by the slave for updating the position in the relay log.
2043
2044 It is used by the master inorder to write the rotate event in the binary log.
2045
2046 @internal
2047 The inheritance structure in the current design for the classes is
2048 as follows:
2049
2050 Binary_log_event
2051 ^
2052 |
2053 |
2054 Rotate_event Log_event
2055 \ /
2056 \ /
2057 \ /
2058 Rotate_log_event
2059 @endinternal
2060*/
2062 public Log_event {
2063 public:
2064 // disable copy-move semantics
2067 Rotate_log_event(const Rotate_log_event &) = delete;
2068 Rotate_log_event &operator=(const Rotate_log_event &) = delete;
2069
2070#ifdef MYSQL_SERVER
2071 Rotate_log_event(const char *new_log_ident_arg, size_t ident_len_arg,
2072 ulonglong pos_arg, uint flags);
2073 int pack_info(Protocol *protocol) override;
2074#else
2075 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2076#endif
2077
2079 const char *buf,
2081 ~Rotate_log_event() override = default;
2082 size_t get_data_size() override {
2083 return ident_len +
2085 }
2086
2087 void claim_memory_ownership(bool claim) override;
2088
2089#ifdef MYSQL_SERVER
2090 bool write(Basic_ostream *ostream) override;
2091#endif
2092
2093 private:
2094#if defined(MYSQL_SERVER)
2095 int do_update_pos(Relay_log_info *rli) override;
2097#endif
2098};
2099
2100/**
2101 @class Append_block_log_event
2102
2103 This event is created to contain the file data. One LOAD_DATA_INFILE
2104 can have 0 or more instances of this event written to the binary log
2105 depending on the size of the file.
2106
2107 @internal
2108 The inheritance structure is as follows
2109
2110 Binary_log_event
2111 ^
2112 |
2113 |
2114 B_l:A_B_E Log_event
2115 \ /
2116 \ /
2117 <<vir>>\ /
2118 \ /
2119 Append_block_log_event
2120 B_l: Namespace Binary_log
2121 A_B_E: class Append_block_event
2122 @endinternal
2124*/
2127 public Log_event {
2128 public:
2129 // disable copy-move semantics
2132 delete;
2134 Append_block_log_event &operator=(const Append_block_log_event &) = delete;
2135
2136#ifdef MYSQL_SERVER
2137 Append_block_log_event(THD *thd, const char *db_arg, uchar *block_arg,
2138 uint block_len_arg, bool using_trans);
2139 int pack_info(Protocol *protocol) override;
2140 virtual int get_create_or_append() const;
2141#else
2142 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2143#endif
2144
2146 const char *buf,
2147 const mysql::binlog::event::Format_description_event *description_event);
2148 ~Append_block_log_event() override = default;
2149
2150 void claim_memory_ownership(bool claim) override;
2151
2152 size_t get_data_size() override {
2153 return block_len +
2155 }
2156#ifdef MYSQL_SERVER
2157 bool write(Basic_ostream *ostream) override;
2158 const char *get_db() override { return db; }
2159#endif
2160
2161 bool is_sbr_logging_format() const override { return true; }
2162
2163 private:
2164#if defined(MYSQL_SERVER)
2165 int do_apply_event(Relay_log_info const *rli) override;
2166#endif
2167};
2168
2169/**
2170 @class Delete_file_log_event
2171
2172 Delete_file_log_event is created when the LOAD_DATA query fails on the
2173 master for some reason, and the slave should be notified to abort the
2174 load. The event is required since the master starts writing the loaded
2175 block into the binary log before the statement ends. In case of error,
2176 the slave should abort, and delete any temporary file created while
2177 applying the (NEW_)LOAD_EVENT.
2178
2179 @internal
2180 The inheritance structure is as follows
2181
2182 Binary_log_event
2183 ^
2184 |
2185 |
2186 B_l:D_F_E Log_event
2187 \ /
2188 \ /
2189 \ /
2190 \ /
2191 Delete_file_log_event
2192
2193 B_l: Namespace Binary_log
2194 D_F_E: class Delete_file_event
2195 @endinternal
2197*/
2199 public Log_event {
2200 public:
2201 // disable copy-move semantics
2205 Delete_file_log_event &operator=(const Delete_file_log_event &) = delete;
2206
2207#ifdef MYSQL_SERVER
2208 Delete_file_log_event(THD *thd, const char *db_arg, bool using_trans);
2209 int pack_info(Protocol *protocol) override;
2210#else
2211 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2212 void print(FILE *file, PRINT_EVENT_INFO *print_event_info, bool enable_local);
2213#endif
2214
2216 const char *buf,
2217 const mysql::binlog::event::Format_description_event *description_event);
2218 ~Delete_file_log_event() override = default;
2219
2220 void claim_memory_ownership(bool claim) override;
2221
2222 size_t get_data_size() override {
2224 }
2225#ifdef MYSQL_SERVER
2226 bool write(Basic_ostream *ostream) override;
2227 const char *get_db() override { return db; }
2228#endif
2229
2230 bool is_sbr_logging_format() const override { return true; }
2231
2232 private:
2233#if defined(MYSQL_SERVER)
2234 int do_apply_event(Relay_log_info const *rli) override;
2235#endif
2236};
2237
2238/**
2239 @class Begin_load_query_log_event
2240
2241 Event for the first block of file to be loaded, its only difference from
2242 Append_block event is that this event creates or truncates existing file
2243 before writing data.
2244
2245 @internal
2246 The inheritance structure is as follows
2247
2248 Binary_log_event
2249 ^
2250 |
2251 |
2252 |
2253 Log_event B_l:A_B_E
2254 ^ /\
2255 | / \
2256 | <<vir>>/ \ <<vir>>
2257 | / \
2258 | / \
2259 | / \
2260 Append_block_log_event B_l:B_L_Q_E
2261 \ /
2262 \ /
2263 \ /
2264 \ /
2265 \ /
2266 Begin_load_query_log_event
2267
2268 B_l: Namespace Binary_log
2269 A_B_E: class Append_block_event
2270 B_L_Q_E: Begin_load_query_event
2271 @endinternal
2272
2273 @section Begin_load_query_log_event_binary_format Binary Format
2274*/
2276 : public Append_block_log_event,
2278 public:
2279 // disable copy-move semantics
2285 delete;
2286
2287#ifdef MYSQL_SERVER
2288 Begin_load_query_log_event(THD *thd_arg, const char *db_arg, uchar *block_arg,
2289 uint block_len_arg, bool using_trans);
2291 int get_create_or_append() const override;
2292#endif
2294 const char *buf,
2295 const mysql::binlog::event::Format_description_event *description_event);
2296 ~Begin_load_query_log_event() override = default;
2297
2298 void claim_memory_ownership(bool claim) override;
2299
2300 private:
2301#if defined(MYSQL_SERVER)
2303#endif
2304};
2305
2306/**
2307 @class Execute_load_query_log_event
2308
2309 Event responsible for LOAD DATA execution, it similar to Query_log_event
2310 but before executing the query it substitutes original filename in LOAD DATA
2311 query with name of temporary file.
2312
2313 @internal
2314 The inheritance structure is as follows:
2315
2316 Binary_log_event
2317 ^
2318 |
2319 |
2320 |
2321 Log_event B_l:Query_event
2322 ^ /\
2323 | / \
2324 | <<vir>>/ \ <<vir>>
2325 | / \
2326 | / \
2327 | / \
2328 Query_log_event B_l:E_L_Q_E
2329 \ /
2330 \ /
2331 \ /
2332 \ /
2333 \ /
2334 Execute_load_query_log_event
2335
2336 B_l: Namespace Binary_log
2337 E_L_Q_E: class Execute_load_query
2338 @endinternal
2339
2340 @section Execute_load_query_log_event_binary_format Binary Format
2341*/
2343 : public Query_log_event,
2345 public:
2346#ifdef MYSQL_SERVER
2348 THD *thd, const char *query_arg, ulong query_length,
2349 uint fn_pos_start_arg, uint fn_pos_end_arg,
2351 bool using_trans, bool immediate, bool suppress_use, int errcode);
2352 int pack_info(Protocol *protocol) override;
2353#else
2354 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2355 /* Prints the query as LOAD DATA LOCAL and with rewritten filename */
2356 void print(FILE *file, PRINT_EVENT_INFO *print_event_info,
2357 const char *local_fname) const;
2358#endif
2360 const char *buf,
2361 const mysql::binlog::event::Format_description_event *description_event);
2362 ~Execute_load_query_log_event() override = default;
2363
2364 ulong get_post_header_size_for_derived() override;
2365#ifdef MYSQL_SERVER
2366 bool write_post_header_for_derived(Basic_ostream *ostream) override;
2367#endif
2368
2369 bool is_sbr_logging_format() const override { return true; }
2370
2371 void claim_memory_ownership(bool claim) override;
2372
2373 private:
2374#if defined(MYSQL_SERVER)
2375 int do_apply_event(Relay_log_info const *rli) override;
2376#endif
2377};
2379#if defined MYSQL_SERVER
2381 public:
2382 Load_query_generator(THD *thd_arg, const sql_exchange *ex, const char *db_arg,
2383 const char *table_name_arg, bool is_concurrent_arg,
2384 bool replace, bool ignore);
2385
2386 const String *generate(size_t *fn_start, size_t *fn_end);
2388 private:
2389 const size_t BUF_SIZE = 2048;
2390 String str;
2391 char *buf[2048];
2395 const char *db;
2396 const char *table_name;
2397 const char *fname;
2400 bool has_replace;
2401 bool has_ignore;
2402};
2403#endif
2404#ifndef MYSQL_SERVER
2405/**
2406 @class Unknown_log_event
2407
2408*/
2409class Unknown_log_event : public mysql::binlog::event::Unknown_event,
2410 public Log_event {
2411 public:
2412 // disable copy-move semantics
2413 Unknown_log_event(Unknown_log_event &&) noexcept = delete;
2414 Unknown_log_event &operator=(Unknown_log_event &&) noexcept = delete;
2415 Unknown_log_event(const Unknown_log_event &) = delete;
2416 Unknown_log_event &operator=(const Unknown_log_event &) = delete;
2417
2418 /**
2419 Even if this is an unknown event, we still pass description_event to
2420 Log_event's ctor, this way we can extract maximum information from the
2421 event's header (the unique ID for example).
2422 */
2423 Unknown_log_event(
2424 const char *buf,
2425 const mysql::binlog::event::Format_description_event *description_event)
2426 : mysql::binlog::event::Unknown_event(buf, description_event),
2427 Log_event(header(), footer()) {
2428 DBUG_TRACE;
2429 if (!is_valid()) return;
2430 common_header->set_is_valid(true);
2431 return;
2432 }
2433
2434 ~Unknown_log_event() override = default;
2435 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2438 }
2439};
2440#endif
2441char *str_to_hex(char *to, const char *from, size_t len);
2442
2443/**
2444 @class Table_map_log_event
2445
2446 Table_map_log_event which maps a table definition to a number.
2447
2448 @internal
2449 The inheritance structure in the current design for the classes is
2450 as follows:
2451
2452 Binary_log_event
2453 ^
2454 |
2455 |
2456 Table_map_event Log_event
2457 \ /
2458 \ /
2459 \ /
2460 Table_map_log_event
2461 @endinternal
2462*/
2464 public Log_event {
2465 public:
2466 // disable copy-move semantics
2469 Table_map_log_event(const Table_map_log_event &) = delete;
2470 Table_map_log_event &operator=(const Table_map_log_event &) = delete;
2472 /** Constants */
2474
2475 /**
2476 Enumeration of the errors that can be returned.
2479 ERR_OPEN_FAILURE = -1, /**< Failure to open table */
2480 ERR_OK = 0, /**< No error */
2481 ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
2482 ERR_OUT_OF_MEM = 2, /**< Out of memory */
2483 ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
2484 ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
2486
2487 enum enum_flag {
2488 /**
2489 Nothing here right now, but the flags support is there in
2490 preparation for changes that are coming. Need to add a
2491 constant to make it compile under HP-UX: aCC does not like
2492 empty enumerations.
2495 };
2496
2497 /** Special constants representing sets of flags */
2498 enum {
2500 TM_BIT_LEN_EXACT_F = (1U << 0),
2501 TM_REFERRED_FK_DB_F = (1U << 1),
2502 /**
2503 Table has generated invisible primary key. MySQL generates primary key
2504 while creating a table if sql_generate_invisible_primary_key is "ON" and
2505 table is PK-less.
2507 TM_GENERATED_INVISIBLE_PK_F = (1U << 2)
2509
2510 flag_set get_flags(flag_set flag) const { return m_flags & flag; }
2511
2512#ifdef MYSQL_SERVER
2513 Table_map_log_event(THD *thd_arg, TABLE *tbl,
2515 bool using_trans);
2516#endif
2518 const char *buf,
2519 const mysql::binlog::event::Format_description_event *description_event);
2520
2521 void claim_memory_ownership(bool claim) override;
2522
2523 ~Table_map_log_event() override;
2524
2525#ifndef MYSQL_SERVER
2526 table_def *create_table_def() {
2527 assert(m_colcnt > 0);
2528 uint vector_column_count =
2530 std::vector<unsigned int> vector_dimensionality;
2531 if (vector_column_count > 0) {
2534 vector_dimensionality = fields.m_vector_dimensionality;
2535 }
2538 vector_dimensionality);
2539 }
2540 static bool rewrite_db_in_buffer(
2541 char **buf, ulong *event_len,
2543#endif
2547 const char *get_table_name() const { return m_tblnam.c_str(); }
2548 const char *get_db_name() const { return m_dbnam.c_str(); }
2549
2550 size_t get_data_size() override { return m_data_size; }
2551#ifdef MYSQL_SERVER
2552 virtual int save_field_metadata();
2553 bool write_data_header(Basic_ostream *ostream) override;
2554 bool write_data_body(Basic_ostream *ostream) override;
2555 const char *get_db() override { return m_dbnam.c_str(); }
2556 uint8 mts_number_dbs() override {
2558 }
2559 /**
2560 @param[out] arg pointer to a struct containing char* array
2561 pointers be filled in and the number of filled instances.
2562 @param rpl_filter pointer to a replication filter.
2563
2564 @return number of databases in the array: either one or
2565 OVER_MAX_DBS_IN_EVENT_MTS, when the Table map event reports
2566 foreign keys constraint.
2567 */
2569 const char *db_name = get_db();
2570
2572 size_t dummy_len;
2573 const char *db_filtered = rpl_filter->get_rewrite_db(db_name, &dummy_len);
2574 // db_name != db_filtered means that db_name is rewritten.
2575 if (strcmp(db_name, db_filtered)) db_name = db_filtered;
2576 }
2577
2578 if (!get_flags(TM_REFERRED_FK_DB_F)) arg->name[0] = db_name;
2579
2580 return arg->num = mts_number_dbs();
2581 }
2582
2583#endif
2584
2585#if defined(MYSQL_SERVER)
2586 int pack_info(Protocol *protocol) override;
2587#endif
2588
2589#ifndef MYSQL_SERVER
2590 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
2591
2592 /**
2593 Print column metadata. Its format looks like:
2594 # Columns(colume_name type, colume_name type, ...)
2595 if colume_name field is not logged into table_map_log_event, then
2596 only type is printed.
2597
2598 @param[out] file the place where colume metadata is printed
2599 @param[in] fields The metadata extracted from optional metadata fields
2600 */
2601 void print_columns(IO_CACHE *file,
2602 const Optional_metadata_fields &fields) const;
2603 /**
2604 Print primary information. Its format looks like:
2605 # Primary Key(colume_name, column_name(prifix), ...)
2606 if colume_name field is not logged into table_map_log_event, then
2607 colume index is printed.
2608
2609 @param[out] file the place where primary key is printed
2610 @param[in] fields The metadata extracted from optional metadata fields
2611 */
2612 void print_primary_key(IO_CACHE *file,
2613 const Optional_metadata_fields &fields) const;
2614#endif
2615
2617
2618 bool is_rbr_logging_format() const override { return true; }
2619
2620 private:
2621#if defined(MYSQL_SERVER)
2622 int do_apply_event(Relay_log_info const *rli) override;
2623 int do_update_pos(Relay_log_info *rli) override;
2625#endif
2627#ifdef MYSQL_SERVER
2628 TABLE *m_table;
2630 // Metadata fields buffer
2632
2633 /**
2634 Wrapper around `TABLE *m_table` that abstracts the table field set iteration
2635 logic, since it is not mandatory that all table fields are to be
2636 replicated. For details, @see ReplicatedColumnsView class documentation.
2637
2638 A smart pointer is used here as the developer might want to instantiate the
2639 view using different classes in runtime depending on the given context.
2640 As of now the column view is only used on outbound scenarios
2641 */
2643
2644 /**
2645 Capture the optional metadata fields which should be logged into
2646 table_map_log_event and serialize them into m_metadata_buf.
2647 */
2648 void init_metadata_fields();
2649 bool init_signedness_field();
2650 /**
2651 Capture and serialize character sets. Character sets for
2652 character columns (TEXT etc) and character sets for ENUM and SET
2653 columns are stored in different metadata fields. The reason is
2654 that TEXT character sets are included even when
2655 binlog_row_metadata=MINIMAL, whereas ENUM and SET character sets
2656 are included only when binlog_row_metadata=FULL.
2657
2658 @param include_type Predicate to determine if a given Field object
2659 is to be included in the metadata field.
2660
2661 @param default_charset_type Type code when storing in "default
2662 charset" format. (See comment above Table_maps_log_event in
2663 mysql/binlog/event/rows_event.h)
2664
2665 @param column_charset_type Type code when storing in "column
2666 charset" format. (See comment above Table_maps_log_event in
2667 mysql/binlog/event/rows_event.h)
2668 */
2669 bool init_charset_field(std::function<bool(const Field *)> include_type,
2670 Optional_metadata_field_type default_charset_type,
2671 Optional_metadata_field_type column_charset_type);
2679#endif
2680
2681#ifndef MYSQL_SERVER
2682 class Charset_iterator;
2683 class Default_charset_iterator;
2684 class Column_charset_iterator;
2685#endif
2686};
2687
2688#ifdef HAVE_PSI_STAGE_INTERFACE
2689/*
2690 Helper class for PSI context while applying a Rows_log_event.
2691 */
2693 private:
2696
2697 /**
2698 A cached pointer to this stage PSI_stage_progress.
2699 */
2701
2702 /**
2703 Counter that is unconditionally incremented on each row that is processed.
2704 This is helpful in case estimation is needed after started processing
2705 a Rows_log_event.
2706 */
2709 public:
2711
2712 void set_progress(PSI_stage_progress *progress) { m_progress = progress; }
2713
2714 /**
2715 If instrumentation is enabled this member function SHALL return true.
2716 @return true if instrumentation is enabled for the given stage, false
2717 otherwise.
2718 */
2719 bool is_enabled() { return m_progress != nullptr; }
2720
2721 /**
2722 This member function shall update the progress and reestimate the remaining
2723 work needed. This MUST be called after setting n_rows_applied correctly
2724 by calling inc_n_rows_applied beforehand.
2725
2726 Cursor, begin and end are used in case estimation is needed.
2727
2728 @param cursor Pointer to where we are in the buffer of rows to be processed.
2729 @param begin Pointer to the beginning of the rows buffer.
2730 @param end Pointer to the end of the rows buffer.
2731 */
2732 void update_work_estimated_and_completed(const uchar *cursor,
2733 const uchar *begin,
2734 const uchar *end) {
2735 if (!is_enabled()) return;
2736
2738
2739 /* Estimate if need be. */
2740 if (estimated == 0) {
2741 assert(cursor > begin);
2742 const ulonglong avg_row_change_size = (cursor - begin) / m_n_rows_applied;
2743 estimated = (end - begin) / avg_row_change_size;
2745 }
2746
2747 /* reset estimated if done more work than estimated */
2748 if (m_n_rows_applied > estimated)
2751 }
2752
2753 /**
2754 Resets this object.
2755 */
2756 void end_work() {
2757 m_progress = nullptr;
2758 m_n_rows_applied = 0;
2759 }
2760
2761 /**
2762 Updates the counter of processed rows.
2763 @param delta the amount of increment to be done.
2764 */
2765 void inc_n_rows_applied(ulonglong delta) { m_n_rows_applied += delta; }
2766
2767 /**
2768 Gets the value of the counter of rows that have been processed.
2769 @return the value of the counter of rows processed so far.
2770 */
2772};
2773#endif
2774
2775/**
2776 @class Rows_log_event
2777
2778 Common base class for all row-containing log events.
2779
2780 RESPONSIBILITIES
2781
2782 Encode the common parts of all events containing rows, which are:
2783 - Write data header and data body to an IO_CACHE.
2784
2785 Virtual inheritance is required here to handle the diamond problem in
2786 the class Write_rows_log_event, Update_rows_log_event and
2787 Delete_rows_log_event.
2788 The diamond structure is explained in @c Write_rows_log_event,
2789 @c Update_rows_log_event,
2790 @c Delete_rows_log_event
2791
2792 @internal
2793 The inheritance structure in the current design for the classes is
2794 as follows:
2795
2796 Binary_log_event
2797 ^
2798 |
2799 |
2800 Rows_event Log_event
2801 \ /
2802 <<vir>>\ /
2803 \ /
2804 Rows_log_event
2805 @endinternal
2807*/
2809 public Log_event {
2810#ifdef HAVE_PSI_STAGE_INTERFACE
2811 protected:
2813#endif
2814
2815 public:
2816 // disable copy-move semantics
2818 Rows_log_event &operator=(Rows_log_event &&) noexcept = delete;
2819 Rows_log_event(const Rows_log_event &) = delete;
2820 Rows_log_event &operator=(const Rows_log_event &) = delete;
2821
2830 };
2831
2832 /**
2833 Enumeration of the errors that can be returned.
2836 ERR_OPEN_FAILURE = -1, /**< Failure to open table */
2837 ERR_OK = 0, /**< No error */
2838 ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
2839 ERR_OUT_OF_MEM = 2, /**< Out of memory */
2840 ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
2841 ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
2842 };
2844 /* Special constants representing sets of flags */
2845 enum { RLE_NO_FLAGS = 0U };
2846
2849 void set_flags(flag_set flags_arg) { m_flags |= flags_arg; }
2850 void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
2851 flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
2854 get_general_type_code() = 0; /* General rows op type, no version */
2855
2856#if defined(MYSQL_SERVER)
2857 int pack_info(Protocol *protocol) override;
2858#endif
2859
2860#ifndef MYSQL_SERVER
2861 void print_verbose(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info);
2862 size_t print_verbose_one_row(IO_CACHE *file, table_def *td,
2863 PRINT_EVENT_INFO *print_event_info,
2864 MY_BITMAP *cols_bitmap, const uchar *ptr,
2865 const uchar *prefix,
2866 enum_row_image_type row_image_type);
2867#endif
2869#ifdef MYSQL_SERVER
2870 int add_row_data(uchar *data, size_t length) {
2871 return do_add_row_data(data, length);
2872 }
2873#endif
2874
2875 /* Member functions to implement superclass interface */
2876 size_t get_data_size() override;
2878 MY_BITMAP const *get_cols() const { return &m_cols; }
2879 MY_BITMAP const *get_cols_ai() const { return &m_cols_ai; }
2881 return m_table_id;
2882 }
2883
2884#if defined(MYSQL_SERVER)
2885 /**
2886 Compares the table's read/write_set with the columns included in
2887 this event's before-image and/or after-image. Each subclass
2888 (Write/Update/Delete) implements this function by comparing on the
2889 image(s) pertinent to the subclass.
2890
2891 @param[in] table The table to compare this events bitmaps
2892 against.
2893
2894 @retval true if sets match
2895 @retval false otherwise (following bitmap_cmp return logic).
2896 */
2897 virtual bool read_write_bitmaps_cmp(const TABLE *table) const = 0;
2898#endif
2899
2900#ifdef MYSQL_SERVER
2901 bool write_data_header(Basic_ostream *ostream) override;
2902 bool write_data_body(Basic_ostream *ostream) override;
2903 const char *get_db() override { return m_table->s->db.str; }
2904#endif
2905
2906 uint m_row_count; /* The number of rows added to the event */
2907
2908 protected:
2909 /*
2910 The constructors are protected since you're supposed to inherit
2911 this class, not create instances of this class.
2912 */
2913#ifdef MYSQL_SERVER
2915 MY_BITMAP const *cols, bool is_transactional,
2917 const unsigned char *extra_row_ndb_info);
2918#endif
2920 const char *row_data,
2921 const mysql::binlog::event::Format_description_event *description_event);
2922
2923#ifndef MYSQL_SERVER
2924 void print_helper(FILE *, PRINT_EVENT_INFO *) const;
2925#endif
2926
2927#ifdef MYSQL_SERVER
2928 virtual int do_add_row_data(uchar *data, size_t length);
2929#endif
2931#ifdef MYSQL_SERVER
2932 TABLE *m_table; /* The table the rows belong to */
2933#endif
2934 MY_BITMAP m_cols; /* Bitmap denoting columns available */
2935 /**
2936 Bitmap denoting columns available in the image as they appear in the table
2937 setup. On some setups, the number and order of columns may differ from
2938 master to slave so, a bitmap for local available columns is computed using
2939 `ReplicatedColumnsView` utility class.
2940 */
2942#ifdef MYSQL_SERVER
2943 /**
2944 Hash table that will hold the entries for while using HASH_SCAN
2945 algorithm to search and update/delete rows.
2946 */
2948
2949 /**
2950 The algorithm to use while searching for rows using the before
2951 image.
2952 */
2954#endif
2955 /**
2956 Bitmap for columns available in the after image, if present. These
2957 fields are only available for Update_rows events. Observe that the
2958 width of both the before image COLS vector and the after image
2959 COLS vector is the same: the number of columns of the table on the
2960 master.
2961 */
2963 /**
2964 Bitmap denoting columns available in the after-image as they appear in the
2965 table setup. On some setups, the number and order of columns may differ from
2966 master to slave so, a bitmap for local available columns is computed using
2967 `ReplicatedColumnsView` utility class.
2968 */
2971 /* Bit buffers in the same memory as the class */
2972 uint32 m_bitbuf[128 / (sizeof(uint32) * 8)];
2973 uint32 m_bitbuf_ai[128 / (sizeof(uint32) * 8)];
2974
2975 /*
2976 is_valid depends on the value of m_rows_buf, so while changing the value
2977 of m_rows_buf check if is_valid also needs to be modified
2979 uchar *m_rows_buf; /* The rows in packed format */
2980 uchar *m_rows_cur; /* One-after the end of the data */
2981 uchar *m_rows_end; /* One-after the end of the allocated space */
2982
2983 /* helper functions */
2985#if defined(MYSQL_SERVER)
2986 const uchar *m_curr_row; /* Start of the row being processed */
2987 const uchar *m_curr_row_end; /* One-after the end of the current row */
2988 uchar *m_key; /* Buffer to keep key value during searches */
2990 KEY *m_key_info; /* Points to description of index #m_key_index */
2991 class Key_compare {
2992 public:
2993 /**
2994 @param ki Where to find KEY description
2995 @note m_distinct_keys is instantiated when Rows_log_event is constructed;
2996 it stores a Key_compare object internally. However at that moment, the
2997 index (KEY*) to use for comparisons, is not yet known. So, at
2998 instantiation, we indicate the Key_compare the place where it can
2999 find the KEY* when needed (this place is Rows_log_event::m_key_info),
3000 Key_compare remembers the place in member m_key_info.
3001 Before we need to do comparisons - i.e. before we need to insert
3002 elements, we update Rows_log_event::m_key_info once for all.
3004 Key_compare(KEY **ki = nullptr) : m_key_info(ki) {}
3005 bool operator()(uchar *k1, uchar *k2) const {
3006 return key_cmp2((*m_key_info)->key_part, k1, (*m_key_info)->key_length,
3007 k2, (*m_key_info)->key_length) < 0;
3008 }
3010 private:
3013 std::set<uchar *, Key_compare> m_distinct_keys;
3014 std::set<uchar *, Key_compare>::iterator m_itr;
3015 /**
3016 A spare buffer which will be used when saving the distinct keys
3017 for doing an index scan with HASH_SCAN search algorithm.
3018 */
3020
3021 /**
3022 Unpack the current row image from the event into m_table->record[0].
3023
3024 @param rli The applier context.
3025
3026 @param cols The bitmap of columns included in the update.
3027
3028 @param is_after_image Should be true if this is an after-image,
3029 false if it is a before-image.
3030
3031 @param only_seek unpack_row()
3032
3033 @retval 0 Success
3034
3035 @retval ER_* On error, it is guaranteed that the error has been
3036 reported through my_error, and the corresponding ER_* code is
3037 returned. Currently the error codes are: EE_OUTOFMEMORY,
3038 ER_REPLICA_CORRUPT_EVENT, or various JSON errors when applying JSON
3039 diffs (ER_COULD_NOT_APPLY_JSON_DIFF, ER_INVALID_JSON_BINARY_DATA,
3040 and maybe others).
3041 */
3042 int unpack_current_row(const Relay_log_info *const rli, MY_BITMAP const *cols,
3043 bool is_after_image, bool only_seek = false);
3044 /**
3045 Updates the generated columns of the `TABLE` object referenced by
3046 `m_table`, that have an active bit in the parameter bitset
3047 `fields_to_update`.
3048
3049 @param fields_to_update A bitset where the bit at the index of
3050 generated columns to update must be set to `1`
3051
3052 @return 0 if the operation terminated successfully, 1 otherwise.
3053 */
3054 int update_generated_columns(MY_BITMAP const &fields_to_update);
3055 /*
3056 This member function is called when deciding the algorithm to be used to
3057 find the rows to be updated on the slave during row based replication.
3058 This this functions sets the m_rows_lookup_algorithm and also the
3059 m_key_index with the key index to be used if the algorithm is dependent on
3060 an index.
3061 */
3063
3064 /*
3065 Encapsulates the operations to be done before applying
3066 row event for update and delete.
3067 */
3069
3070 /*
3071 Encapsulates the operations to be done after applying
3072 row event for update and delete.
3073 */
3075
3076 /**
3077 Helper function to check whether there is an auto increment
3078 column on the table where the event is to be applied.
3079 GIPKs when not present in the source table are also considered a
3080 auto inc column in a extra column.
3081
3082 @param rli the relay log object associated to the replicated table
3083
3084 @return true if there is an autoincrement field on the extra
3085 columns, false otherwise.
3086 */
3087 bool is_auto_inc_in_extra_columns(const Relay_log_info *const rli);
3088
3089 /**
3090 Helper function to check whether the storage engine error
3091 allows for the transaction to be retried or not.
3092
3093 @param error Storage engine error
3094 @retval true if the error is retryable.
3095 @retval false if the error is non-retryable.
3096 */
3098#endif
3099
3100 bool is_rbr_logging_format() const override { return true; }
3101
3102 private:
3103#if defined(MYSQL_SERVER)
3104
3105 /**
3106 Wrapper around `TABLE *m_table` that abstracts the table field set iteration
3107 logic, since it is not mandatory that all table fields are to be
3108 replicated. For details, @see ReplicatedColumnsView class documentation.
3109
3110 A smart pointer is used here as the developer might want to instantiate the
3111 view using different classes in runtime depending on the given context.
3112 */
3114
3115 int do_apply_event(Relay_log_info const *rli) override;
3116 int do_update_pos(Relay_log_info *rli) override;
3118
3119 /*
3120 Primitive to prepare for a sequence of row executions.
3121
3122 DESCRIPTION
3123
3124 Before doing a sequence of do_prepare_row() and do_exec_row()
3125 calls, this member function should be called to prepare for the
3126 entire sequence. Typically, this member function will allocate
3127 space for any buffers that are needed for the two member
3128 functions mentioned above.
3129
3130 RETURN VALUE
3131
3132 The member function will return 0 if all went OK, or a non-zero
3133 error code otherwise.
3134 */
3135 virtual int do_before_row_operations(const Relay_log_info *const log) = 0;
3136
3137 /*
3138 Primitive to clean up after a sequence of row executions.
3139
3140 DESCRIPTION
3141
3142 After doing a sequence of do_prepare_row() and do_exec_row(),
3143 this member function should be called to clean up and release
3144 any allocated buffers.
3145
3146 The error argument, if non-zero, indicates an error which happened during
3147 row processing before this function was called. In this case, even if
3148 function is successful, it should return the error code given in the
3149 argument.
3150 */
3151 virtual int do_after_row_operations(const Relay_log_info *const log,
3152 int error) = 0;
3153
3154 /*
3155 Primitive to do the actual execution necessary for a row.
3156
3157 DESCRIPTION
3158 The member function will do the actual execution needed to handle a row.
3159 The row is located at m_curr_row. When the function returns,
3160 m_curr_row_end should point at the next row (one byte after the end
3161 of the current row).
3162
3163 RETURN VALUE
3164 0 if execution succeeded, 1 if execution failed.
3166 */
3167 virtual int do_exec_row(const Relay_log_info *const rli) = 0;
3168
3169 /**
3170 Private member function called while handling idempotent errors.
3171
3172 @param rli Pointer to relay log info structure.
3173 @param [in,out] err the error to handle. If it is listed as
3174 idempotent/ignored related error, then it is cleared.
3175 @returns true if the slave should stop executing rows.
3176 */
3178
3179 /**
3180 Private member function called after updating/deleting a row. It
3181 performs some assertions and more importantly, it updates
3182 m_curr_row so that the next row is processed during the row
3183 execution main loop (@c Rows_log_event::do_apply_event()).
3184
3185 @param rli Pointer to relay log info structure.
3186 @param err the current error code.
3187 */
3188 void do_post_row_operations(Relay_log_info const *rli, int err);
3189
3190 /**
3191 Commodity wrapper around do_exec_row(), that deals with resetting
3192 the thd reference in the table.
3193 */
3194 int do_apply_row(Relay_log_info const *rli);
3195
3196 /**
3197 Implementation of the index scan and update algorithm. It uses
3198 PK, UK or regular Key to search for the record to update. When
3199 found it updates it.
3200 */
3202
3203 /**
3204 Implementation of the hash_scan and update algorithm. It collects
3205 rows positions in a hashtable until the last row is
3206 unpacked. Then it scans the table to update and when a record in
3207 the table matches the one in the hashtable, the update/delete is
3208 performed.
3209 */
3211
3212 /**
3213 Implementation of the legacy table_scan and update algorithm. For
3214 each unpacked row it scans the storage engine table for a
3215 match. When a match is found, the update/delete operations are
3216 performed.
3217 */
3219
3220 /**
3221 Seek past the after-image of an update event, in case a row was processed
3222 without reading the after-image.
3223
3224 An update event may process a row without reading the after-image,
3225 e.g. in case of ignored or idempotent errors. To ensure that the
3226 read position for the next row is correct, we need to seek past
3227 the after-image.
3228
3229 @param rli The applier context
3230
3231 @param curr_bi_start The read position of the beginning of the
3232 before-image. (The function compares this with m_curr_row to know
3233 if the after-image has been read or not.)
3234
3235 @retval 0 Success
3236 @retval ER_* Error code returned by unpack_current_row
3237 */
3239 [[maybe_unused]],
3240 const uchar *curr_bi_start
3241 [[maybe_unused]]) {
3242 return 0;
3243 }
3244
3245 /**
3246 Initializes scanning of rows. Opens an index and initializes an iterator
3247 over a list of distinct keys (m_distinct_keys) if it is a HASH_SCAN
3248 over an index or the table if its a HASH_SCAN over the table.
3249 */
3250 int open_record_scan();
3251
3252 /**
3253 Does the cleanup
3254 - closes the index if opened by open_record_scan
3255 - closes the table if opened for scanning.
3256 */
3257 int close_record_scan();
3258
3259 /**
3260 Fetches next row. If it is a HASH_SCAN over an index, it populates
3261 table->record[0] with the next row corresponding to the index. If
3262 the indexes are in non-contigous ranges it fetches record corresponding
3263 to the key value in the next range.
3264
3265 @param first_read signifying if this is the first time we are reading a row
3266 over an index.
3267 @return error code when there are no more records to be fetched or some
3268 other error occurred,
3269 - 0 otherwise.
3270 */
3271 int next_record_scan(bool first_read);
3272
3273 /**
3274 Populates the m_distinct_keys with unique keys to be modified
3275 during HASH_SCAN over keys.
3276 @returns 0 success, or the error code.
3277 */
3279
3280 /**
3281 Populates the m_hash when using HASH_SCAN. Thence, it:
3282 - unpacks the before image (BI)
3283 - saves the positions
3284 - saves the positions into the hash map, using the
3285 BI checksum as key
3286 - unpacks the after image (AI) if needed, so that
3287 m_curr_row_end gets updated correctly.
3288
3289 @param rli The reference to the relay log info object.
3290 @returns 0 on success. Otherwise, the error code.
3291 */
3292 int do_hash_row(Relay_log_info const *rli);
3293
3294 /**
3295 This member function scans the table and applies the changes
3296 that had been previously hashed. As such, m_hash MUST be filled
3297 by do_hash_row before calling this member function.
3298
3299 @param rli The reference to the relay log info object.
3300 @returns 0 on success. Otherwise, the error code.
3301 */
3302 int do_scan_and_update(Relay_log_info const *rli);
3303#endif /* defined(MYSQL_SERVER) */
3304
3305 friend class Old_rows_log_event;
3306
3307 /**
3308 This bitmap is used as a backup for the write set while we calculate
3309 the values for any hidden generated columns (functional indexes). In order
3310 to calculate the values, the columns must be marked in the write set. After
3311 the values are calculated, we set the write set back to its original value.
3312 */
3314};
3315
3316/**
3317 @class Write_rows_log_event
3318
3319 Log row insertions and updates. The event contain several
3320 insert/update rows for a table. Note that each event contains only
3321 rows for one table.
3322
3323 @internal
3324 The inheritance structure is as follows
3325
3326 Binary_log_event
3327 ^
3328 |
3329 |
3330 |
3331 Log_event B_l:Rows_event
3332 ^ /\
3333 | / \
3334 | <<vir>>/ \ <<vir>>
3335 | / \
3336 | / \
3337 | / \
3338 Rows_log_event B_l:W_R_E
3339 \ /
3340 \ /
3341 \ /
3342 \ /
3343 \ /
3344 \/
3345 Write_rows_log_event
3346
3347 B_l: Namespace Binary_log
3348 W_R_E: class Write_rows_event
3349 @endinternal
3351*/
3354 public:
3355 enum {
3356 /* Support interface to THD::binlog_prepare_pending_rows_event */
3358 };
3359
3360#if defined(MYSQL_SERVER)
3362 const mysql::binlog::event::Table_id &table_id,
3363 bool is_transactional,
3364 const unsigned char *extra_row_ndb_info);
3365#endif
3367 const char *buf,
3368 const mysql::binlog::event::Format_description_event *description_event);
3369#if defined(MYSQL_SERVER)
3371 bool is_transactional,
3372 const uchar *before_record
3373 [[maybe_unused]],
3374 const uchar *after_record);
3375 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3376 return bitmap_cmp(get_cols(), table->write_set);
3377 }
3378#endif
3379
3380 void claim_memory_ownership(bool claim) override;
3381
3382 protected:
3383 int write_row(const Relay_log_info *const, const bool);
3385 private:
3388 }
3389
3390#ifndef MYSQL_SERVER
3391 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3392#endif
3393
3394#if defined(MYSQL_SERVER)
3395 int do_before_row_operations(const Relay_log_info *const) override;
3396 int do_after_row_operations(const Relay_log_info *const, int) override;
3397 int do_exec_row(const Relay_log_info *const) override;
3398#endif
3399};
3400
3401/**
3402 @class Update_rows_log_event
3403
3404 Log row updates with a before image. The event contain several
3405 update rows for a table. Note that each event contains only rows for
3406 one table.
3407
3408 Also note that the row data consists of pairs of row data: one row
3409 for the old data and one row for the new data.
3410
3411 @internal
3412 The inheritance structure is as follows
3413
3414 Binary_log_event
3415 ^
3416 |
3417 |
3418 |
3419 Log_event B_l:Rows_event
3420 ^ /\
3421 | / \
3422 | <<vir>>/ \ <<vir>>
3423 | / \
3424 | / \
3425 | / \
3426 Rows_log_event B_l:U_R_E
3427 \ /
3428 \ /
3429 \ /
3430 \ /
3431 \ /
3432 \/
3433 Update_rows_log_event
3434
3435
3436 B_l: Namespace Binary_log
3437 U_R_E: class Update_rows_event
3438 @eninternal
3440*/
3443 public:
3444 enum {
3445 /* Support interface to THD::binlog_prepare_pending_rows_event */
3447 };
3449#ifdef MYSQL_SERVER
3451 const mysql::binlog::event::Table_id &table_id,
3452 MY_BITMAP const *cols_bi, MY_BITMAP const *cols_ai,
3453 bool is_transactional,
3454 const unsigned char *extra_row_ndb_info);
3455
3457 const mysql::binlog::event::Table_id &table_id,
3458 bool is_transactional,
3459 const unsigned char *extra_row_ndb_info);
3460
3461 void init(MY_BITMAP const *cols);
3462#endif
3463
3464 ~Update_rows_log_event() override;
3465
3467 const char *buf,
3468 const mysql::binlog::event::Format_description_event *description_event);
3469
3470#ifdef MYSQL_SERVER
3472 bool is_transactional,
3473 const uchar *before_record,
3474 const uchar *after_record);
3475 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3476 return (bitmap_cmp(get_cols(), table->read_set) &&
3477 bitmap_cmp(get_cols_ai(), table->write_set));
3478 }
3479#endif
3480
3481 void claim_memory_ownership(bool claim) override;
3483 protected:
3486 }
3487
3488#ifndef MYSQL_SERVER
3489 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3490#endif
3491
3492#if defined(MYSQL_SERVER)
3493 int do_before_row_operations(const Relay_log_info *const) override;
3494 int do_after_row_operations(const Relay_log_info *const, int) override;
3495 int do_exec_row(const Relay_log_info *const) override;
3496
3498 const uchar *curr_bi_start) override;
3499
3500 private:
3501 /**
3502 Auxiliary function used in the (THD*, ...) constructor to
3503 determine the type code based on configuration options.
3504
3505 @param thd_arg The THD object for the session.
3506
3507 @return One of PARTIAL_UPDATE_ROWS_EVENT, or UPDATE_ROWS_EVENT.
3508 */
3510 const THD *thd_arg);
3511#endif /* defined(MYSQL_SERVER) */
3512};
3513
3514/**
3515 @class Delete_rows_log_event
3516
3517 Log row deletions. The event contain several delete rows for a
3518 table. Note that each event contains only rows for one table.
3519
3520 RESPONSIBILITIES
3521
3522 - Act as a container for rows that has been deleted on the master
3523 and should be deleted on the slave.
3524
3525 COLLABORATION
3526
3527 Row_writer
3528 Create the event and add rows to the event.
3529 Row_reader
3530 Extract the rows from the event.
3531
3532 @internal
3533 The inheritance structure is as follows
3534
3535 Binary_log_event
3536 ^
3537 |
3538 |
3539 |
3540 Log_event B_l:Rows_event
3541 ^ /\
3542 | / \
3543 | <<vir>>/ \ <<vir>>
3544 | / \
3545 | / \
3546 | / \
3547 Rows_log_event B_l:D_R_E
3548 \ /
3549 \ /
3550 \ /
3551 \ /
3552 \ /
3553 \/
3554 Delete_rows_log_event
3555
3556 B_l: Namespace Binary_log
3557 D_R_E: class Delete_rows_event
3558 @endinternal
3560*/
3563 public:
3564 enum {
3565 /* Support interface to THD::binlog_prepare_pending_rows_event */
3567 };
3568
3569#ifdef MYSQL_SERVER
3571 bool is_transactional,
3572 const unsigned char *extra_row_ndb_info);
3573#endif
3575 const char *buf,
3576 const mysql::binlog::event::Format_description_event *description_event);
3577#ifdef MYSQL_SERVER
3579 bool is_transactional,
3580 const uchar *before_record,
3581 const uchar *after_record
3582 [[maybe_unused]]);
3583 bool read_write_bitmaps_cmp(const TABLE *table) const override {
3584 return bitmap_cmp(get_cols(), table->read_set);
3585 }
3586#endif
3587
3588 void claim_memory_ownership(bool claim) override;
3590 protected:
3593 }
3594
3595#ifndef MYSQL_SERVER
3596 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3597#endif
3598
3599#if defined(MYSQL_SERVER)
3600 int do_before_row_operations(const Relay_log_info *const) override;
3601 int do_after_row_operations(const Relay_log_info *const, int) override;
3602 int do_exec_row(const Relay_log_info *const) override;
3603#endif
3604};
3605
3606/**
3607 @class Incident_log_event
3608
3609 Class representing an incident, an occurrence out of the ordinary,
3610 that happened on the master.
3611
3612 The event is used to inform the slave that something out of the
3613 ordinary happened on the master that might cause the database to be
3614 in an inconsistent state.
3615
3616 It's the derived class of Incident_event
3617
3618 @internal
3619 The inheritance structure is as follows
3620
3621 Binary_log_event
3622 ^
3623 |
3624 |
3625 B_l:Incident_event Log_event
3626 \ /
3627 \ /
3628 \ /
3629 \ /
3630 Incident_log_event
3631
3632 B_l: Namespace Binary_log
3633 @endinternal
3635*/
3637 public Log_event {
3638 public:
3639 // disable copy-move semantics
3642 Incident_log_event(const Incident_log_event &) = delete;
3643 Incident_log_event &operator=(const Incident_log_event &) = delete;
3645#ifdef MYSQL_SERVER
3646 Incident_log_event(THD *thd_arg, enum_incident incident_arg,
3647 std::string_view msg)
3648 : mysql::binlog::event::Incident_event(incident_arg),
3651 DBUG_TRACE;
3652 DBUG_PRINT("enter", ("incident: %d", incident_arg));
3653 common_header->set_is_valid(incident_arg > INCIDENT_NONE &&
3654 incident_arg < INCIDENT_COUNT);
3655 assert(message == nullptr && message_length == 0);
3657 msg.length() + 1, MYF(MY_WME)))) {
3658 // The allocation failed. Mark this binlog event as invalid.
3660 return;
3661 }
3662 strmake(message, msg.data(), msg.length());
3663 message_length = msg.length();
3664 return;
3665 }
3666#endif
3667
3668#ifdef MYSQL_SERVER
3669 int pack_info(Protocol *) override;
3670#endif
3671
3673 const char *buf,
3674 const mysql::binlog::event::Format_description_event *description_event);
3675
3676 ~Incident_log_event() override;
3677
3678 void claim_memory_ownership(bool claim) override;
3679
3680#ifndef MYSQL_SERVER
3681 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3682#endif
3683
3684#if defined(MYSQL_SERVER)
3685 int do_apply_event(Relay_log_info const *rli) override;
3686 bool write_data_header(Basic_ostream *ostream) override;
3687 bool write_data_body(Basic_ostream *ostream) override;
3688#endif
3689
3690 size_t get_data_size() override {
3694
3695 bool ends_group() const override { return true; }
3696
3697 private:
3698 const char *description() const;
3699};
3700
3701/**
3702 @class Ignorable_log_event
3703
3704 Base class for ignorable log events is Ignorable_event.
3705 Events deriving from this class can be safely ignored
3706 by slaves that cannot recognize them.
3707
3708 Its the derived class of Ignorable_event
3709
3710 @internal
3711 The inheritance structure is as follows
3712
3713 Binary_log_event
3714 ^
3715 |
3716 |
3717 B_l:Ignorable_event Log_event
3718 \ /
3719 <<virtual>>\ /
3720 \ /
3721 Ignorable_log_event
3722
3723 B_l: Namespace Binary_log
3724 @endinternal
3725*/
3728 public Log_event {
3729 public:
3730 // disable copy-move semantics
3733 Ignorable_log_event(const Ignorable_log_event &) = delete;
3734 Ignorable_log_event &operator=(const Ignorable_log_event &) = delete;
3736#ifdef MYSQL_SERVER
3737 Ignorable_log_event(THD *thd_arg)
3740 DBUG_TRACE;
3742 return;
3743 }
3744#endif
3745
3747 const char *buf,
3749 ~Ignorable_log_event() override;
3750
3751 void claim_memory_ownership(bool claim) override;
3752
3753#ifdef MYSQL_SERVER
3754 int pack_info(Protocol *) override;
3755#endif
3756
3757#ifndef MYSQL_SERVER
3758 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3759#endif
3760
3761 size_t get_data_size() override {
3763 }
3764};
3765
3766/**
3767 @class Rows_query_log_event
3768 It is used to record the original query for the rows
3769 events in RBR.
3770 It is the subclass of Ignorable_log_event and Rows_query_event
3771
3772 @internal
3773 The inheritance structure in the current design for the classes is
3774 as follows:
3775 Binary_log_event
3776 ^
3777 |
3778 |
3779 |
3780 Log_event B_l:Ignorable_event
3781 ^ /\
3782 | / \
3783 | <<vir>>/ \ <<vir>>
3784 | / \
3785 | / \
3786 | / \
3787 Ignorable_log_event B_l:Rows_query_event
3788 \ /
3789 \ /
3790 \ /
3791 \ /
3792 \ /
3793 \/
3794 Rows_query_log_event
3795
3796 B_l : namespace namespace mysql::binlog::event
3797 @endinternal
3798*/
3801 public:
3802#ifdef MYSQL_SERVER
3803 Rows_query_log_event(THD *thd_arg, const char *query, size_t query_len)
3804 : Ignorable_log_event(thd_arg) {
3805 DBUG_TRACE;
3807 m_rows_query_length = query_len;
3808 if (!(m_rows_query =
3811 return;
3814 "rows_query_alter", size_t i = 0; while (i < m_rows_query_length) {
3815 if (m_rows_query[i] == '\\') {
3816 m_rows_query[i] = '\0';
3817 i++;
3818 for (auto j = i; j < m_rows_query_length - 1; j++) {
3819 m_rows_query[j] = m_rows_query[j + 1];
3820 }
3822 } else
3823 i++;
3824 });
3825 DBUG_PRINT("enter", ("%s", m_rows_query));
3826 return;
3827 }
3828#endif
3829
3830#ifdef MYSQL_SERVER
3831 int pack_info(Protocol *) override;
3832 int do_apply_event(Relay_log_info const *rli) override;
3833 bool write_data_body(Basic_ostream *ostream) override;
3834#endif
3835
3837 const char *buf,
3839
3840 void claim_memory_ownership(bool claim) override;
3841
3842 ~Rows_query_log_event() override {
3844 m_rows_query = nullptr;
3845 }
3846#ifndef MYSQL_SERVER
3847 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3848#endif
3849 size_t get_data_size() override {
3852 }
3854
3855static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
3856 FILE *file,
3857 bool flush_stream) {
3858 return my_b_copy_to_file(cache, file) ||
3859 (flush_stream ? (fflush(file) || ferror(file)) : 0) ||
3860 reinit_io_cache(cache, WRITE_CACHE, 0, false, true);
3861}
3862
3863#ifdef MYSQL_SERVER
3864/*****************************************************************************
3865
3866 Heartbeat Log Event class
3867
3868 The class is not logged to a binary log, and is not applied on to the slave.
3869 The decoding of the event on the slave side is done by its superclass,
3870 mysql::binlog::event::Heartbeat_event.
3872 ****************************************************************************/
3874 public Log_event {
3875 public:
3877 const char *buf,
3878 const mysql::binlog::event::Format_description_event *description_event);
3880
3882 public Log_event {
3883 public:
3885 const char *buf,
3886 const mysql::binlog::event::Format_description_event *description_event);
3887};
3888/**
3889 The function is called by slave applier in case there are
3890 active table filtering rules to force gathering events associated
3891 with Query-log-event into an array to execute
3892 them once the fate of the Query is determined for execution.
3893*/
3895#endif
3896
3897int append_query_string(const THD *thd, const CHARSET_INFO *csinfo,
3898 String const *from, String *to);
3900
3903 public Log_event {
3904 public:
3905#ifdef MYSQL_SERVER
3906
3907 Transaction_payload_log_event(THD *thd_arg, const char *payload,
3908 uint64_t payload_size,
3909 uint16_t compression_type,
3910 uint64_t uncompressed_size)
3911 : Transaction_payload_event(payload, payload_size, compression_type,
3912 uncompressed_size),
3913 Log_event(thd_arg, 0 /* flags */, Log_event::EVENT_TRANSACTIONAL_CACHE,
3915
3916 Transaction_payload_log_event(THD *thd_arg, const char *payload,
3917 uint64_t payload_size)
3919 thd_arg, payload, payload_size,
3920 mysql::binlog::event::compression::type::NONE, payload_size) {}
3921
3923 : Transaction_payload_log_event(thd_arg, nullptr, (uint64_t)0) {}
3924#endif
3925
3927 const char *buf,
3930
3931 ~Transaction_payload_log_event() override = default;
3932
3933 void claim_memory_ownership(bool claim) override;
3934
3935#ifndef MYSQL_SERVER
3936 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
3937#endif
3938
3939 size_t get_event_length() { return LOG_EVENT_HEADER_LEN + get_data_size(); }
3940 size_t get_data_size() override;
3941
3942#if defined(MYSQL_SERVER)
3943
3944 public:
3945 int do_apply_event(Relay_log_info const *rli) override;
3946 bool apply_payload_event(Relay_log_info const *rli, const uchar *event_buf);
3948 int pack_info(Protocol *protocol) override;
3949 bool ends_group() const override;
3950 bool write(Basic_ostream *ostream) override;
3951#endif
3952};
3953
3954/**
3955 @class Gtid_log_event
3956
3957 This is a subclass if Gtid_event and Log_event. It contains
3958 per-transaction fields, including the GTID and logical timestamps
3959 used by MTS.
3960
3961 @internal
3962 The inheritance structure is as follows
3963
3964 Binary_log_event
3965 ^
3966 |
3967 |
3968 B_l:Gtid_event Log_event
3969 \ /
3970 \ /
3971 \ /
3972 \ /
3973 Gtid_log_event
3974
3975 B_l: Namespace Binary_log
3976 @endinternal
3977*/
3979 public Log_event {
3980 public:
3981 // disable copy-move semantics
3983 Gtid_log_event &operator=(Gtid_log_event &&) noexcept = delete;
3984 Gtid_log_event(const Gtid_log_event &) = delete;
3985 Gtid_log_event &operator=(const Gtid_log_event &) = delete;
3986
3987#ifdef MYSQL_SERVER
3988 /**
3989 Create a new event using the GTID owned by the given thread.
3990 */
3991 Gtid_log_event(THD *thd_arg, bool using_trans, int64 last_committed_arg,
3992 int64 sequence_number_arg, bool may_have_sbr_stmts_arg,
3993 ulonglong original_commit_timestamp_arg,
3994 ulonglong immediate_commit_timestamp_arg,
3995 uint32_t original_server_version_arg,
3996 uint32_t immediate_server_version_arg);
3997
3998 /**
3999 Create a new event using the GTID from the given Gtid_specification
4000 without a THD object.
4001 */
4002 Gtid_log_event(uint32 server_id_arg, bool using_trans,
4003 int64 last_committed_arg, int64 sequence_number_arg,
4004 bool may_have_sbr_stmts_arg,
4005 ulonglong original_commit_timestamp_arg,
4006 ulonglong immediate_commit_timestamp_arg,
4007 const Gtid_specification spec_arg,
4008 uint32_t original_server_version_arg,
4009 uint32_t immediate_server_version_arg);
4010#endif
4011
4012#ifdef MYSQL_SERVER
4013 int pack_info(Protocol *) override;
4014#endif
4016 const char *buffer,
4018
4019 ~Gtid_log_event() override = default;
4020
4021 void claim_memory_ownership(bool claim) override;
4022
4024
4025 size_t get_data_size() override {
4026 if (is_tagged()) {
4027 auto size_calculated = Encoder_type::get_size(*this);
4028 DBUG_EXECUTE_IF("add_unknown_ignorable_fields_to_gtid_log_event",
4029 { size_calculated += 2; });
4030 return size_calculated;
4031 }
4032 DBUG_EXECUTE_IF("do_not_write_rpl_timestamps", return POST_HEADER_LENGTH;);
4036 }
4037
4038 /// @brief Clears tsid and spec
4039 void clear_gtid_and_spec();
4040
4041 /// @brief Updates parent tsid and gtid info structure
4043
4044 size_t get_event_length() { return LOG_EVENT_HEADER_LEN + get_data_size(); }
4045
4046 /// Used internally by both print() and pack_info().
4047 size_t to_string(char *buf) const;
4048
4049 private:
4050#ifdef MYSQL_SERVER
4051 /**
4052 Writes the post-header to the given output stream.
4053
4054 This is an auxiliary function typically used by the write() member
4055 function.
4056
4057 @param ostream The output stream to write to.
4058
4059 @retval true Error.
4060 @retval false Success.
4061 */
4062 bool write_data_header(Basic_ostream *ostream) override;
4063 bool write_data_body(Basic_ostream *ostream) override;
4064 /**
4065 Writes the post-header to the given memory buffer.
4066
4067 This is an auxiliary function used by write_to_memory.
4068
4069 @param[in,out] buffer Buffer to which the post-header will be written.
4070
4071 @return The number of bytes written, i.e., always
4072 Gtid_log_event::POST_HEADER_LENGTH.
4073 */
4075
4076 /**
4077 Writes the body to the given memory buffer.
4078
4079 This is an auxiliary function used by write_to_memory.
4080
4081 @param [in,out] buff Buffer to which the data will be written.
4082
4083 @return The number of bytes written, i.e.,
4084 If the transaction did not originated on this server
4085 Gtid_event::IMMEDIATE_COMMIT_TIMESTAMP_LENGTH.
4086 else
4087 FULL_COMMIT_TIMESTAMP_LENGTH.
4088 */
4090
4091 /// @copydoc write_body_to_memory
4092 /// @details Version for tagged Gtid log event
4094
4095#endif
4096
4097 public:
4098#ifndef MYSQL_SERVER
4099 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4100#endif
4101
4102#if defined(MYSQL_SERVER)
4103 int do_apply_event(Relay_log_info const *rli) override;
4104 int do_update_pos(Relay_log_info *rli) override;
4106#endif
4107
4108 /**
4109 Return the gtid type for this Gtid_log_event: this can be
4110 either ANONYMOUS_GTID, AUTOMATIC_GTID, or ASSIGNED_GTID.
4111 */
4112 enum_gtid_type get_type() const { return spec.type; }
4113
4114 /**
4115 Return the TSID for this GTID. The TSID is shared with the
4116 Log_event so it should not be modified.
4117 */
4118 const Tsid &get_tsid() const { return tsid; }
4119#ifdef MYSQL_SERVER
4120 /**
4121 Return the SIDNO relative to the global tsid_map for this GTID.
4122
4123 This requires a lookup and possibly even update of global_tsid_map,
4124 hence global_tsid_lock must be held. If global_tsid_lock is not
4125 held, the caller must pass need_lock=true. If there is an error
4126 (e.g. out of memory) while updating global_tsid_map, this function
4127 returns a negative number.
4128
4129 @param need_lock If true, the read lock on global_tsid_lock is
4130 acquired and released inside this function; if false, the read
4131 lock or write lock must be held prior to calling this function.
4132 @retval SIDNO if successful
4133 @retval negative if adding TSID to global_tsid_map causes an error.
4134 */
4135 rpl_sidno get_sidno(bool need_lock);
4136#endif
4137 /**
4138 Return the SIDNO relative to the given Tsid_map for this GTID.
4139
4140 This assumes that the Tsid_map is local to the thread, and thus
4141 does not use locks.
4142
4143 @param tsid_map The tsid_map to use.
4144 @retval SIDNO if successful.
4145 @retval negative if adding TSID to tsid_map causes an error.
4146 */
4147 rpl_sidno get_sidno(Tsid_map *tsid_map) { return tsid_map->add_tsid(tsid); }
4148 /// Return the GNO for this GTID.
4149 rpl_gno get_gno() const override { return spec.gtid.gno; }
4150
4151 /// @returns The GTID event specification
4154 /// string holding the text "SET @@GLOBAL.GTID_NEXT = '"
4155 static const char *SET_STRING_PREFIX;
4156
4157 private:
4158 /// Length of SET_STRING_PREFIX
4159 static const size_t SET_STRING_PREFIX_LENGTH = 26;
4160 /// The maximal length of the entire "SET ..." query.
4161 static const size_t MAX_SET_STRING_LENGTH = SET_STRING_PREFIX_LENGTH +
4164
4165 private:
4166 /**
4167 Internal representation of the GTID. The SIDNO will be
4168 uninitialized (value -1) until the first call to get_sidno(bool).
4169 */
4171 /// TSID for this GTID.
4172 Tsid tsid;
4173
4174 public:
4175 /**
4176 Set the transaction length information based on binlog cache size.
4177
4178 Note that is_checksum_enabled and event_counter are optional parameters.
4179 When not specified, the function will assume that no checksum will be used
4180 and the informed cache_size is the final transaction size without
4181 considering the GTID event size.
4182
4183 The high level formula that will be used by the function is:
4184
4185 trx_length = cache_size +
4186 cache_checksum_active * cache_events * CRC32_payload +
4187 gtid_length +
4188 cache_checksum_active * CRC32_payload; // For the GTID.
4189
4190 @param cache_size The size of the binlog cache in bytes.
4191 @param is_checksum_enabled If checksum will be added to events on flush.
4192 @param event_counter The amount of events in the cache.
4193 */
4195 bool is_checksum_enabled = false,
4196 int event_counter = 0);
4197
4198 /// @copydoc set_trx_length_by_cache_size
4199 /// @detail tagged version of event
4201 bool is_checksum_enabled = false,
4202 int event_counter = 0);
4203};
4204
4205/**
4206 @class Previous_gtids_log_event
4207
4208 This is the subclass of Previous_gtids_event and Log_event
4209 It is used to record the gtid_executed in the last binary log file,
4210 for ex after flush logs, or at the starting of the binary log file
4211
4212 @internal
4213 The inheritance structure is as follows
4214
4215 Binary_log_event
4216 ^
4217 |
4218 |
4219B_l:Previous_gtids_event Log_event
4220 \ /
4221 \ /
4222 \ /
4223 \ /
4224 Previous_gtids_log_event
4225
4226 B_l: Namespace Binary_log
4227 @endinternal
4228*/
4231 public Log_event {
4232 public:
4233 // disable copy-move semantics
4236 delete;
4239 delete;
4240
4241#ifdef MYSQL_SERVER
4243#endif
4244
4245#ifdef MYSQL_SERVER
4246 int pack_info(Protocol *) override;
4247#endif
4248
4250 const char *buf,
4251 const mysql::binlog::event::Format_description_event *description_event);
4252 ~Previous_gtids_log_event() override = default;
4253
4254 size_t get_data_size() override { return buf_size; }
4255
4256 void claim_memory_ownership(bool claim) override;
4257
4258#ifndef MYSQL_SERVER
4259 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4260#endif
4261#ifdef MYSQL_SERVER
4262 bool write(Basic_ostream *ostream) override {
4263#ifndef NDEBUG
4264 if (DBUG_EVALUATE_IF("skip_writing_previous_gtids_log_event", 1, 0) &&
4265 /*
4266 The skip_writing_previous_gtids_log_event debug point was designed
4267 for skipping the writing of the previous_gtids_log_event on binlog
4268 files only.
4269 */
4270 !is_relay_log_event()) {
4271 DBUG_PRINT("info",
4272 ("skip writing Previous_gtids_log_event because of"
4273 "debug option 'skip_writing_previous_gtids_log_event'"));
4274 return false;
4275 }
4276
4277 if (DBUG_EVALUATE_IF("write_partial_previous_gtids_log_event", 1, 0) &&
4278 /*
4279 The write_partial_previous_gtids_log_event debug point was designed
4280 for writing a partial previous_gtids_log_event on binlog files only.
4281 */
4282 !is_relay_log_event()) {
4283 DBUG_PRINT("info",
4284 ("writing partial Previous_gtids_log_event because of"
4285 "debug option 'write_partial_previous_gtids_log_event'"));
4286 return (Log_event::write_header(ostream, get_data_size()) ||
4288 }
4289#endif
4290
4291 return (Log_event::write_header(ostream, get_data_size()) ||
4292 Log_event::write_data_header(ostream) || write_data_body(ostream) ||
4293 Log_event::write_footer(ostream));
4294 }
4295 bool write_data_body(Basic_ostream *ostream) override;
4296#endif
4298 /// Return the encoded buffer, or NULL on error.
4299 const uchar *get_buf() { return buf; }
4300 /**
4301 Return the formatted string, or NULL on error.
4302 The string is allocated using my_malloc and it is the
4303 responsibility of the caller to free it.
4304 */
4305 char *get_str(size_t *length,
4307 /// Add all GTIDs from this event to the given Gtid_set.
4308 int add_to_set(Gtid_set *gtid_set) const;
4309 /*
4310 Previous Gtid Log events should always be skipped
4311 there is nothing to apply there, whether it is
4312 relay log's (generated on Slave) or it is binary log's
4313 (generated on Master, copied to slave as relay log).
4314 Also, we should not increment slave_skip_counter
4315 for this event, hence return EVENT_SKIP_IGNORE.
4317#if defined(MYSQL_SERVER)
4319 {
4320 return EVENT_SKIP_IGNORE;
4322
4323 int do_apply_event(Relay_log_info const *) override { return 0; }
4324 int do_update_pos(Relay_log_info *rli) override;
4325#endif
4326};
4327
4328/**
4329 @class Transaction_context_log_event
4330
4331 This is the subclass of Transaction_context_event and Log_event
4332 This class encodes the transaction_context_log_event.
4333
4334 @internal
4335 The inheritance structure is as follows
4336
4337 Binary_log_event
4338 ^
4339 |
4340 |
4341B_l:Transaction_context_event Log_event
4342 \ /
4343 \ /
4344 \ /
4345 \ /
4346 Transaction_context_log_event
4347
4348 B_l: Namespace Binary_log
4349 @endinternal
4350*/
4353 public Log_event {
4354 private:
4355 /// The Tsid_map to use for creating the Gtid_set.
4357 /// A gtid_set which is used to store the transaction set used for
4358 /// conflict detection.
4360
4361#ifdef MYSQL_SERVER
4362 bool write_data_header(Basic_ostream *ostream) override;
4363
4364 bool write_data_body(Basic_ostream *ostream) override;
4365
4367
4368 bool write_data_set(Basic_ostream *ostream, std::list<const char *> *set);
4369#endif
4370
4372
4373 static int get_data_set_size(std::list<const char *> *set);
4374
4375 size_t to_string(char *buf, ulong len) const;
4376
4377 public:
4378#ifdef MYSQL_SERVER
4379
4380 Transaction_context_log_event(const char *server_uuid_arg, bool using_trans,
4381 my_thread_id thread_id_arg,
4382 bool is_gtid_specified);
4383
4384#endif
4385
4387 const char *buffer,
4389
4391
4392 void claim_memory_ownership(bool claim) override;
4393
4394 size_t get_data_size() override;
4395
4396 size_t get_event_length();
4397
4398#ifdef MYSQL_SERVER
4399 int pack_info(Protocol *protocol) override;
4400#endif
4401
4402#ifndef MYSQL_SERVER
4403 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4404#endif
4406#if defined(MYSQL_SERVER)
4407 int do_apply_event(Relay_log_info const *) override { return 0; }
4408 int do_update_pos(Relay_log_info *rli) override;
4409#endif
4410
4411 /**
4412 Add a hash which identifies a inserted/updated/deleted row on the
4413 ongoing transaction.
4414
4415 @param[in] hash row identifier
4416 */
4417 void add_write_set(const char *hash);
4418
4419 /**
4420 Return a pointer to write-set list.
4421 */
4422 std::list<const char *> *get_write_set() { return &write_set; }
4423
4424 /**
4425 Add a hash which identifies a read row on the ongoing transaction.
4426
4427 @param[in] hash row identifier
4428 */
4429 void add_read_set(const char *hash);
4430
4431 /**
4432 Return a pointer to read-set list.
4433 */
4434 std::list<const char *> *get_read_set() { return &read_set; }
4435
4436#ifdef MYSQL_SERVER
4437 /**
4438 Read snapshot version from encoded buffers.
4439 Cannot be executed during data read from file (event constructor),
4440 since its required locks will collide with the server gtid state
4441 initialization procedure.
4442 */
4443 bool read_snapshot_version();
4444#endif
4445
4446 /**
4447 Return the transaction snapshot timestamp.
4448 */
4450
4451 /**
4452 Return the server uuid.
4453 */
4454 const char *get_server_uuid() { return server_uuid; }
4455
4456 /**
4457 Return the id of the committing thread.
4458 */
4459 my_thread_id get_thread_id() const {
4460 return static_cast<my_thread_id>(thread_id);
4461 }
4462
4463 /**
4464 Return true if transaction has GTID fully specified, false otherwise.
4465 */
4466 bool is_gtid_specified() const { return gtid_specified; }
4467};
4468
4469/**
4470 @class View_change_log_event
4471
4472 This is the subclass of View_change_log_event and Log_event
4473 This class created the view_change_log_event which is used as a marker in
4474 case a new node joins or leaves the group.
4475
4476 @internal
4477 The inheritance structure is as follows
4478
4479 Binary_log_event
4480 ^
4481 |
4482 |
4483B_l: View_change_event Log_event
4484 \ /
4485 \ /
4486 \ /
4487 \ /
4488 View_change_log_event
4489
4490 B_l: Namespace Binary_log
4491 @endinternal
4493
4495 public Log_event {
4496 private:
4497 size_t to_string(char *buf, ulong len) const;
4498
4499#ifdef MYSQL_SERVER
4500 bool write_data_header(Basic_ostream *ostream) override;
4501
4502 bool write_data_body(Basic_ostream *ostream) override;
4503
4504 bool write_data_map(Basic_ostream *ostream,
4505 std::map<std::string, std::string> *map);
4506#endif
4507
4508 size_t get_size_data_map(std::map<std::string, std::string> *map);
4509
4510 public:
4511 // disable copy-move semantics
4515 View_change_log_event &operator=(const View_change_log_event &) = delete;
4516
4517 View_change_log_event(const char *view_id);
4518
4520 const char *buffer,
4521 const mysql::binlog::event::Format_description_event *descr_event);
4522
4523 ~View_change_log_event() override;
4524
4525 void claim_memory_ownership(bool claim) override;
4526
4527 size_t get_data_size() override;
4528
4529#ifdef MYSQL_SERVER
4530 int pack_info(Protocol *protocol) override;
4531#endif
4532
4533#ifndef MYSQL_SERVER
4534 void print(FILE *file, PRINT_EVENT_INFO *print_event_info) const override;
4535#endif
4536
4537#if defined(MYSQL_SERVER)
4538 int do_apply_event(Relay_log_info const *rli) override;
4539 int do_update_pos(Relay_log_info *rli) override;
4540#endif
4541
4542 /**
4543 Returns the view id.
4544 */
4545 char *get_view_id() { return view_id; }
4546
4547 /**
4548 Sets the certification info in the event
4549
4550 @note size is calculated on this method as the size of the data
4551 might render the log even invalid. Also due to its size doing it
4552 here avoid looping over the data multiple times.
4553
4554 @param[in] info certification info to be written
4555 @param[out] event_size the event size after this operation
4556 */
4557 void set_certification_info(std::map<std::string, std::string> *info,
4558 size_t *event_size);
4559
4560 /**
4561 Returns the certification info
4562 */
4563 std::map<std::string, std::string> *get_certification_info() {
4564 return &certification_info;
4565 }
4566
4567 /**
4568 Set the certification sequence number
4569
4570 @param number the sequence number
4571 */
4572 void set_seq_number(rpl_gno number) { seq_number = number; }
4573
4574 /**
4575 Returns the certification sequence number
4576 */
4577 rpl_gno get_seq_number() { return seq_number; }
4579
4580inline bool is_any_gtid_event(const Log_event *evt) {
4582 evt->get_type_code()));
4583}
4584
4585/**
4586 Check if the given event is a session control event, one of
4587 `User_var_event`, `Intvar_event` or `Rand_event`.
4588
4589 @param evt The event to check.
4590
4591 @return true if the given event is of type `User_var_event`,
4592 `Intvar_event` or `Rand_event`, false otherwise.
4593 */
4594inline bool is_session_control_event(Log_event *evt) {
4598}
4599
4600/**
4601 The function checks the argument event properties to deduce whether
4602 it represents an atomic DDL.
4603
4604 @param evt a reference to Log_event
4605 @return true when the DDL properties are found,
4606 false otherwise
4607*/
4608inline bool is_atomic_ddl_event(Log_event const *evt) {
4609 return evt != nullptr &&
4611 static_cast<Query_log_event const *>(evt)->ddl_xid !=
4613}
4614
4615/**
4616 The function lists all DDL instances that are supported
4617 for crash-recovery (WL9175).
4618 todo: the supported feature list is supposed to grow. Once
4619 a feature has been readied for 2pc through WL7743,9536(7141/7016) etc
4620 it needs registering in the function.
4621
4622 @param thd an Query-log-event creator thread handle
4623 @param using_trans
4624 The caller must specify the value according to the following
4625 rules:
4626 @c true when
4627 - on master the current statement is not processing
4628 a table in SE which does not support atomic DDL
4629 - on slave the relay-log repository is transactional.
4630 @c false otherwise.
4631 @return true when the being created (master) or handled (slave) event
4632 is 2pc-capable, @c false otherwise.
4633*/
4634bool is_atomic_ddl(THD *thd, bool using_trans);
4635
4636#ifdef MYSQL_SERVER
4637/**
4638 Serialize an binary event to the given output stream. It is more general
4639 than call ev->write() directly. The caller will not be affected if any
4640 change happens in serialization process. For example, serializing the
4641 event in different format.
4643template <class EVENT>
4644bool binary_event_serialize(EVENT *ev, Basic_ostream *ostream) {
4645 return ev->write(ostream);
4646}
4647
4648/*
4649 This is an utility function that adds a quoted identifier into the a buffer.
4650 This also escapes any existence of the quote string inside the identifier.
4651 */
4652size_t my_strmov_quoted_identifier(THD *thd, char *buffer,
4653 const char *identifier, size_t length);
4654#else
4655size_t my_strmov_quoted_identifier(char *buffer, const char *identifier);
4656#endif
4658 const char *identifier,
4659 size_t length);
4660
4661/**
4662 Read an integer in net_field_length format, guarding against read out of
4663 bounds and advancing the position.
4664
4665 @param[in,out] packet Pointer to buffer to read from. On successful
4666 return, the buffer position will be incremented to point to the next
4667 byte after what was read.
4668
4669 @param[in,out] max_length Pointer to the number of bytes in the
4670 buffer. If the function would need to look at more than *max_length
4671 bytes in order to decode the number, the function will do nothing
4672 and return true.
4673
4674 @param[out] out Pointer where the value will be stored.
4675
4676 @retval false Success.
4677 @retval true Failure, i.e., reached end of buffer.
4678*/
4679template <typename T>
4680bool net_field_length_checked(const uchar **packet, size_t *max_length, T *out);
4681
4682/**
4683 Extract basic info about an event: type, query, is it ignorable
4684
4685 @param log_event the event to extract info from
4686 @return a pair first param is true if an error occurred, false otherwise
4687 second param is the event info
4688 */
4689std::pair<bool, mysql::binlog::event::Log_event_basic_info>
4691
4692/**
4693 Extract basic info about an event: type, query, is it ignorable
4694
4695 @param buf The event info buffer
4696 @param length The length of the buffer
4697 @param fd_event The Format description event associated
4698 @return a pair first param is true if an error occurred, false otherwise
4699 second param is the event info
4700 */
4701std::pair<bool, mysql::binlog::event::Log_event_basic_info>
4703 const char *buf, size_t length,
4705
4706/**
4707 @} (end of group Replication)
4708*/
4709
4710#endif /* _log_event_h */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
int64 query_id_t
Definition: binlog.h:73
Contains the classes representing events occurring in the replication stream.
#define LOG_EVENT_HEADER_LEN
Definition: binlog_event.h:436
This event is created to contain the file data.
Definition: log_event.h:2125
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:7027
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:7054
virtual int get_create_or_append() const
Definition: log_event.cc:7077
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:2159
size_t get_data_size() override
Definition: log_event.h:2150
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:7064
~Append_block_log_event() override=default
const char * get_db() override
Definition: log_event.h:2156
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:7107
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:2275
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:7328
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:7318
~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:7324
Delete_file_log_event is created when the LOAD_DATA query fails on the master for some reason,...
Definition: log_event.h:2197
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:7268
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:7246
size_t get_data_size() override
Definition: log_event.h:2220
~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:2228
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:7223
const char * get_db() override
Definition: log_event.h:2225
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:7256
Log row deletions.
Definition: log_event.h:3560
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:3581
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:12533
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12586
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:12553
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:12522
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3589
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12593
@ TYPE_CODE
Definition: log_event.h:3564
int do_before_row_operations(const Relay_log_info *const) override
Definition: log_event.cc:12560
Event responsible for LOAD DATA execution, it similar to Query_log_event but before executing the que...
Definition: log_event.h:2342
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:7482
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:2367
bool write_post_header_for_derived(Basic_ostream *ostream) override
Definition: log_event.cc:7392
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:7451
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:7386
ulong get_post_header_size_for_derived() override
Definition: log_event.cc:7382
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:7341
~Execute_load_query_log_event() override=default
Definition: field.h:573
For binlog version 4.
Definition: log_event.h:1558
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:5336
std::atomic< int32 > atomic_usage_counter
Definition: log_event.h:1576
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5342
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:5516
size_t get_data_size() override
Definition: log_event.h:1589
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5352
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5487
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5435
Format_description_log_event()
Format_description_log_event 1st ctor.
Definition: log_event.cc:5227
This is a subclass if Gtid_event and Log_event.
Definition: log_event.h:3977
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:13724
rpl_gno get_gno() const override
Return the GNO for this GTID.
Definition: log_event.h:4147
rpl_sidno get_sidno(bool need_lock)
Return the SIDNO relative to the global tsid_map for this GTID.
Definition: log_event.cc:13756
~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:13437
Gtid_log_event(Gtid_log_event &&) noexcept=delete
size_t get_event_length()
Definition: log_event.h:4042
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13705
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:4110
uint32 write_body_to_memory(uchar *buff)
Writes the body to the given memory buffer.
Definition: log_event.cc:13474
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:13447
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:13548
uint32 write_post_header_to_memory(uchar *buffer)
Writes the post-header to the given memory buffer.
Definition: log_event.cc:13377
static const size_t SET_STRING_PREFIX_LENGTH
Length of SET_STRING_PREFIX.
Definition: log_event.h:4157
Tsid tsid
TSID for this GTID.
Definition: log_event.h:4170
const Tsid & get_tsid() const
Return the TSID for this GTID.
Definition: log_event.h:4116
Gtid_specification get_gtid_spec()
Definition: log_event.cc:13770
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13539
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:13734
static const size_t MAX_SET_STRING_LENGTH
The maximal length of the entire "SET ..." query.
Definition: log_event.h:4159
void update_parent_gtid_info()
Updates parent tsid and gtid info structure.
Definition: log_event.cc:13202
static const char * SET_STRING_PREFIX
string holding the text "SET @@GLOBAL.GTID_NEXT = '"
Definition: log_event.h:4153
void clear_gtid_and_spec()
Clears tsid and spec.
Definition: log_event.cc:13208
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:13292
Gtid_specification spec
Internal representation of the GTID.
Definition: log_event.h:4168
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13273
size_t get_data_size() override
Definition: log_event.h:4023
size_t to_string(char *buf) const
Used internally by both print() and pack_info().
Definition: log_event.cc:13281
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:13719
Represents a set of GTIDs.
Definition: rpl_gtid.h:1558
Definition: rpl_utility.h:111
Definition: log_event.h:3880
Heartbeat_log_event_v2(const char *buf, const mysql::binlog::event::Format_description_event *description_event)
Definition: log_event.cc:14593
Definition: log_event.h:3872
Heartbeat_log_event(const char *buf, const mysql::binlog::event::Format_description_event *description_event)
Definition: log_event.cc:14586
Base class for ignorable log events is Ignorable_event.
Definition: log_event.h:3726
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12974
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:12967
size_t get_data_size() override
Definition: log_event.h:3759
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:3635
Incident_log_event(const Incident_log_event &)=delete
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:12919
size_t get_data_size() override
Definition: log_event.h:3688
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:12945
~Incident_log_event() override
Definition: log_event.cc:12833
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:12879
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:12852
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:12846
const char * description() const
Definition: log_event.cc:12837
bool ends_group() const override
Definition: log_event.h:3693
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:1634
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5832
~Intvar_log_event() override=default
Intvar_log_event(Intvar_log_event &&) noexcept=delete
size_t get_data_size() override
Definition: log_event.h:1663
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:5911
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:5842
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:5807
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:1671
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5886
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5906
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:929
Definition: key.h:113
Definition: sql_list.h:494
Definition: log_event.h:2378
bool has_replace
Definition: log_event.h:2398
const size_t BUF_SIZE
Definition: log_event.h:2387
const char * table_name
Definition: log_event.h:2394
const char * fname
Definition: log_event.h:2395
const sql_exchange * sql_ex
Definition: log_event.h:2392
THD * thd
Definition: log_event.h:2391
bool has_ignore
Definition: log_event.h:2399
String str
Definition: log_event.h:2388
const char * db
Definition: log_event.h:2393
bool is_concurrent
Definition: log_event.h:2397
const String * generate(size_t *fn_start, size_t *fn_end)
Definition: log_event.cc:7591
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:7574
This is the abstract base class for binary log events.
Definition: log_event.h:539
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:1258
ulong mts_group_idx
Index in rli->gaq array to indicate a group that this event is purging.
Definition: log_event.h:694
bool is_using_stmt_cache() const
Definition: log_event.h:846
enum_skip_reason continue_group(Relay_log_info *rli)
Helper function to ignore an event w.r.t.
Definition: log_event.cc:2476
bool is_no_filter_event() const
Definition: log_event.h:840
int apply_event(Relay_log_info *rli)
Apply the event to the database.
Definition: log_event.cc:2905
virtual int do_apply_event(Relay_log_info const *rli)
Primitive to apply an event to the database.
Definition: log_event.h:1191
virtual const char * get_db()
Definition: log_event.cc:1061
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:972
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:677
int net_send(Protocol *protocol, const char *log_name, my_off_t pos)
Only called by SHOW BINLOG EVENTS.
Definition: log_event.cc:1066
uint32 write_header_to_memory(uchar *buf)
Writes the common header of this event to the given memory buffer.
Definition: log_event.cc:1219
virtual mysql::binlog::event::Log_event_type get_type_code() const
Definition: log_event.h:804
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:1120
uint32 server_id
Definition: log_event.h:665
enum_mts_event_exec_mode
Definition: log_event.h:953
@ EVENT_EXEC_PARALLEL
Definition: log_event.h:957
@ EVENT_EXEC_SYNC
Definition: log_event.h:965
@ EVENT_EXEC_CAN_NOT
Definition: log_event.h:969
@ EVENT_EXEC_ASYNC
Definition: log_event.h:961
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:1166
bool is_valid()
Definition: log_event.cc:1311
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:1087
ha_checksum crc
Placeholder for event checksum while writing to binlog.
Definition: log_event.h:687
virtual size_t get_data_size()
Definition: log_event.h:899
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:1197
enum_event_cache_type
Definition: log_event.h:568
@ EVENT_CACHE_COUNT
Definition: log_event.h:590
@ EVENT_INVALID_CACHE
Definition: log_event.h:569
@ EVENT_NO_CACHE
Definition: log_event.h:586
@ EVENT_STMT_CACHE
Definition: log_event.h:575
@ EVENT_TRANSACTIONAL_CACHE
Definition: log_event.h:581
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:548
@ EVENT_SKIP_IGNORE
Skip event by ignoring it.
Definition: log_event.h:559
@ EVENT_SKIP_COUNT
Skip event and decrease skip counter.
Definition: log_event.h:564
@ EVENT_SKIP_NOT
Don't skip event.
Definition: log_event.h:552
bool is_mts_sequential_exec() const
Is called from get_mts_execution_mode() to.
Definition: log_event.h:929
bool m_free_temp_buf_in_destructor
Definition: log_event.h:656
bool m_claim_at_destruction
When requested (m_claim_at_destruction equal to true), will claim memory ownership before Log_event d...
Definition: log_event.h:723
bool is_relay_log_event() const
Definition: log_event.h:834
bool is_ignorable_event() const
Definition: log_event.h:837
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:717
int update_pos(Relay_log_info *rli)
Update the relay log position.
Definition: log_event.h:1158
virtual int do_apply_event_worker(Slave_worker *w)
Definition: log_event.cc:985
void set_artificial_event()
Definition: log_event.h:822
const char * get_type_str() const
Returns the human readable name of this event's type.
Definition: log_event.cc:901
time_t get_time()
Prints a "session_var=value" string.
Definition: log_event.cc:878
bool write_footer(Basic_ostream *ostream)
Definition: log_event.cc:1206
Relay_log_info * worker
MTS: associating the event with either an assigned Worker or Coordinator.
Definition: log_event.h:712
bool is_using_trans_cache() const
Definition: log_event.h:843
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:1007
int apply_csa_event(Relay_log_info *rli)
Applier_context Current applier context, attached to the agent.
Definition: log_event.cc:2871
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:730
virtual bool write(Basic_ostream *ostream)
Definition: log_event.h:792
ulong rbr_exec_mode
A storage to cache the global system variable's value.
Definition: log_event.h:671
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:700
virtual void set_mts_isolate_group()
Definition: log_event.h:1066
THD * thd
Definition: log_event.h:726
int apply_gtid_event(Relay_log_info *rli)
Apply the GTID event in curr_group_data to the database.
Definition: log_event.cc:2840
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:706
virtual bool write_data_body(Basic_ostream *)
Definition: log_event.h:801
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:937
void register_temp_buf(char *buf, bool free_in_destructor=true)
Definition: log_event.h:882
virtual uint8 mts_number_dbs()
Definition: log_event.h:1099
void free_temp_buf()
Definition: log_event.h:886
bool is_mts_group_isolated()
Definition: log_event.h:1106
ulong exec_time
Definition: log_event.h:659
virtual bool is_rbr_logging_format() const
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:815
virtual ~Log_event()
Definition: log_event.h:881
enum_event_logging_type event_logging_type
Defines when information, i.e.
Definition: log_event.h:683
enum_event_logging_type
Definition: log_event.h:593
@ EVENT_NORMAL_LOGGING
Definition: log_event.h:599
@ EVENT_IMMEDIATE_LOGGING
Definition: log_event.h:604
@ EVENT_INVALID_LOGGING
Definition: log_event.h:594
@ EVENT_CACHE_LOGGING_COUNT
Definition: log_event.h:608
void claim_at_destruction(bool claim)
When requested (claim equal to true), will claim memory ownership before Log_event destruction.
Definition: log_event.h:879
char * temp_buf
Definition: log_event.h:649
virtual bool is_sbr_logging_format() const
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:811
virtual int pack_info(Protocol *protocol)
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:1056
bool is_using_immediate_logging() const
Definition: log_event.h:849
void set_relay_log_event()
Definition: log_event.h:830
virtual bool write_data_header(Basic_ostream *)
Definition: log_event.h:800
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:1089
bool is_artificial_event() const
Definition: log_event.h:831
virtual int do_update_pos(Relay_log_info *rli)
Advance relay log coordinates.
Definition: log_event.cc:999
virtual bool ends_group() const
Definition: log_event.h:1125
bool need_checksum()
A decider of whether to trigger checksum computation or not.
Definition: log_event.cc:1118
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:869
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:2581
This is the subclass of Previous_gtids_event and Log_event It is used to record the gtid_executed in ...
Definition: log_event.h:4229
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13861
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:13868
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:13842
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13805
int do_apply_event(Relay_log_info const *) override
Primitive to apply an event to the database.
Definition: log_event.h:4321
int add_to_set(Gtid_set *gtid_set) const
Add all GTIDs from this event to the given Gtid_set.
Definition: log_event.cc:13831
size_t get_data_size() override
Definition: log_event.h:4252
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:4316
bool write(Basic_ostream *ostream) override
Definition: log_event.h:4260
~Previous_gtids_log_event() override=default
const uchar * get_buf()
Return the encoded buffer, or NULL on error.
Definition: log_event.h:4297
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:13779
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:1314
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5108
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:1520
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:1490
Query_log_event(const Query_log_event &)=delete
bool is_trans_keyword() const
Definition: log_event.h:1458
mysql::binlog::event::Log_event_header::Byte * data_buf
Definition: log_event.h:1316
bool m_skip_temp_tables_handling_by_worker
Instructs the applier to skip temporary tables handling.
Definition: log_event.h:1358
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:5158
Query_log_event()
The simplest constructor that could possibly work.
Definition: log_event.cc:3475
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:5122
virtual ulong get_post_header_size_for_derived()
Definition: log_event.h:1442
bool need_enable_cascade_triggers
Whether or not the statement represented by this event requires Q_ENABLE_CASCADE_TRIGGERS to be logge...
Definition: log_event.h:1528
bool starts_group() const override
Notice, DDL queries are logged without BEGIN/COMMIT parentheses and identification of such single-que...
Definition: log_event.h:1498
uchar mts_number_dbs() override
Definition: log_event.h:1409
my_thread_id slave_proxy_id
Definition: log_event.h:1331
void set_skip_temp_tables_handling_by_worker()
Definition: log_event.h:1360
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:5211
bool has_ddl_committed
The flag indicates whether the DDL query has been (already) committed or not.
Definition: log_event.h:1351
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:4311
~Query_log_event() override
Definition: log_event.h:1427
void attach_temp_tables_worker(THD *, const Relay_log_info *)
Associating slave Worker thread to a subset of temporary tables.
Definition: log_event.cc:4288
bool write(Basic_ostream *ostream) override
Query_log_event::write().
Definition: log_event.cc:3165
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:1339
bool is_query_prefix_match(const char *pattern, uint p_len)
Definition: log_event.h:1514
uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter) override
Definition: log_event.h:1384
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:1524
const char * get_db() override
Definition: log_event.h:1371
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:3114
bool ends_group() const override
Definition: log_event.h:1503
bool is_skip_temp_tables_handling_by_worker()
Definition: log_event.h:1364
virtual bool write_post_header_for_derived(Basic_ostream *)
Definition: log_event.h:1435
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:4302
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
Definition: log_event.h:1707
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5952
bool is_sbr_logging_format() const override
Return true if the event has to be logged using SBR for DMLs.
Definition: log_event.h:1741
~Rand_log_event() override=default
size_t get_data_size() override
Definition: log_event.h:1736
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:5997
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:5978
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5928
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5992
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:5946
Definition: rpl_rli.h:208
This will be deprecated when we move to using sequence ids.
Definition: log_event.h:2060
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:5641
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:5529
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:5783
~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:5602
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:5612
size_t get_data_size() override
Definition: log_event.h:2080
Definition: log_event.h:2690
bool is_enabled()
If instrumentation is enabled this member function SHALL return true.
Definition: log_event.h:2717
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:2763
ulonglong m_n_rows_applied
Counter that is unconditionally incremented on each row that is processed.
Definition: log_event.h:2705
ulonglong get_n_rows_applied()
Gets the value of the counter of rows that have been processed.
Definition: log_event.h:2769
Rows_applier_psi_stage()
Definition: log_event.h:2708
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:2730
void set_progress(PSI_stage_progress *progress)
Definition: log_event.h:2710
void end_work()
Resets this object.
Definition: log_event.h:2754
PSI_stage_progress * m_progress
A cached pointer to this stage PSI_stage_progress.
Definition: log_event.h:2698
Definition: log_event.h:2989
KEY ** m_key_info
Definition: log_event.h:3009
Key_compare(KEY **ki=nullptr)
Definition: log_event.h:3002
bool operator()(uchar *k1, uchar *k2) const
Definition: log_event.h:3003
Common base class for all row-containing log events.
Definition: log_event.h:2807
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:3311
uint32 m_bitbuf[128/(sizeof(uint32) *8)]
Definition: log_event.h:2970
uchar * m_rows_end
Definition: log_event.h:2979
int close_record_scan()
Does the cleanup.
Definition: log_event.cc:8853
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:8798
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:10404
virtual int do_before_row_operations(const Relay_log_info *const log)=0
uchar * m_rows_buf
Definition: log_event.h:2977
void decide_row_lookup_algorithm_and_key()
Definition: log_event.cc:8406
uint m_rows_lookup_algorithm
The algorithm to use while searching for rows using the before image.
Definition: log_event.h:2951
TABLE * m_table
Definition: log_event.h:2930
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:3111
bool is_rbr_logging_format() const override
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:3098
int do_hash_row(Relay_log_info const *rli)
Populates the m_hash when using HASH_SCAN.
Definition: log_event.cc:9235
@ RLE_NO_FLAGS
Definition: log_event.h:2843
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:2945
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:3017
int do_hash_scan_and_update(Relay_log_info const *rli)
Implementation of the hash_scan and update algorithm.
Definition: log_event.cc:9479
int add_row_data(uchar *data, size_t length)
Definition: log_event.h:2868
uint m_key_index
Definition: log_event.h:2987
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:8828
int row_operations_scan_and_key_setup()
Definition: log_event.cc:8504
MY_BITMAP const * get_cols_ai() const
Definition: log_event.h:2877
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:10266
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:2967
uchar * m_key
Definition: log_event.h:2986
int do_index_scan_and_update(Relay_log_info const *rli)
Implementation of the index scan and update algorithm.
Definition: log_event.cc:9004
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:9303
virtual int do_add_row_data(uchar *data, size_t length)
Definition: log_event.cc:8139
Rows_applier_psi_stage m_psi_progress
Definition: log_event.h:2810
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:8595
size_t get_data_size() override
Definition: log_event.cc:8106
const char * get_db() override
Definition: log_event.h:2901
uint16 flag_set
Definition: log_event.h:2820
row_lookup_mode
Definition: log_event.h:2822
@ ROW_LOOKUP_INDEX_SCAN
Definition: log_event.h:2825
@ ROW_LOOKUP_UNDEFINED
Definition: log_event.h:2823
@ ROW_LOOKUP_NOT_NEEDED
Definition: log_event.h:2824
@ ROW_LOOKUP_TABLE_SCAN
Definition: log_event.h:2826
@ ROW_LOOKUP_HASH_SCAN
Definition: log_event.h:2827
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:3236
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:8577
uchar * m_rows_cur
Definition: log_event.h:2978
const mysql::binlog::event::Table_id & get_table_id() const
Definition: log_event.h:2878
uint m_row_count
Definition: log_event.h:2904
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:9583
int next_record_scan(bool first_read)
Fetches next row.
Definition: log_event.cc:8866
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:10510
int do_table_scan_and_update(Relay_log_info const *rli)
Implementation of the legacy table_scan and update algorithm.
Definition: log_event.cc:9500
MY_BITMAP m_local_cols
Bitmap denoting columns available in the image as they appear in the table setup.
Definition: log_event.h:2939
int open_record_scan()
Initializes scanning of rows.
Definition: log_event.cc:8928
void clear_flags(flag_set flags_arg)
Definition: log_event.h:2848
virtual int do_exec_row(const Relay_log_info *const rli)=0
std::set< uchar *, Key_compare >::iterator m_itr
Definition: log_event.h:3012
enum_error
Enumeration of the errors that can be returned.
Definition: log_event.h:2833
@ ERR_TABLE_LIMIT_EXCEEDED
No more room for tables.
Definition: log_event.h:2836
@ ERR_BAD_TABLE_DEF
Table definition does not match.
Definition: log_event.h:2838
@ ERR_OPEN_FAILURE
Failure to open table.
Definition: log_event.h:2834
@ ERR_RBR_TO_SBR
daisy-chanining RBR to SBR not allowed
Definition: log_event.h:2839
@ ERR_OUT_OF_MEM
Out of memory.
Definition: log_event.h:2837
@ ERR_OK
No error.
Definition: log_event.h:2835
int row_operations_scan_and_key_teardown(int error)
Definition: log_event.cc:8547
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:8083
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:2876
std::set< uchar *, Key_compare > m_distinct_keys
Definition: log_event.h:3011
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:8710
Rows_log_event(Rows_log_event &&) noexcept=delete
const uchar * m_curr_row
Definition: log_event.h:2984
MY_BITMAP m_cols_ai
Bitmap for columns available in the after image, if present.
Definition: log_event.h:2960
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:8984
KEY * m_key_info
Definition: log_event.h:2988
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:7990
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:10372
~Rows_log_event() override
Definition: log_event.cc:7970
void set_flags(flag_set flags_arg)
Definition: log_event.h:2847
friend class Old_rows_log_event
Definition: log_event.h:3303
const uchar * m_curr_row_end
Definition: log_event.h:2985
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:10477
uint32 m_bitbuf_ai[128/(sizeof(uint32) *8)]
Definition: log_event.h:2971
MY_BITMAP m_cols
Definition: log_event.h:2932
It is used to record the original query for the rows events in RBR.
Definition: log_event.h:3798
size_t get_data_size() override
Definition: log_event.h:3847
~Rows_query_log_event() override
Definition: log_event.h:3840
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:13106
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:13089
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:13004
int pack_info(Protocol *) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13011
Rows_query_log_event(THD *thd_arg, const char *query, size_t query_len)
Definition: log_event.h:3801
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:55
Definition: rpl_rli_pdb.h:470
Definition: log_event.h:1984
mysql::binlog::event::Log_event_type get_type_code() const override
Definition: log_event.h:2013
Stop_log_event()
Definition: log_event.h:1993
~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:6948
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:2022
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:6968
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:2462
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:11063
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:10928
Table_map_log_event(const Table_map_log_event &)=delete
uint8 mts_number_dbs() override
Definition: log_event.h:2554
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:11072
const char * get_db_name() const
Definition: log_event.h:2546
virtual int save_field_metadata()
Save the field metadata based on the real_type of the field.
Definition: log_event.cc:10598
bool init_set_str_value_field()
Definition: log_event.cc:11380
flag_set get_flags(flag_set flag) const
Definition: log_event.h:2508
~Table_map_log_event() override
bool init_geometry_type_field()
Definition: log_event.cc:11428
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:11274
bool init_primary_key_field()
Definition: log_event.cc:11459
enum_flag
Definition: log_event.h:2485
@ ENUM_FLAG_COUNT
Nothing here right now, but the flags support is there in preparation for changes that are coming.
Definition: log_event.h:2492
bool is_rbr_logging_format() const override
Return true if the event has to be logged using RBR for DMLs.
Definition: log_event.h:2616
const mysql::binlog::event::Table_id & get_table_id() const
Definition: log_event.h:2542
bool init_column_visibility_field()
Definition: log_event.cc:11507
const char * get_table_name() const
Definition: log_event.h:2545
uint8 get_mts_dbs(Mts_db_names *arg, Rpl_filter *rpl_filter) override
Definition: log_event.h:2566
@ TYPE_CODE
Definition: log_event.h:2471
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:11077
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:11091
bool init_enum_str_value_field()
Definition: log_event.cc:11407
bool init_column_name_field()
Definition: log_event.cc:11368
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:2640
const char * get_db() override
Definition: log_event.h:2553
size_t get_data_size() override
Definition: log_event.h:2548
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:11539
TABLE * m_table
Definition: log_event.h:2626
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:10809
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:11220
enum_error
Enumeration of the errors that can be returned.
Definition: log_event.h:2476
@ ERR_OK
No error.
Definition: log_event.h:2478
@ ERR_TABLE_LIMIT_EXCEEDED
No more room for tables.
Definition: log_event.h:2479
@ ERR_OPEN_FAILURE
Failure to open table.
Definition: log_event.h:2477
@ ERR_OUT_OF_MEM
Out of memory.
Definition: log_event.h:2480
@ ERR_BAD_TABLE_DEF
Table definition does not match.
Definition: log_event.h:2481
@ ERR_RBR_TO_SBR
daisy-chanining RBR to SBR not allowed
Definition: log_event.h:2482
bool has_generated_invisible_primary_key() const
Definition: log_event.cc:10805
bool init_vector_dimensionality_field()
Definition: log_event.cc:11445
StringBuffer< 1024 > m_metadata_buf
Definition: log_event.h:2629
@ TM_GENERATED_INVISIBLE_PK_F
Table has generated invisible primary key.
Definition: log_event.h:2505
@ TM_BIT_LEN_EXACT_F
Definition: log_event.h:2498
@ TM_NO_FLAGS
Definition: log_event.h:2497
@ TM_REFERRED_FK_DB_F
Definition: log_event.h:2499
bool init_signedness_field()
Definition: log_event.cc:11243
This is the subclass of Transaction_context_event and Log_event This class encodes the transaction_co...
Definition: log_event.h:4351
static int get_data_set_size(std::list< const char * > *set)
Definition: log_event.cc:14103
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:14115
my_thread_id get_thread_id() const
Return the id of the committing thread.
Definition: log_event.h:4457
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:13877
void add_read_set(const char *hash)
Add a hash which identifies a read row on the ongoing transaction.
Definition: log_event.cc:14120
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:13995
Gtid_set * get_snapshot_version()
Return the transaction snapshot timestamp.
Definition: log_event.h:4447
size_t get_data_size() override
Definition: log_event.cc:14002
int do_apply_event(Relay_log_info const *) override
Primitive to apply an event to the database.
Definition: log_event.h:4405
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:13970
bool read_snapshot_version()
Read snapshot version from encoded buffers.
Definition: log_event.cc:14082
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:13962
Gtid_set * snapshot_version
A gtid_set which is used to store the transaction set used for conflict detection.
Definition: log_event.h:4357
size_t get_event_length()
Definition: log_event.cc:14014
Tsid_map * tsid_map
The Tsid_map to use for creating the Gtid_set.
Definition: log_event.h:4354
std::list< const char * > * get_read_set()
Return a pointer to read-set list.
Definition: log_event.h:4432
size_t get_snapshot_version_size()
Definition: log_event.cc:14097
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:14019
bool is_gtid_specified() const
Return true if transaction has GTID fully specified, false otherwise.
Definition: log_event.h:4464
~Transaction_context_log_event() override
Definition: log_event.cc:13945
bool write_data_set(Basic_ostream *ostream, std::list< const char * > *set)
Definition: log_event.cc:14063
std::list< const char * > * get_write_set()
Return a pointer to write-set list.
Definition: log_event.h:4420
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:14035
size_t to_string(char *buf, ulong len) const
Definition: log_event.cc:13956
const char * get_server_uuid()
Return the server uuid.
Definition: log_event.h:4452
bool write_snapshot_version(Basic_ostream *ostream)
Definition: log_event.cc:14047
Definition: log_event.h:3901
size_t get_event_length()
Definition: log_event.h:3937
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:14347
bool apply_payload_event(Relay_log_info const *rli, const uchar *event_buf)
Definition: log_event.cc:14404
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:14492
bool ends_group() const override
Definition: log_event.cc:14539
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:14497
~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:14529
size_t get_data_size() override
Definition: log_event.cc:14339
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:3905
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:14353
Represents a bidirectional map between TSID and SIDNO.
Definition: rpl_gtid.h:751
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:3440
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12752
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:12639
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:12667
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:3473
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:12712
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12745
@ TYPE_CODE
Definition: log_event.h:3444
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:12719
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3482
~Update_rows_log_event() override
Definition: log_event.cc:12690
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:9177
void init(MY_BITMAP const *cols)
Definition: log_event.cc:12674
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:1915
~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:1969
bool is_deferred()
Definition: log_event.h:1958
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:6896
query_id_t query_id
Definition: log_event.h:1925
void set_deferred(query_id_t qid)
Definition: log_event.h:1963
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6515
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:6784
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:6915
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:6901
bool deferred
Definition: log_event.h:1924
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6613
This is the subclass of View_change_log_event and Log_event This class created the view_change_log_ev...
Definition: log_event.h:4493
std::map< std::string, std::string > * get_certification_info()
Returns the certification info.
Definition: log_event.h:4561
int do_update_pos(Relay_log_info *rli) override
Advance relay log coordinates.
Definition: log_event.cc:14260
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:14187
bool write_data_body(Basic_ostream *ostream) override
Definition: log_event.cc:14277
void set_seq_number(rpl_gno number)
Set the certification sequence number.
Definition: log_event.h:4570
char * get_view_id()
Returns the view id.
Definition: log_event.h:4543
size_t get_size_data_map(std::map< std::string, std::string > *map)
Definition: log_event.cc:14168
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:14193
size_t get_data_size() override
Definition: log_event.cc:14159
bool write_data_header(Basic_ostream *ostream) override
Definition: log_event.cc:14266
int do_apply_event(Relay_log_info const *rli) override
Primitive to apply an event to the database.
Definition: log_event.cc:14219
rpl_gno get_seq_number()
Returns the certification sequence number.
Definition: log_event.h:4575
bool write_data_map(Basic_ostream *ostream, std::map< std::string, std::string > *map)
Definition: log_event.cc:14285
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:14321
View_change_log_event(const View_change_log_event &)=delete
size_t to_string(char *buf, ulong len) const
Definition: log_event.cc:14182
Log row insertions and updates.
Definition: log_event.h:3351
int do_before_row_operations(const Relay_log_info *const) override
Definition: log_event.cc:12025
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:12508
mysql::binlog::event::Log_event_type get_general_type_code() override
Definition: log_event.h:3384
@ TYPE_CODE
Definition: log_event.h:3355
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:11995
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:3373
int do_exec_row(const Relay_log_info *const) override
Definition: log_event.cc:12485
int write_row(const Relay_log_info *const, const bool)
Write the current row into event's table.
Definition: log_event.cc:12214
int do_after_row_operations(const Relay_log_info *const, int) override
Definition: log_event.cc:12133
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:12005
Similar to Xid_log_event except that.
Definition: log_event.h:1854
static const int xid_bufs_size
Definition: log_event.h:1857
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:6471
XA_prepare_log_event(THD *thd_arg, XID *xid_arg, bool one_phase_arg=false)
Definition: log_event.h:1861
size_t get_data_size() override
Definition: log_event.h:1877
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6409
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:6437
int pack_info(Protocol *protocol) override
Stores a string representation of this event in the Protocol.
Definition: log_event.cc:6395
mysql::binlog::event::Log_event_type get_type_code() const override
Definition: log_event.h:1874
Definition: log_event.h:1780
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:6381
bool ends_group() const override
Definition: log_event.h:1793
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:1783
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:6132
~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:6205
This is the subclass of Xid_event defined in libbinlogevent, An XID event is generated for a commit o...
Definition: log_event.h:1803
~Xid_log_event() override=default
bool write(Basic_ostream *ostream) override
Definition: log_event.cc:6058
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:6035
size_t get_data_size() override
Definition: log_event.h:1829
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:6091
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:6052
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:172
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:875
@ IGNORABLE_HEADER_LEN
Definition: binlog_event.h:889
@ FORMAT_DESCRIPTION_HEADER_LEN
Definition: binlog_event.h:879
@ INCIDENT_HEADER_LEN
Definition: binlog_event.h:887
@ DELETE_FILE_HEADER_LEN
Definition: binlog_event.h:876
@ ROTATE_HEADER_LEN
Definition: binlog_event.h:873
const Log_event_header * header() const
Return a const pointer to the header of the log event.
Definition: binlog_event.h:952
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:960
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:1144
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:947
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:512
The Common-Header always has the same form and length within one version of MySQL.
Definition: binlog_event.h:678
unsigned long long log_pos
Definition: binlog_event.h:709
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:724
Log_event_type type_code
Event type extracted from the header.
Definition: binlog_event.h:694
void set_is_valid(bool is_valid)
Set if the event object shall be considered valid or not.
Definition: binlog_event.h:758
uint16_t flags
Definition: binlog_event.h:717
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:470
const char * db
Definition: statement_events.h:559
const char * query
Definition: statement_events.h:558
unsigned char mts_accessed_dbs
Definition: statement_events.h:664
char mts_accessed_db_names[MAX_DBS_IN_EVENT_MTS][NAME_LEN]
Definition: statement_events.h:665
size_t q_len
Definition: statement_events.h:611
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
Definition: statement_events.h:1059
Rand_event(unsigned long long seed1_arg, unsigned long long seed2_arg)
Definition: statement_events.h:1069
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:959
enum_flag get_flags() const
Definition: rows_event.h:1039
uint16_t m_flags
Definition: rows_event.h:960
Rows query event type, which is a subclass of the Ignorable_event, to record the original query for t...
Definition: rows_event.h:1185
char * m_rows_query
Definition: rows_event.h:1215
size_t m_rows_query_length
Definition: rows_event.h:1216
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:990
Log row updates with a before image.
Definition: rows_event.h:1125
Written every time a statement uses a user variable; precedes other events for the statement.
Definition: statement_events.h:830
const char * name
Definition: statement_events.h:879
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:846
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:1107
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:250
static uint vector_column_count(const unsigned char *types, ulong size)
Return the number of VECTOR columns.
Definition: rpl_utility.h:324
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:491
#define MY_WME
Definition: my_sys.h:136
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:293
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:14653
size_t my_strmov_quoted_identifier(THD *thd, char *buffer, const char *identifier, size_t length)
Definition: log_event.cc:14613
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:4606
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:804
bool binary_event_serialize(EVENT *ev, Basic_ostream *ostream)
Serialize an binary event to the given output stream.
Definition: log_event.h:4642
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:764
TYPELIB binlog_checksum_typelib
Definition: log_event.cc:224
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:3621
int ignored_error_code(int err_code)
Ignore error code specified on command line.
Definition: log_event.cc:610
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:4578
size_t my_strmov_quoted_identifier_helper(int q, char *buffer, const char *identifier, size_t length)
Definition: log_event.cc:14626
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:4592
PSI_memory_key key_memory_Rows_query_log_event_rows_query
Definition: log_event.cc:199
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:3853
PSI_memory_key key_memory_Incident_log_event_message
Definition: log_event.cc:198
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:6017
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:822
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:7744
#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:856
#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:943
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:1319
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:279
@ INCIDENT_EVENT
Something out of the ordinary happened on the master.
Definition: binlog_event.h:323
@ FORMAT_DESCRIPTION_EVENT
Definition: binlog_event.h:305
@ EXECUTE_LOAD_QUERY_EVENT
Definition: binlog_event.h:308
@ ROWS_QUERY_LOG_EVENT
Definition: binlog_event.h:338
@ WRITE_ROWS_EVENT
Version 2 of the Row events.
Definition: binlog_event.h:341
@ DELETE_ROWS_EVENT
Definition: binlog_event.h:343
@ XA_PREPARE_LOG_EVENT
Definition: binlog_event.h:355
@ QUERY_EVENT
Definition: binlog_event.h:293
@ UNKNOWN_EVENT
Every time you add a type, you have to.
Definition: binlog_event.h:287
@ PREVIOUS_GTIDS_LOG_EVENT
Definition: binlog_event.h:348
@ UPDATE_ROWS_EVENT
Definition: binlog_event.h:342
@ RAND_EVENT
Definition: binlog_event.h:303
@ TABLE_MAP_EVENT
Definition: binlog_event.h:310
@ STOP_EVENT
Definition: binlog_event.h:294
@ INTVAR_EVENT
Definition: binlog_event.h:296
@ USER_VAR_EVENT
Definition: binlog_event.h:304
@ ROTATE_EVENT
Definition: binlog_event.h:295
@ SLAVE_EVENT
Definition: binlog_event.h:298
const uint64_t INVALID_XID
The following constant represents the maximum of MYSQL_XID domain.
Definition: statement_events.h:51
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
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
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:2732
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2742
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:114
const int MAX_GNO_TEXT_LENGTH
The length of MAX_GNO when printed in decimal.
Definition: rpl_gtid.h:288
enum_gtid_type
Enumeration of different types of values for Gtid_specification, i.e, the different internal states t...
Definition: rpl_gtid.h:3917
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:110
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:1259
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:1904
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:4034
enum_gtid_type type
The type of this GTID.
Definition: rpl_gtid.h:4047
Gtid gtid
The GTID: { SIDNO, GNO } if type == GTID; { 0, 0 } if type == AUTOMATIC or ANONYMOUS.
Definition: rpl_gtid.h:4053
rpl_gno gno
GNO of this Gtid.
Definition: rpl_gtid.h:1108
Definition: my_sys.h:342
const char * str
Definition: mysql_lex_string.h:41
Definition: my_bitmap.h:43
Definition: log_event.h:508
const char * name[MAX_DBS_IN_EVENT_MTS]
Definition: log_event.h:509
int num
Definition: log_event.h:510
Mts_db_names()=default
void reset_and_dispose()
Definition: log_event.h:514
Interface for an instrumented stage progress.
Definition: psi_stage_bits.h:63
LEX_CSTRING db
Definition: table.h:809
Definition: table.h:1456
TABLE_SHARE * s
Definition: table.h:1457
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:392
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
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:4113
static uint64_t cache_size
Definition: xcom_cache.cc:363