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