1
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
17
@addtogroup Replication
22
@brief Binary log event definitions. This includes generic code
23
common to all types of log events, as well as specific code for each
31
#if defined(USE_PRAGMA_INTERFACE) && defined(MYSQL_SERVER)
32
#pragma interface /* gcc class implementation */
35
#include <my_bitmap.h>
36
#include "rpl_constants.h"
39
#include "sql_const.h"
40
#include "rpl_utility.h"
42
#include "rpl_tblmap.h"
46
#include "rpl_record.h"
47
#include "rpl_reporting.h"
48
#include "sql_class.h" /* THD */
51
/* Forward declarations */
54
#define PREFIX_SQL_LOAD "SQL_LOAD-"
55
#define LONG_FIND_ROW_THRESHOLD 60 /* seconds */
58
Either assert or return an error.
60
In debug build, the condition will be checked, but in non-debug
61
builds, the error code given will be returned instead.
63
@param COND Condition to check
64
@param ERRNO Error number to return in non-debug builds
67
#define ASSERT_OR_RETURN_ERROR(COND, ERRNO) \
68
do { if (!(COND)) return ERRNO; } while (0)
70
#define ASSERT_OR_RETURN_ERROR(COND, ERRNO) \
74
#define LOG_READ_EOF -1
75
#define LOG_READ_BOGUS -2
76
#define LOG_READ_IO -3
77
#define LOG_READ_MEM -5
78
#define LOG_READ_TRUNC -6
79
#define LOG_READ_TOO_LARGE -7
80
#define LOG_READ_CHECKSUM_FAILURE -8
82
#define LOG_EVENT_OFFSET 4
85
3 is MySQL 4.x; 4 is MySQL 5.0.0.
86
Compared to version 3, version 4 has:
87
- a different Start_log_event, which includes info about the binary log
88
(sizes of headers); this info is included for better compatibility if the
89
master's MySQL version is different from the slave's.
90
- all events have a unique ID (the triplet (server_id, timestamp at server
91
start, other) to be sure an event is not executed more than once in a
92
multimaster setup, example:
100
if a query is run on M1, it will arrive twice on S, so we need that S
101
remembers the last unique ID it has processed, to compare and know if the
102
event should be skipped or not. Example of ID: we already have the server id
104
timestamp_when_the_master_started (4 bytes), a counter (a sequence number
105
which increments every time we write an event to the binlog) (3 bytes).
106
Q: how do we handle when the counter is overflowed and restarts from 0 ?
108
- Query and Load (Create or Execute) events may have a more precise
109
timestamp (with microseconds), number of matched/affected/warnings rows
110
and fields of session variables: SQL_MODE,
111
FOREIGN_KEY_CHECKS, UNIQUE_CHECKS, SQL_AUTO_IS_NULL, the collations and
112
charsets, the PASSWORD() version (old/new/...).
114
#define BINLOG_VERSION 4
117
We could have used SERVER_VERSION_LENGTH, but this introduces an
118
obscure dependency - if somebody decided to change SERVER_VERSION_LENGTH
119
this would break the replication protocol
121
#define ST_SERVER_VER_LEN 50
124
These are flags and structs to handle all the LOAD DATA INFILE options (LINES
129
These are flags and structs to handle all the LOAD DATA INFILE options (LINES
131
DUMPFILE_FLAG is probably useless (DUMPFILE is a clause of SELECT, not of LOAD
134
#define DUMPFILE_FLAG 0x1
135
#define OPT_ENCLOSED_FLAG 0x2
136
#define REPLACE_FLAG 0x4
137
#define IGNORE_FLAG 0x8
139
#define FIELD_TERM_EMPTY 0x1
140
#define ENCLOSED_EMPTY 0x2
141
#define LINE_TERM_EMPTY 0x4
142
#define LINE_START_EMPTY 0x8
143
#define ESCAPED_EMPTY 0x10
145
/*****************************************************************************
149
****************************************************************************/
161
#define NUM_LOAD_DELIM_STRS 5
163
/*****************************************************************************
167
****************************************************************************/
170
sql_ex_info() {} /* Remove gcc warning */
171
const char* field_term;
172
const char* enclosed;
173
const char* line_term;
174
const char* line_start;
176
int cached_new_format;
177
uint8 field_term_len,enclosed_len,line_term_len,line_start_len, escaped_len;
181
// store in new format even if old is possible
182
void force_new_format() { cached_new_format = 1;}
185
return (new_format() ?
186
field_term_len + enclosed_len + line_term_len +
187
line_start_len + escaped_len + 6 : 7);
189
bool write_data(IO_CACHE* file);
190
const char* init(const char* buf, const char* buf_end, bool use_new_format);
193
return ((cached_new_format != -1) ? cached_new_format :
194
(cached_new_format=(field_term_len > 1 ||
196
line_term_len > 1 || line_start_len > 1 ||
201
/*****************************************************************************
205
This log consists of events. Each event has a fixed-length header,
206
possibly followed by a variable length data body.
208
The data body consists of an optional fixed length segment (post-header)
209
and an optional variable length segment.
211
See the #defines below for the format specifics.
213
The events which really update data are Query_log_event,
214
Execute_load_query_log_event and old Load_log_event and
215
Execute_load_log_event events (Execute_load_query is used together with
216
Begin_load_query and Append_block events to replicate LOAD DATA INFILE.
217
Create_file/Append_block/Execute_load (which includes Load_log_event)
218
were used to replicate LOAD DATA before the 5.0.3).
220
****************************************************************************/
222
#define LOG_EVENT_HEADER_LEN 19 /* the fixed header length */
223
#define OLD_HEADER_LEN 13 /* the fixed header length in 3.23 */
225
Fixed header length, where 4.x and 5.0 agree. That is, 5.0 may have a longer
226
header (it will for sure when we have the unique event's ID), but at least
227
the first 19 bytes are the same in 4.x and 5.0. So when we have the unique
228
event's ID, LOG_EVENT_HEADER_LEN will be something like 26, but
229
LOG_EVENT_MINIMAL_HEADER_LEN will remain 19.
231
#define LOG_EVENT_MINIMAL_HEADER_LEN 19
233
/* event-specific post-header sizes */
234
// where 3.23, 4.x and 5.0 agree
235
#define QUERY_HEADER_MINIMAL_LEN (4 + 4 + 1 + 2)
236
// where 5.0 differs: 2 for len of N-bytes vars.
237
#define QUERY_HEADER_LEN (QUERY_HEADER_MINIMAL_LEN + 2)
238
#define STOP_HEADER_LEN 0
239
#define LOAD_HEADER_LEN (4 + 4 + 4 + 1 +1 + 4)
240
#define SLAVE_HEADER_LEN 0
241
#define START_V3_HEADER_LEN (2 + ST_SERVER_VER_LEN + 4)
242
#define ROTATE_HEADER_LEN 8 // this is FROZEN (the Rotate post-header is frozen)
243
#define INTVAR_HEADER_LEN 0
244
#define CREATE_FILE_HEADER_LEN 4
245
#define APPEND_BLOCK_HEADER_LEN 4
246
#define EXEC_LOAD_HEADER_LEN 4
247
#define DELETE_FILE_HEADER_LEN 4
248
#define NEW_LOAD_HEADER_LEN LOAD_HEADER_LEN
249
#define RAND_HEADER_LEN 0
250
#define USER_VAR_HEADER_LEN 0
251
#define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES)
252
#define XID_HEADER_LEN 0
253
#define BEGIN_LOAD_QUERY_HEADER_LEN APPEND_BLOCK_HEADER_LEN
254
#define ROWS_HEADER_LEN 8
255
#define TABLE_MAP_HEADER_LEN 8
256
#define EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN (4 + 4 + 4 + 1)
257
#define EXECUTE_LOAD_QUERY_HEADER_LEN (QUERY_HEADER_LEN + EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN)
258
#define INCIDENT_HEADER_LEN 2
259
#define HEARTBEAT_HEADER_LEN 0
260
#define ANNOTATE_ROWS_HEADER_LEN 0
263
Max number of possible extra bytes in a replication event compared to a
264
packet (i.e. a query) sent from client to master;
265
First, an auxiliary log_event status vars estimation:
267
#define MAX_SIZE_LOG_EVENT_STATUS (1 + 4 /* type, flags2 */ + \
268
1 + 8 /* type, sql_mode */ + \
269
1 + 1 + 255 /* type, length, catalog */ + \
270
1 + 4 /* type, auto_increment */ + \
271
1 + 6 /* type, charset */ + \
272
1 + 1 + 255 /* type, length, time_zone */ + \
273
1 + 2 /* type, lc_time_names_number */ + \
274
1 + 2 /* type, charset_database_number */ + \
275
1 + 8 /* type, table_map_for_update */ + \
276
1 + 4 /* type, master_data_written */ + \
277
1 + 3 /* type, sec_part of NOW() */ + \
278
1 + 16 + 1 + 60/* type, user_len, user, host_len, host */)
279
#define MAX_LOG_EVENT_HEADER ( /* in order of Query_log_event::write */ \
280
LOG_EVENT_HEADER_LEN + /* write_header */ \
281
QUERY_HEADER_LEN + /* write_data */ \
282
EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN + /*write_post_header_for_derived */ \
283
MAX_SIZE_LOG_EVENT_STATUS + /* status */ \
287
The new option is added to handle large packets that are sent from the master
288
to the slave. It is used to increase the thd(max_allowed) for both the
289
DUMP thread on the master and the SQL/IO thread on the slave.
291
#define MAX_MAX_ALLOWED_PACKET 1024*1024*1024
294
Event header offsets;
295
these point to places inside the fixed header.
298
#define EVENT_TYPE_OFFSET 4
299
#define SERVER_ID_OFFSET 5
300
#define EVENT_LEN_OFFSET 9
301
#define LOG_POS_OFFSET 13
302
#define FLAGS_OFFSET 17
304
/* start event post-header (for v3 and v4) */
306
#define ST_BINLOG_VER_OFFSET 0
307
#define ST_SERVER_VER_OFFSET 2
308
#define ST_CREATED_OFFSET (ST_SERVER_VER_OFFSET + ST_SERVER_VER_LEN)
309
#define ST_COMMON_HEADER_LEN_OFFSET (ST_CREATED_OFFSET + 4)
311
/* slave event post-header (this event is never written) */
313
#define SL_MASTER_PORT_OFFSET 8
314
#define SL_MASTER_POS_OFFSET 0
315
#define SL_MASTER_HOST_OFFSET 10
317
/* query event post-header */
319
#define Q_THREAD_ID_OFFSET 0
320
#define Q_EXEC_TIME_OFFSET 4
321
#define Q_DB_LEN_OFFSET 8
322
#define Q_ERR_CODE_OFFSET 9
323
#define Q_STATUS_VARS_LEN_OFFSET 11
324
#define Q_DATA_OFFSET QUERY_HEADER_LEN
325
/* these are codes, not offsets; not more than 256 values (1 byte). */
326
#define Q_FLAGS2_CODE 0
327
#define Q_SQL_MODE_CODE 1
329
Q_CATALOG_CODE is catalog with end zero stored; it is used only by MySQL
330
5.0.x where 0<=x<=3. We have to keep it to be able to replicate these
333
#define Q_CATALOG_CODE 2
334
#define Q_AUTO_INCREMENT 3
335
#define Q_CHARSET_CODE 4
336
#define Q_TIME_ZONE_CODE 5
338
Q_CATALOG_NZ_CODE is catalog withOUT end zero stored; it is used by MySQL
339
5.0.x where x>=4. Saves one byte in every Query_log_event in binlog,
340
compared to Q_CATALOG_CODE. The reason we didn't simply re-use
341
Q_CATALOG_CODE is that then a 5.0.3 slave of this 5.0.x (x>=4) master would
342
crash (segfault etc) because it would expect a 0 when there is none.
344
#define Q_CATALOG_NZ_CODE 6
346
#define Q_LC_TIME_NAMES_CODE 7
348
#define Q_CHARSET_DATABASE_CODE 8
350
#define Q_TABLE_MAP_FOR_UPDATE_CODE 9
352
#define Q_MASTER_DATA_WRITTEN_CODE 10
358
/* Intvar event post-header */
360
/* Intvar event data */
361
#define I_TYPE_OFFSET 0
362
#define I_VAL_OFFSET 1
364
/* Rand event data */
365
#define RAND_SEED1_OFFSET 0
366
#define RAND_SEED2_OFFSET 8
368
/* User_var event data */
369
#define UV_VAL_LEN_SIZE 4
370
#define UV_VAL_IS_NULL 1
371
#define UV_VAL_TYPE_SIZE 1
372
#define UV_NAME_LEN_SIZE 4
373
#define UV_CHARSET_NUMBER_SIZE 4
375
/* Load event post-header */
376
#define L_THREAD_ID_OFFSET 0
377
#define L_EXEC_TIME_OFFSET 4
378
#define L_SKIP_LINES_OFFSET 8
379
#define L_TBL_LEN_OFFSET 12
380
#define L_DB_LEN_OFFSET 13
381
#define L_NUM_FIELDS_OFFSET 14
382
#define L_SQL_EX_OFFSET 18
383
#define L_DATA_OFFSET LOAD_HEADER_LEN
385
/* Rotate event post-header */
386
#define R_POS_OFFSET 0
387
#define R_IDENT_OFFSET 8
389
/* CF to DF handle LOAD DATA INFILE */
391
/* CF = "Create File" */
392
#define CF_FILE_ID_OFFSET 0
393
#define CF_DATA_OFFSET CREATE_FILE_HEADER_LEN
395
/* AB = "Append Block" */
396
#define AB_FILE_ID_OFFSET 0
397
#define AB_DATA_OFFSET APPEND_BLOCK_HEADER_LEN
399
/* EL = "Execute Load" */
400
#define EL_FILE_ID_OFFSET 0
402
/* DF = "Delete File" */
403
#define DF_FILE_ID_OFFSET 0
405
/* TM = "Table Map" */
406
#define TM_MAPID_OFFSET 0
407
#define TM_FLAGS_OFFSET 6
410
#define RW_MAPID_OFFSET 0
411
#define RW_FLAGS_OFFSET 6
413
/* ELQ = "Execute Load Query" */
414
#define ELQ_FILE_ID_OFFSET QUERY_HEADER_LEN
415
#define ELQ_FN_POS_START_OFFSET ELQ_FILE_ID_OFFSET + 4
416
#define ELQ_FN_POS_END_OFFSET ELQ_FILE_ID_OFFSET + 8
417
#define ELQ_DUP_HANDLING_OFFSET ELQ_FILE_ID_OFFSET + 12
419
/* 4 bytes which all binlogs should begin with */
420
#define BINLOG_MAGIC (const uchar*) "\xfe\x62\x69\x6e"
423
The 2 flags below were useless :
424
- the first one was never set
425
- the second one was set in all Rotate events on the master, but not used for
427
So they are now removed and their place may later be reused for other
428
flags. Then one must remember that Rotate events in 4.x have
429
LOG_EVENT_FORCED_ROTATE_F set, so one should not rely on the value of the
430
replacing flag when reading a Rotate event.
431
I keep the defines here just to remember what they were.
434
#define LOG_EVENT_TIME_F 0x1
435
#define LOG_EVENT_FORCED_ROTATE_F 0x2
439
This flag only makes sense for Format_description_log_event. It is set
440
when the event is written, and *reset* when a binlog file is
441
closed (yes, it's the only case when MySQL modifies already written
442
part of binlog). Thus it is a reliable indicator that binlog was
443
closed correctly. (Stop_log_event is not enough, there's always a
444
small chance that mysqld crashes in the middle of insert and end of
445
the binlog would look like a Stop_log_event).
447
This flag is used to detect a restart after a crash, and to provide
448
"unbreakable" binlog. The problem is that on a crash storage engines
449
rollback automatically, while binlog does not. To solve this we use this
450
flag and automatically append ROLLBACK to every non-closed binlog (append
451
virtually, on reading, file itself is not changed). If this flag is found,
452
mysqlbinlog simply prints "ROLLBACK" Replication master does not abort on
453
binlog corruption, but takes it as EOF, and replication slave forces a
454
rollback in this case.
456
Note, that old binlogs does not have this flag set, so we get a
457
a backward-compatible behaviour.
460
#define LOG_EVENT_BINLOG_IN_USE_F 0x1
463
@def LOG_EVENT_THREAD_SPECIFIC_F
465
If the query depends on the thread (for example: TEMPORARY TABLE).
466
Currently this is used by mysqlbinlog to know it must print
467
SET @@PSEUDO_THREAD_ID=xx; before the query (it would not hurt to print it
468
for every query but this would be slow).
470
#define LOG_EVENT_THREAD_SPECIFIC_F 0x4
473
@def LOG_EVENT_SUPPRESS_USE_F
475
Suppress the generation of 'USE' statements before the actual
476
statement. This flag should be set for any events that does not need
477
the current database set to function correctly. Most notable cases
478
are 'CREATE DATABASE' and 'DROP DATABASE'.
480
This flags should only be used in exceptional circumstances, since
481
it introduce a significant change in behaviour regarding the
482
replication logic together with the flags --binlog-do-db and
485
#define LOG_EVENT_SUPPRESS_USE_F 0x8
488
Note: this is a place holder for the flag
489
LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F (0x10), which is not used any
490
more, please do not reused this value for other flags.
494
@def LOG_EVENT_ARTIFICIAL_F
496
Artificial events are created arbitarily and not written to binary
499
These events should not update the master log position when slave
500
SQL thread executes them.
502
#define LOG_EVENT_ARTIFICIAL_F 0x20
505
@def LOG_EVENT_RELAY_LOG_F
507
Events with this flag set are created by slave IO thread and written
510
#define LOG_EVENT_RELAY_LOG_F 0x40
513
@def LOG_EVENT_SKIP_REPLICATION_F
515
Flag set by application creating the event (with @@skip_replication); the
516
slave will skip replication of such events if
517
--replicate-events-marked-for-skip is not set to REPLICATE.
519
This is a MariaDB flag; we allocate it from the end of the available
520
values to reduce risk of conflict with new MySQL flags.
522
#define LOG_EVENT_SKIP_REPLICATION_F 0x8000
526
@def OPTIONS_WRITTEN_TO_BIN_LOG
528
OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must
529
be written to the binlog. OPTIONS_WRITTEN_TO_BIN_LOG could be
530
written into the Format_description_log_event, so that if later we
531
don't want to replicate a variable we did replicate, or the
532
contrary, it's doable. But it should not be too hard to decide once
533
for all of what we replicate and what we don't, among the fixed 32
534
bits of thd->options.
536
I (Guilhem) have read through every option's usage, and it looks
537
like OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only
538
ones which alter how the query modifies the table. It's good to
539
replicate OPTION_RELAXED_UNIQUE_CHECKS too because otherwise, the
540
slave may insert data slower than the master, in InnoDB.
541
OPTION_BIG_SELECTS is not needed (the slave thread runs with
542
max_join_size=HA_POS_ERROR) and OPTION_BIG_TABLES is not needed
543
either, as the manual says (because a too big in-memory temp table
544
is automatically written to disk).
546
#define OPTIONS_WRITTEN_TO_BIN_LOG \
547
(OPTION_AUTO_IS_NULL | OPTION_NO_FOREIGN_KEY_CHECKS | \
548
OPTION_RELAXED_UNIQUE_CHECKS | OPTION_NOT_AUTOCOMMIT)
550
/* Shouldn't be defined before */
551
#define EXPECTED_OPTIONS \
552
((ULL(1) << 14) | (ULL(1) << 26) | (ULL(1) << 27) | (ULL(1) << 19))
554
#if OPTIONS_WRITTEN_TO_BIN_LOG != EXPECTED_OPTIONS
555
#error OPTIONS_WRITTEN_TO_BIN_LOG must NOT change their values!
557
#undef EXPECTED_OPTIONS /* You shouldn't use this one */
559
enum enum_binlog_checksum_alg {
560
BINLOG_CHECKSUM_ALG_OFF= 0, // Events are without checksum though its generator
561
// is checksum-capable New Master (NM).
562
BINLOG_CHECKSUM_ALG_CRC32= 1, // CRC32 of zlib algorithm.
563
BINLOG_CHECKSUM_ALG_ENUM_END, // the cut line: valid alg range is [1, 0x7f].
564
BINLOG_CHECKSUM_ALG_UNDEF= 255 // special value to tag undetermined yet checksum
565
// or events from checksum-unaware servers
568
#define CHECKSUM_CRC32_SIGNATURE_LEN 4
570
defined statically while there is just one alg implemented
572
#define BINLOG_CHECKSUM_LEN CHECKSUM_CRC32_SIGNATURE_LEN
573
#define BINLOG_CHECKSUM_ALG_DESC_LEN 1 /* 1 byte checksum alg descriptor */
578
Enumeration type for the different types of log events.
583
Every time you update this enum (when you add a type), you have to
584
fix Format_description_log_event::Format_description_log_event().
594
CREATE_FILE_EVENT= 8,
595
APPEND_BLOCK_EVENT= 9,
597
DELETE_FILE_EVENT= 11,
599
NEW_LOAD_EVENT is like LOAD_EVENT except that it has a longer
600
sql_ex, allowing multibyte TERMINATED BY etc; both types share the
601
same class (Load_log_event)
606
FORMAT_DESCRIPTION_EVENT= 15,
608
BEGIN_LOAD_QUERY_EVENT= 17,
609
EXECUTE_LOAD_QUERY_EVENT= 18,
611
TABLE_MAP_EVENT = 19,
614
These event numbers were used for 5.1.0 to 5.1.15 and are
617
PRE_GA_WRITE_ROWS_EVENT = 20,
618
PRE_GA_UPDATE_ROWS_EVENT = 21,
619
PRE_GA_DELETE_ROWS_EVENT = 22,
622
These event numbers are used from 5.1.16 and forward
624
WRITE_ROWS_EVENT = 23,
625
UPDATE_ROWS_EVENT = 24,
626
DELETE_ROWS_EVENT = 25,
629
Something out of the ordinary happened on the master
634
Heartbeat event to be send by master at its idle time
635
to ensure master's online status to slave
637
HEARTBEAT_LOG_EVENT= 27,
640
Add new events here - right above this comment!
641
Existing events (except ENUM_END_EVENT) should never change their numbers
644
/* New MySQL/Sun events are to be added right above this comment */
647
MARIA_EVENTS_BEGIN= 160,
648
/* New Maria event numbers start from here */
649
ANNOTATE_ROWS_EVENT= 160,
651
/* Add new MariaDB events here - right above this comment! */
653
ENUM_END_EVENT /* end marker */
657
The number of types we handle in Format_description_log_event (UNKNOWN_EVENT
658
is not to be handled, it does not exist in binlogs, it does not have a
661
#define LOG_EVENT_TYPES (ENUM_END_EVENT-1)
665
INVALID_INT_EVENT = 0, LAST_INSERT_ID_EVENT = 1, INSERT_ID_EVENT = 2
675
class Format_description_log_event;
676
class Relay_log_info;
679
enum enum_base64_output_mode {
680
BASE64_OUTPUT_NEVER= 0,
681
BASE64_OUTPUT_AUTO= 1,
682
BASE64_OUTPUT_ALWAYS= 2,
683
BASE64_OUTPUT_UNSPEC= 3,
684
BASE64_OUTPUT_DECODE_ROWS= 4,
685
/* insert new output modes here */
686
BASE64_OUTPUT_MODE_COUNT
690
A structure for mysqlbinlog to know how to print events
692
This structure is passed to the event's print() methods,
694
There are two types of settings stored here:
695
1. Last db, flags2, sql_mode etc comes from the last printed event.
696
They are stored so that only the necessary USE and SET commands
698
2. Other information on how to print the events, e.g. short_form,
699
hexdump_from. These are not dependent on the last event.
701
typedef struct st_print_event_info
704
Settings for database, sql_mode etc that comes from the last event
705
that was printed. We cache these so that we don't have to print
706
them if they are unchanged.
708
// TODO: have the last catalog here ??
709
char db[FN_REFLEN+1]; // TODO: make this a LEX_STRING when thd->db is
712
bool sql_mode_inited;
713
ulonglong sql_mode; /* must be same as THD.variables.sql_mode */
714
ulong auto_increment_increment, auto_increment_offset;
716
char charset[6]; // 3 variables, each of them storable in 2 bytes
717
char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH];
718
uint lc_time_names_number;
719
uint charset_database_number;
721
bool thread_id_printed;
723
Track when @@skip_replication changes so we need to output a SET
726
int skip_replication;
728
st_print_event_info();
730
~st_print_event_info() {
731
close_cached_file(&head_cache);
732
close_cached_file(&body_cache);
734
bool init_ok() /* tells if construction was successful */
735
{ return my_b_inited(&head_cache) && my_b_inited(&body_cache); }
738
/* Settings on how to print the events */
740
enum_base64_output_mode base64_output_mode;
742
This is set whenever a Format_description_event is printed.
743
Later, when an event is printed in base64, this flag is tested: if
744
no Format_description_event has been seen, it is unsafe to print
745
the base64 event, so an error message is generated.
747
bool printed_fd_event;
748
my_off_t hexdump_from;
749
uint8 common_header_len;
753
table_mapping m_table_map;
754
table_mapping m_table_map_ignored;
757
These two caches are used by the row-based replication events to
758
collect the header information and the main body of the events
759
making up a statement.
767
the struct aggregates two paramenters that identify an event
768
uniquely in scope of communication of a particular master and slave couple.
769
I.e there can not be 2 events from the same staying connected master which
770
have the same coordinates.
772
Such identifier is not yet unique generally as the event originating master
773
is resetable. Also the crashed master can be replaced with some other.
775
typedef struct event_coordinates
777
char * file_name; // binlog file name (directories stripped)
778
my_off_t pos; // event's position in the binlog file
784
This is the abstract base class for binary log events.
786
@section Log_event_binary_format Binary Format
788
Any @c Log_event saved on disk consists of the following three
795
The Common-Header, documented in the table @ref Table_common_header
796
"below", always has the same form and length within one version of
797
MySQL. Each event type specifies a format and length of the
798
Post-Header. The length of the Common-Header is the same for all
799
events of the same type. The Body may be of different format and
800
length even for different events of the same type. The binary
801
formats of Post-Header and Body are documented separately in each
802
subclass. The binary format of Common-Header is as follows.
805
<caption>Common-Header</caption>
815
<td>4 byte unsigned integer</td>
816
<td>The time when the query started, in seconds since 1970.
822
<td>1 byte enumeration</td>
823
<td>See enum #Log_event_type.</td>
828
<td>4 byte unsigned integer</td>
829
<td>Server ID of the server that created the event.</td>
834
<td>4 byte unsigned integer</td>
835
<td>The total size of this event, in bytes. In other words, this
836
is the sum of the sizes of Common-Header, Post-Header, and Body.
841
<td>master_position</td>
842
<td>4 byte unsigned integer</td>
843
<td>The position of the next event in the master binary log, in
844
bytes from the beginning of the file. In a binlog that is not a
845
relay log, this is just the position of the next event, in bytes
846
from the beginning of the file. In a relay log, this is
847
the position of the next event in the master's binlog.
853
<td>2 byte bitfield</td>
854
<td>See Log_event::flags.</td>
858
Summing up the numbers above, we see that the total size of the
859
common header is 19 bytes.
861
@subsection Log_event_format_of_atomic_primitives Format of Atomic Primitives
863
- All numbers, whether they are 16-, 24-, 32-, or 64-bit numbers,
864
are stored in little endian, i.e., the least significant byte first,
865
unless otherwise specified.
867
@anchor packed_integer
868
- Some events use a special format for efficient representation of
869
unsigned integers, called Packed Integer. A Packed Integer has the
870
capacity of storing up to 8-byte integers, while small integers
871
still can use 1, 3, or 4 bytes. The value of the first byte
872
determines how to read the number, according to the following table:
875
<caption>Format of Packed Integer</caption>
884
<td>The first byte is the number (in the range 0-250), and no more
890
<td>Two more bytes are used. The number is in the range
896
<td>Three more bytes are used. The number is in the range
897
0xffff-0xffffff.</td>
902
<td>Eight more bytes are used. The number is in the range
903
0xffffff-0xffffffffffffffff.</td>
908
- Strings are stored in various formats. The format of each string
909
is documented separately.
915
Enumeration of what kinds of skipping (and non-skipping) that can
916
occur when the slave executes an event.
921
enum enum_skip_reason {
928
Skip event by ignoring it.
930
This means that the slave skip counter will not be changed.
935
Skip event and decrease skip counter.
940
enum enum_event_cache_type
944
If possible the event should use a non-transactional cache before
945
being flushed to the binary log. This means that it must be flushed
946
right after its correspondent statement is completed.
950
The event should use a transactional cache before being flushed to
951
the binary log. This means that it must be flushed upon commit or
954
EVENT_TRANSACTIONAL_CACHE,
956
The event must be written directly to the binary log without going
961
If there is a need for different types, introduce them before this.
967
The following type definition is to be used whenever data is placed
968
and manipulated in a common buffer. Use this typedef for buffers
969
that contain data containing binary and character data.
971
typedef unsigned char Byte;
974
The offset in the log where this event originally appeared (it is
975
preserved in relay logs, making SHOW SLAVE STATUS able to print
976
coordinates of the event in the master's binlog). Note: when a
977
transaction is written by the master to its binlog (wrapped in
978
BEGIN/COMMIT) the log_pos of all the queries it contains is the
979
one of the BEGIN (this way, when one does SHOW SLAVE STATUS it
980
sees the offset of the BEGIN, which is logical as rollback may
981
occur), except the COMMIT query which has its real offset.
985
A temp buffer for read_log_event; it is later analysed according to the
986
event's type, and its content is distributed in the event-specific fields.
991
TRUE <=> this event 'owns' temp_buf and should call my_free() when done
994
bool event_owns_temp_buf;
997
Timestamp on the master(for debugging and replication of
998
NOW()/TIMESTAMP). It is important for queries and LOAD DATA
999
INFILE. This is set at the event's creation time, except for Query
1000
and Load (et al.) events where this is set at the query's
1001
execution time, which guarantees good replication (otherwise, we
1002
could have a query and its event with different timestamps).
1005
ulong when_sec_part;
1006
/* The number of seconds the query took to run on the master. */
1008
/* Number of bytes written by write() function */
1012
The master's server id (is preserved in the relay log; used to
1013
prevent from infinite loops in circular replication).
1018
Some 16 flags. See the definitions above for LOG_EVENT_TIME_F,
1019
LOG_EVENT_FORCED_ROTATE_F, LOG_EVENT_THREAD_SPECIFIC_F,
1020
LOG_EVENT_SUPPRESS_USE_F, and LOG_EVENT_SKIP_REPLICATION_F for notes.
1027
A storage to cache the global system variable's value.
1028
Handling of a separate event will be governed its member.
1030
ulong slave_exec_mode;
1033
Placeholder for event checksum while writing to binlog.
1041
Log_event(THD* thd_arg, uint16 flags_arg, bool is_transactional);
1043
read_log_event() functions read an event from a binlog or relay
1044
log; used by SHOW BINLOG EVENTS, the binlog_dump thread on the
1045
master (reads master's binlog), the slave IO thread (reads the
1046
event sent by binlog_dump), the slave SQL thread (reads the event
1047
from the relay log). If mutex is 0, the read will proceed without
1048
mutex. We need the description_event to be able to parse the
1049
event (to know the post-header's size); in fact in read_log_event
1050
we detect the event's type, then call the specific event's
1051
constructor and pass description_event as an argument.
1053
static Log_event* read_log_event(IO_CACHE* file,
1054
mysql_mutex_t* log_lock,
1055
const Format_description_log_event
1060
Reads an event from a binlog or relay log. Used by the dump thread
1061
this method reads the event into a raw buffer without parsing it.
1063
@Note If mutex is 0, the read will proceed without mutex.
1065
@Note If a log name is given than the method will check if the
1066
given binlog is still active.
1068
@param[in] file log file to be read
1069
@param[out] packet packet to hold the event
1070
@param[in] lock the lock to be used upon read
1071
@param[in] log_file_name_arg the log's file name
1072
@param[out] is_binlog_active is the current log still active
1075
@retval LOG_READ_EOF end of file, nothing was read
1076
@retval LOG_READ_BOGUS malformed event
1077
@retval LOG_READ_IO io error while reading
1078
@retval LOG_READ_MEM packet memory allocation failed
1079
@retval LOG_READ_TRUNC only a partial event could be read
1080
@retval LOG_READ_TOO_LARGE event too large
1082
static int read_log_event(IO_CACHE* file, String* packet,
1083
mysql_mutex_t* log_lock,
1084
uint8 checksum_alg_arg,
1085
const char *log_file_name_arg = NULL,
1086
bool* is_binlog_active = NULL);
1088
init_show_field_list() prepares the column names and types for the
1089
output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
1092
static void init_show_field_list(List<Item>* field_list);
1093
#ifdef HAVE_REPLICATION
1094
int net_send(THD *thd, Protocol *protocol, const char* log_name,
1098
pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
1099
a string to display to the user, so it resembles print().
1102
virtual void pack_info(THD *thd, Protocol *protocol);
1104
#endif /* HAVE_REPLICATION */
1105
virtual const char* get_db()
1107
return thd ? thd->db : 0;
1110
Log_event() : temp_buf(0), flags(0) {}
1111
/* avoid having to link mysqlbinlog against libpthread */
1112
static Log_event* read_log_event(IO_CACHE* file,
1113
const Format_description_log_event
1114
*description_event, my_bool crc_check);
1115
/* print*() functions are used by mysqlbinlog */
1116
virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
1117
void print_timestamp(IO_CACHE* file, time_t *ts = 0);
1118
void print_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
1120
void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
1124
The value is set by caller of FD constructor and
1125
Log_event::write_header() for the rest.
1126
In the FD case it's propagated into the last byte
1127
of post_header_len[] at FD::write().
1128
On the slave side the value is assigned from post_header_len[last]
1129
of the last seen FD event.
1133
static void *operator new(size_t size)
1135
return (void*) my_malloc((uint)size, MYF(MY_WME|MY_FAE));
1138
static void operator delete(void *ptr, size_t)
1143
/* Placement version of the above operators */
1144
static void *operator new(size_t, void* ptr) { return ptr; }
1145
static void operator delete(void*, void*) { }
1146
bool wrapper_my_b_safe_write(IO_CACHE* file, const uchar* buf, ulong data_length);
1149
bool write_header(IO_CACHE* file, ulong data_length);
1150
bool write_footer(IO_CACHE* file);
1151
my_bool need_checksum();
1153
virtual bool write(IO_CACHE* file)
1155
return(write_header(file, get_data_size()) ||
1156
write_data_header(file) ||
1157
write_data_body(file) ||
1158
write_footer(file));
1160
virtual bool write_data_header(IO_CACHE* file)
1162
virtual bool write_data_body(IO_CACHE* file __attribute__((unused)))
1164
inline my_time_t get_time()
1171
when= thd->start_time;
1172
when_sec_part= thd->start_time_sec_part;
1175
/* thd will only be 0 here at time of log creation */
1176
if ((tmp_thd= current_thd))
1178
when= tmp_thd->start_time;
1179
when_sec_part= tmp_thd->start_time_sec_part;
1182
my_hrtime_t hrtime= my_hrtime();
1183
when= hrtime_to_my_time(hrtime);
1184
when_sec_part= hrtime_sec_part(hrtime);
1188
virtual Log_event_type get_type_code() = 0;
1189
virtual bool is_valid() const = 0;
1190
void set_artificial_event() { flags |= LOG_EVENT_ARTIFICIAL_F; }
1191
void set_relay_log_event() { flags |= LOG_EVENT_RELAY_LOG_F; }
1192
bool is_artificial_event() const { return flags & LOG_EVENT_ARTIFICIAL_F; }
1193
bool is_relay_log_event() const { return flags & LOG_EVENT_RELAY_LOG_F; }
1194
inline bool use_trans_cache() const
1196
return (cache_type == Log_event::EVENT_TRANSACTIONAL_CACHE);
1198
inline void set_direct_logging()
1200
cache_type = Log_event::EVENT_NO_CACHE;
1202
inline bool use_direct_logging()
1204
return (cache_type == Log_event::EVENT_NO_CACHE);
1206
Log_event(const char* buf, const Format_description_log_event
1207
*description_event);
1208
virtual ~Log_event() { free_temp_buf();}
1209
void register_temp_buf(char* buf, bool must_free)
1212
event_owns_temp_buf= must_free;
1214
void free_temp_buf()
1218
if (event_owns_temp_buf)
1224
Get event length for simple events. For complicated events the length
1225
is calculated during write()
1227
virtual int get_data_size() { return 0;}
1228
static Log_event* read_log_event(const char* buf, uint event_len,
1230
const Format_description_log_event
1231
*description_event, my_bool crc_check);
1233
Returns the human readable name of the given event type.
1235
static const char* get_type_str(Log_event_type type);
1237
Returns the human readable name of this event's type.
1239
const char* get_type_str();
1241
/* Return start of query time or current time */
1243
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
1247
Apply the event to the database.
1249
This function represents the public interface for applying an
1254
int apply_event(Relay_log_info const *rli)
1256
return do_apply_event(rli);
1261
Update the relay log position.
1263
This function represents the public interface for "stepping over"
1264
the event and will update the relay log information.
1268
int update_pos(Relay_log_info *rli)
1270
return do_update_pos(rli);
1274
Decide if the event shall be skipped, and the reason for skipping
1279
enum_skip_reason shall_skip(Relay_log_info *rli)
1281
return do_shall_skip(rli);
1287
Helper function to ignore an event w.r.t. the slave skip counter.
1289
This function can be used inside do_shall_skip() for functions
1290
that cannot end a group. If the slave skip counter is 1 when
1291
seeing such an event, the event shall be ignored, the counter
1292
left intact, and processing continue with the next event.
1296
enum_skip_reason do_shall_skip(Relay_log_info *rli) {
1297
return continue_group(rli);
1303
enum_skip_reason continue_group(Relay_log_info *rli);
1306
Primitive to apply an event to the database.
1308
This is where the change to the database is made.
1310
@note The primitive is protected instead of private, since there
1311
is a hierarchy of actions to be performed in some cases.
1313
@see Format_description_log_event::do_apply_event()
1315
@param rli Pointer to relay log info structure
1317
@retval 0 Event applied successfully
1318
@retval errno Error code if event application failed
1320
virtual int do_apply_event(Relay_log_info const *rli)
1322
return 0; /* Default implementation does nothing */
1327
Advance relay log coordinates.
1329
This function is called to advance the relay log coordinates to
1330
just after the event. It is essential that both the relay log
1331
coordinate and the group log position is updated correctly, since
1332
this function is used also for skipping events.
1334
Normally, each implementation of do_update_pos() shall:
1336
- Update the event position to refer to the position just after
1339
- Update the group log position to refer to the position just
1340
after the event <em>if the event is last in a group</em>
1342
@param rli Pointer to relay log info structure
1344
@retval 0 Coordinates changed successfully
1345
@retval errno Error code if advancing failed (usually just
1346
1). Observe that handler errors are returned by the
1347
do_apply_event() function, and not by this one.
1349
virtual int do_update_pos(Relay_log_info *rli);
1353
Decide if this event shall be skipped or not and the reason for
1356
The default implementation decide that the event shall be skipped
1359
- the server id of the event is the same as the server id of the
1360
server and <code>rli->replicate_same_server_id</code> is true,
1363
- if <code>rli->slave_skip_counter</code> is greater than zero.
1368
@retval Log_event::EVENT_SKIP_NOT
1369
The event shall not be skipped and should be applied.
1371
@retval Log_event::EVENT_SKIP_IGNORE
1372
The event shall be skipped by just ignoring it, i.e., the slave
1373
skip counter shall not be changed. This happends if, for example,
1374
the originating server id of the event is the same as the server
1377
@retval Log_event::EVENT_SKIP_COUNT
1378
The event shall be skipped because the slave skip counter was
1379
non-zero. The caller shall decrease the counter by one.
1381
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
1387
One class for each type of event.
1388
Two constructors for each class:
1389
- one to create the event for logging (when the server acts as a master),
1390
called after an update to the database is done,
1391
which accepts parameters like the query, the database, the options for LOAD
1393
- one to create the event from a packet (when the server acts as a slave),
1394
called before reproducing the update, which accepts parameters (like a
1395
buffer). Used to read from the master, from the relay log, and in
1396
mysqlbinlog. This constructor must be format-tolerant.
1400
@class Query_log_event
1402
A @c Query_log_event is created for each query that modifies the
1403
database, unless the query is logged row-based.
1405
@section Query_log_event_binary_format Binary format
1407
See @ref Log_event_binary_format "Binary format for log events" for
1408
a general discussion and introduction to the binary format of binlog
1411
The Post-Header has five components:
1414
<caption>Post-Header for Query_log_event</caption>
1419
<th>Description</th>
1423
<td>slave_proxy_id</td>
1424
<td>4 byte unsigned integer</td>
1425
<td>An integer identifying the client thread that issued the
1426
query. The id is unique per server. (Note, however, that two
1427
threads on different servers may have the same slave_proxy_id.)
1428
This is used when a client thread creates a temporary table local
1429
to the client. The slave_proxy_id is used to distinguish
1430
temporary tables that belong to different clients.
1436
<td>4 byte unsigned integer</td>
1437
<td>The time from when the query started to when it was logged in
1438
the binlog, in seconds.</td>
1443
<td>1 byte integer</td>
1444
<td>The length of the name of the currently selected database.</td>
1449
<td>2 byte unsigned integer</td>
1450
<td>Error code generated by the master. If the master fails, the
1451
slave will fail with the same error code, except for the error
1452
codes ER_DB_CREATE_EXISTS == 1007 and ER_DB_DROP_EXISTS == 1008.
1457
<td>status_vars_len</td>
1458
<td>2 byte unsigned integer</td>
1459
<td>The length of the status_vars block of the Body, in bytes. See
1460
@ref query_log_event_status_vars "below".
1465
The Body has the following components:
1468
<caption>Body for Query_log_event</caption>
1473
<th>Description</th>
1477
<td>@anchor query_log_event_status_vars status_vars</td>
1478
<td>status_vars_len bytes</td>
1479
<td>Zero or more status variables. Each status variable consists
1480
of one byte identifying the variable stored, followed by the value
1481
of the variable. The possible variables are listed separately in
1482
the table @ref Table_query_log_event_status_vars "below". MySQL
1483
always writes events in the order defined below; however, it is
1484
capable of reading them in any order. </td>
1490
<td>The currently selected database, as a null-terminated string.
1492
(The trailing zero is redundant since the length is already known;
1493
it is db_len from Post-Header.)
1499
<td>variable length string without trailing zero, extending to the
1500
end of the event (determined by the length field of the
1503
<td>The SQL query.</td>
1507
The following table lists the status variables that may appear in
1508
the status_vars field.
1510
@anchor Table_query_log_event_status_vars
1512
<caption>Status variables for Query_log_event</caption>
1515
<th>Status variable</th>
1516
<th>1 byte identifier</th>
1518
<th>Description</th>
1523
<td>Q_FLAGS2_CODE == 0</td>
1524
<td>4 byte bitfield</td>
1525
<td>The flags in @c thd->options, binary AND-ed with @c
1526
OPTIONS_WRITTEN_TO_BIN_LOG. The @c thd->options bitfield contains
1527
options for "SELECT". @c OPTIONS_WRITTEN identifies those options
1528
that need to be written to the binlog (not all do). Specifically,
1529
@c OPTIONS_WRITTEN_TO_BIN_LOG equals (@c OPTION_AUTO_IS_NULL | @c
1530
OPTION_NO_FOREIGN_KEY_CHECKS | @c OPTION_RELAXED_UNIQUE_CHECKS |
1531
@c OPTION_NOT_AUTOCOMMIT), or 0x0c084000 in hex.
1533
These flags correspond to the SQL variables SQL_AUTO_IS_NULL,
1534
FOREIGN_KEY_CHECKS, UNIQUE_CHECKS, and AUTOCOMMIT, documented in
1535
the "SET Syntax" section of the MySQL Manual.
1537
This field is always written to the binlog in version >= 5.0, and
1538
never written in version < 5.0.
1544
<td>Q_SQL_MODE_CODE == 1</td>
1545
<td>8 byte bitfield</td>
1546
<td>The @c sql_mode variable. See the section "SQL Modes" in the
1547
MySQL manual, and see sql_priv.h for a list of the possible
1548
flags. Currently (2007-10-04), the following flags are available:
1550
MODE_REAL_AS_FLOAT==0x1
1551
MODE_PIPES_AS_CONCAT==0x2
1552
MODE_ANSI_QUOTES==0x4
1553
MODE_IGNORE_SPACE==0x8
1554
MODE_IGNORE_BAD_TABLE_OPTIONS==0x10
1555
MODE_ONLY_FULL_GROUP_BY==0x20
1556
MODE_NO_UNSIGNED_SUBTRACTION==0x40
1557
MODE_NO_DIR_IN_CREATE==0x80
1558
MODE_POSTGRESQL==0x100
1563
MODE_NO_KEY_OPTIONS==0x2000
1564
MODE_NO_TABLE_OPTIONS==0x4000
1565
MODE_NO_FIELD_OPTIONS==0x8000
1566
MODE_MYSQL323==0x10000
1567
MODE_MYSQL323==0x20000
1568
MODE_MYSQL40==0x40000
1570
MODE_NO_AUTO_VALUE_ON_ZERO==0x100000
1571
MODE_NO_BACKSLASH_ESCAPES==0x200000
1572
MODE_STRICT_TRANS_TABLES==0x400000
1573
MODE_STRICT_ALL_TABLES==0x800000
1574
MODE_NO_ZERO_IN_DATE==0x1000000
1575
MODE_NO_ZERO_DATE==0x2000000
1576
MODE_INVALID_DATES==0x4000000
1577
MODE_ERROR_FOR_DIVISION_BY_ZERO==0x8000000
1578
MODE_TRADITIONAL==0x10000000
1579
MODE_NO_AUTO_CREATE_USER==0x20000000
1580
MODE_HIGH_NOT_PRECEDENCE==0x40000000
1581
MODE_PAD_CHAR_TO_FULL_LENGTH==0x80000000
1583
All these flags are replicated from the server. However, all
1584
flags except @c MODE_NO_DIR_IN_CREATE are honored by the slave;
1585
the slave always preserves its old value of @c
1586
MODE_NO_DIR_IN_CREATE. For a rationale, see comment in
1587
@c Query_log_event::do_apply_event in @c log_event.cc.
1589
This field is always written to the binlog.
1595
<td>Q_CATALOG_NZ_CODE == 6</td>
1596
<td>Variable-length string: the length in bytes (1 byte) followed
1597
by the characters (at most 255 bytes)
1599
<td>Stores the client's current catalog. Every database belongs
1600
to a catalog, the same way that every table belongs to a
1601
database. Currently, there is only one catalog, "std".
1603
This field is written if the length of the catalog is > 0;
1604
otherwise it is not written.
1609
<td>auto_increment</td>
1610
<td>Q_AUTO_INCREMENT == 3</td>
1611
<td>two 2 byte unsigned integers, totally 2+2=4 bytes</td>
1613
<td>The two variables auto_increment_increment and
1614
auto_increment_offset, in that order. For more information, see
1615
"System variables" in the MySQL manual.
1617
This field is written if auto_increment > 1. Otherwise, it is not
1624
<td>Q_CHARSET_CODE == 4</td>
1625
<td>three 2 byte unsigned integers, totally 2+2+2=6 bytes</td>
1626
<td>The three variables character_set_client,
1627
collation_connection, and collation_server, in that order.
1628
character_set_client is a code identifying the character set and
1629
collation used by the client to encode the query.
1630
collation_connection identifies the character set and collation
1631
that the master converts the query to when it receives it; this is
1632
useful when comparing literal strings. collation_server is the
1633
default character set and collation used when a new database is
1636
See also "Connection Character Sets and Collations" in the MySQL
1639
All three variables are codes identifying a (character set,
1640
collation) pair. To see which codes map to which pairs, run the
1641
query "SELECT id, character_set_name, collation_name FROM
1644
Cf. Q_CHARSET_DATABASE_CODE below.
1646
This field is always written.
1652
<td>Q_TIME_ZONE_CODE == 5</td>
1653
<td>Variable-length string: the length in bytes (1 byte) followed
1654
by the characters (at most 255 bytes).
1655
<td>The time_zone of the master.
1657
See also "System Variables" and "MySQL Server Time Zone Support"
1658
in the MySQL manual.
1660
This field is written if the length of the time zone string is >
1661
0; otherwise, it is not written.
1666
<td>lc_time_names_number</td>
1667
<td>Q_LC_TIME_NAMES_CODE == 7</td>
1668
<td>2 byte integer</td>
1669
<td>A code identifying a table of month and day names. The
1670
mapping from codes to languages is defined in @c sql_locale.cc.
1672
This field is written if it is not 0, i.e., if the locale is not
1678
<td>charset_database_number</td>
1679
<td>Q_CHARSET_DATABASE_CODE == 8</td>
1680
<td>2 byte integer</td>
1682
<td>The value of the collation_database system variable (in the
1683
source code stored in @c thd->variables.collation_database), which
1684
holds the code for a (character set, collation) pair as described
1685
above (see Q_CHARSET_CODE).
1687
collation_database was used in old versions (???WHEN). Its value
1688
was loaded when issuing a "use db" query and could be changed by
1689
issuing a "SET collation_database=xxx" query. It used to affect
1690
the "LOAD DATA INFILE" and "CREATE TABLE" commands.
1692
In newer versions, "CREATE TABLE" has been changed to take the
1693
character set from the database of the created table, rather than
1694
the character set of the current database. This makes a
1695
difference when creating a table in another database than the
1696
current one. "LOAD DATA INFILE" has not yet changed to do this,
1697
but there are plans to eventually do it, and to make
1698
collation_database read-only.
1700
This field is written if it is not 0.
1704
<td>table_map_for_update</td>
1705
<td>Q_TABLE_MAP_FOR_UPDATE_CODE == 9</td>
1706
<td>8 byte integer</td>
1708
<td>The value of the table map that is to be updated by the
1709
multi-table update query statement. Every bit of this variable
1710
represents a table, and is set to 1 if the corresponding table is
1711
to be updated by this statement.
1713
The value of this variable is set when executing a multi-table update
1714
statement and used by slave to apply filter rules without opening
1715
all the tables on slave. This is required because some tables may
1716
not exist on slave because of the filter rules.
1721
@subsection Query_log_event_notes_on_previous_versions Notes on Previous Versions
1723
* Status vars were introduced in version 5.0. To read earlier
1724
versions correctly, check the length of the Post-Header.
1726
* The status variable Q_CATALOG_CODE == 2 existed in MySQL 5.0.x,
1727
where 0<=x<=3. It was identical to Q_CATALOG_CODE, except that the
1728
string had a trailing '\0'. The '\0' was removed in 5.0.4 since it
1729
was redundant (the string length is stored before the string). The
1730
Q_CATALOG_CODE will never be written by a new master, but can still
1731
be understood by a new slave.
1733
* See Q_CHARSET_DATABASE_CODE in the table above.
1735
* When adding new status vars, please don't forget to update the
1736
MAX_SIZE_LOG_EVENT_STATUS, and update function code_name
1739
class Query_log_event: public Log_event
1744
Log_event::Byte* data_buf;
1747
const char* catalog;
1750
If we already know the length of the query string
1751
we pass it with q_len, so we would not have to call strlen()
1752
otherwise, set it to 0, in which case, we compute it with strlen()
1759
For events created by Query_log_event::do_apply_event (and
1760
Load_log_event::do_apply_event()) we need the *original* thread
1761
id, to be able to log the event with the original (=master's)
1762
thread id (fix for BUG#1686).
1764
ulong slave_proxy_id;
1767
Binlog format 3 and 4 start to differ (as far as class members are
1768
concerned) from here.
1771
uint catalog_len; // <= 255 char; 0 means uninited
1774
We want to be able to store a variable number of N-bit status vars:
1775
(generally N=32; but N=64 for SQL_MODE) a user may want to log the number
1776
of affected rows (for debugging) while another does not want to lose 4
1778
The storage on disk is the following:
1779
status_vars_len is part of the post-header,
1780
status_vars are in the variable-length part, after the post-header, before
1782
status_vars on disk is a sequence of pairs (code, value) where 'code' means
1783
'sql_mode', 'affected' etc. Sometimes 'value' must be a short string, so
1784
its first byte is its length. For now the order of status vars is:
1785
flags2 - sql_mode - catalog - autoinc - charset
1786
We should add the same thing to Load_log_event, but in fact
1787
LOAD DATA INFILE is going to be logged with a new type of event (logging of
1788
the plain text query), so Load_log_event would be frozen, so no need. The
1789
new way of logging LOAD DATA INFILE would use a derived class of
1790
Query_log_event, so automatically benefit from the work already done for
1791
status variables in Query_log_event.
1793
uint16 status_vars_len;
1796
'flags2' is a second set of flags (on top of those in Log_event), for
1797
session variables. These are thd->options which is & against a mask
1798
(OPTIONS_WRITTEN_TO_BIN_LOG).
1799
flags2_inited helps make a difference between flags2==0 (3.23 or 4.x
1800
master, we don't know flags2, so use the slave server's global options) and
1801
flags2==0 (5.0 master, we know this has a meaning of flags all down which
1802
must influence the query).
1805
bool sql_mode_inited;
1806
bool charset_inited;
1809
/* In connections sql_mode is 32 bits now but will be 64 bits soon */
1811
ulong auto_increment_increment, auto_increment_offset;
1813
uint time_zone_len; /* 0 means uninited */
1814
const char *time_zone_str;
1815
uint lc_time_names_number; /* 0 means en_US */
1816
uint charset_database_number;
1818
map for tables that will be updated for a multi-table update query
1819
statement, for other query statements, this will be zero.
1821
ulonglong table_map_for_update;
1823
Holds the original length of a Query_log_event that comes from a
1824
master of version < 5.0 (i.e., binlog_version < 4). When the IO
1825
thread writes the relay log, it augments the Query_log_event with a
1826
Q_MASTER_DATA_WRITTEN_CODE status_var that holds the original event
1827
length. This field is initialized to non-zero in the SQL thread when
1828
it reads this augmented event. SQL thread does not write
1829
Q_MASTER_DATA_WRITTEN_CODE to the slave's server binlog.
1831
uint32 master_data_written;
1835
Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
1836
bool using_trans, bool direct, bool suppress_use, int error);
1837
const char* get_db() { return db; }
1838
#ifdef HAVE_REPLICATION
1839
void pack_info(THD *thd, Protocol* protocol);
1840
#endif /* HAVE_REPLICATION */
1842
void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
1843
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
1847
Query_log_event(const char* buf, uint event_len,
1848
const Format_description_log_event *description_event,
1849
Log_event_type event_type);
1855
Log_event_type get_type_code() { return QUERY_EVENT; }
1857
bool write(IO_CACHE* file);
1858
virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; }
1860
bool is_valid() const { return query != 0; }
1863
Returns number of bytes additionaly written to post header by derived
1864
events (so far it is only Execute_load_query event).
1866
virtual ulong get_post_header_size_for_derived() { return 0; }
1867
/* Writes derived event-specific part of post header. */
1869
public: /* !!! Public in this patch to allow old usage */
1870
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
1871
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
1872
virtual int do_apply_event(Relay_log_info const *rli);
1873
virtual int do_update_pos(Relay_log_info *rli);
1875
int do_apply_event(Relay_log_info const *rli,
1876
const char *query_arg,
1878
#endif /* HAVE_REPLICATION */
1880
If true, the event always be applied by slave SQL thread or be printed by
1883
bool is_trans_keyword()
1886
Before the patch for bug#50407, The 'SAVEPOINT and ROLLBACK TO'
1887
queries input by user was written into log events directly.
1888
So the keywords can be written in both upper case and lower case
1889
together, strncasecmp is used to check both cases. they also could be
1890
binlogged with comments in the front of these keywords. for examples:
1891
/ * bla bla * / SAVEPOINT a;
1892
/ * bla bla * / ROLLBACK TO a;
1893
but we don't handle these cases and after the patch, both quiries are
1894
binlogged in upper case with no comments.
1896
return !strncmp(query, "BEGIN", q_len) ||
1897
!strncmp(query, "COMMIT", q_len) ||
1898
!strncasecmp(query, "SAVEPOINT", 9) ||
1899
!strncasecmp(query, "ROLLBACK", 8);
1904
#ifdef HAVE_REPLICATION
1907
@class Slave_log_event
1909
Note that this class is currently not used at all; no code writes a
1910
@c Slave_log_event (though some code in @c repl_failsafe.cc reads @c
1911
Slave_log_event). So it's not a problem if this code is not
1914
@section Slave_log_event_binary_format Binary Format
1916
This event type has no Post-Header. The Body has the following
1920
<caption>Body for Slave_log_event</caption>
1925
<th>Description</th>
1930
<td>8 byte integer</td>
1936
<td>master_port</td>
1937
<td>2 byte integer</td>
1942
<td>master_host</td>
1943
<td>null-terminated string</td>
1949
<td>null-terminated string</td>
1954
class Slave_log_event: public Log_event
1958
void init_from_mem_pool(int data_size);
1960
my_off_t master_pos;
1963
int master_host_len;
1968
Slave_log_event(THD* thd_arg, Relay_log_info* rli);
1969
void pack_info(THD *thd, Protocol* protocol);
1971
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
1974
Slave_log_event(const char* buf,
1976
const Format_description_log_event *description_event);
1978
int get_data_size();
1979
bool is_valid() const { return master_host != 0; }
1980
Log_event_type get_type_code() { return SLAVE_EVENT; }
1982
bool write(IO_CACHE* file);
1986
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
1987
virtual int do_apply_event(Relay_log_info const* rli);
1991
#endif /* HAVE_REPLICATION */
1995
@class Load_log_event
1997
This log event corresponds to a "LOAD DATA INFILE" SQL query on the
2002
(2) LOAD DATA [CONCURRENT] [LOCAL] INFILE 'file_name'
2003
(3) [REPLACE | IGNORE]
2004
(4) INTO TABLE 'table_name'
2006
(6) [TERMINATED BY 'field_term']
2007
(7) [[OPTIONALLY] ENCLOSED BY 'enclosed']
2008
(8) [ESCAPED BY 'escaped']
2011
(11) [TERMINATED BY 'line_term']
2012
(12) [LINES STARTING BY 'line_start']
2014
(14) [IGNORE skip_lines LINES]
2015
(15) (field_1, field_2, ..., field_n)@endverbatim
2017
@section Load_log_event_binary_format Binary Format
2019
The Post-Header consists of the following six components.
2022
<caption>Post-Header for Load_log_event</caption>
2027
<th>Description</th>
2031
<td>slave_proxy_id</td>
2032
<td>4 byte unsigned integer</td>
2033
<td>An integer identifying the client thread that issued the
2034
query. The id is unique per server. (Note, however, that two
2035
threads on different servers may have the same slave_proxy_id.)
2036
This is used when a client thread creates a temporary table local
2037
to the client. The slave_proxy_id is used to distinguish
2038
temporary tables that belong to different clients.
2044
<td>4 byte unsigned integer</td>
2045
<td>The time from when the query started to when it was logged in
2046
the binlog, in seconds.</td>
2051
<td>4 byte unsigned integer</td>
2052
<td>The number on line (14) above, if present, or 0 if line (14)
2058
<td>table_name_len</td>
2059
<td>1 byte unsigned integer</td>
2060
<td>The length of 'table_name' on line (4) above.</td>
2065
<td>1 byte unsigned integer</td>
2066
<td>The length of 'db' on line (1) above.</td>
2071
<td>4 byte unsigned integer</td>
2072
<td>The number n of fields on line (15) above.</td>
2076
The Body contains the following components.
2079
<caption>Body of Load_log_event</caption>
2084
<th>Description</th>
2089
<td>variable length</td>
2091
<td>Describes the part of the query on lines (3) and
2092
(5)–(13) above. More precisely, it stores the five strings
2093
(on lines) field_term (6), enclosed (7), escaped (8), line_term
2094
(11), and line_start (12); as well as a bitfield indicating the
2095
presence of the keywords REPLACE (3), IGNORE (3), and OPTIONALLY
2098
The data is stored in one of two formats, called "old" and "new".
2099
The type field of Common-Header determines which of these two
2100
formats is used: type LOAD_EVENT means that the old format is
2101
used, and type NEW_LOAD_EVENT means that the new format is used.
2102
When MySQL writes a Load_log_event, it uses the new format if at
2103
least one of the five strings is two or more bytes long.
2104
Otherwise (i.e., if all strings are 0 or 1 bytes long), the old
2107
The new and old format differ in the way the five strings are
2111
<li> In the new format, the strings are stored in the order
2112
field_term, enclosed, escaped, line_term, line_start. Each string
2113
consists of a length (1 byte), followed by a sequence of
2114
characters (0-255 bytes). Finally, a boolean combination of the
2115
following flags is stored in 1 byte: REPLACE_FLAG==0x4,
2116
IGNORE_FLAG==0x8, and OPT_ENCLOSED_FLAG==0x2. If a flag is set,
2117
it indicates the presence of the corresponding keyword in the SQL
2120
<li> In the old format, we know that each string has length 0 or
2121
1. Therefore, only the first byte of each string is stored. The
2122
order of the strings is the same as in the new format. These five
2123
bytes are followed by the same 1 byte bitfield as in the new
2124
format. Finally, a 1 byte bitfield called empty_flags is stored.
2125
The low 5 bits of empty_flags indicate which of the five strings
2126
have length 0. For each of the following flags that is set, the
2127
corresponding string has length 0; for the flags that are not set,
2128
the string has length 1: FIELD_TERM_EMPTY==0x1,
2129
ENCLOSED_EMPTY==0x2, LINE_TERM_EMPTY==0x4, LINE_START_EMPTY==0x8,
2130
ESCAPED_EMPTY==0x10.
2133
Thus, the size of the new format is 6 bytes + the sum of the sizes
2134
of the five strings. The size of the old format is always 7
2141
<td>num_fields 1 byte unsigned integers</td>
2142
<td>An array of num_fields integers representing the length of
2143
each field in the query. (num_fields is from the Post-Header).
2149
<td>num_fields null-terminated strings</td>
2150
<td>An array of num_fields null-terminated strings, each
2151
representing a field in the query. (The trailing zero is
2152
redundant, since the length are stored in the num_fields array.)
2153
The total length of all strings equals to the sum of all
2154
field_lens, plus num_fields bytes for all the trailing zeros.
2160
<td>null-terminated string of length table_len+1 bytes</td>
2161
<td>The 'table_name' from the query, as a null-terminated string.
2162
(The trailing zero is actually redundant since the table_len is
2163
known from Post-Header.)
2169
<td>null-terminated string of length db_len+1 bytes</td>
2170
<td>The 'db' from the query, as a null-terminated string.
2171
(The trailing zero is actually redundant since the db_len is known
2178
<td>variable length string without trailing zero, extending to the
2179
end of the event (determined by the length field of the
2182
<td>The 'file_name' from the query.
2188
@subsection Load_log_event_notes_on_previous_versions Notes on Previous Versions
2190
This event type is understood by current versions, but only
2191
generated by MySQL 3.23 and earlier.
2193
class Load_log_event: public Log_event
2197
int copy_log_event(const char *buf, ulong event_len,
2199
const Format_description_log_event* description_event);
2202
void print_query(THD *thd, bool need_db, const char *cs, String *buf,
2203
my_off_t *fn_start, my_off_t *fn_end,
2204
const char *qualify_db);
2206
ulong slave_proxy_id;
2207
uint32 table_name_len;
2209
No need to have a catalog, as these events can only come from 4.x.
2210
TODO: this may become false if Dmitri pushes his new LOAD DATA INFILE in
2211
5.0 only (not in 4.x).
2217
const uchar* field_lens;
2218
uint32 field_block_len;
2220
const char* table_name;
2227
Indicates that this event corresponds to LOAD DATA CONCURRENT,
2229
@note Since Load_log_event event coming from the binary log
2230
lacks information whether LOAD DATA on master was concurrent
2231
or not, this flag is only set to TRUE for an auxiliary
2232
Load_log_event object which is used in mysql_load() to
2233
re-construct LOAD DATA statement from function parameters,
2238
/* fname doesn't point to memory inside Log_event::temp_buf */
2239
void set_fname_outside_temp_buf(const char *afname, uint alen)
2245
/* fname doesn't point to memory inside Log_event::temp_buf */
2246
int check_fname_outside_temp_buf()
2252
String field_lens_buf;
2255
Load_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
2256
const char* table_name_arg,
2257
List<Item>& fields_arg,
2258
bool is_concurrent_arg,
2259
enum enum_duplicates handle_dup, bool ignore,
2261
void set_fields(const char* db, List<Item> &fields_arg,
2262
Name_resolution_context *context);
2263
const char* get_db() { return db; }
2264
#ifdef HAVE_REPLICATION
2265
void pack_info(THD *thd, Protocol* protocol);
2266
#endif /* HAVE_REPLICATION */
2268
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2269
void print(FILE* file, PRINT_EVENT_INFO* print_event_info, bool commented);
2273
Note that for all the events related to LOAD DATA (Load_log_event,
2274
Create_file/Append/Exec/Delete, we pass description_event; however as
2275
logging of LOAD DATA is going to be changed in 4.1 or 5.0, this is only used
2276
for the common_header_len (post_header_len will not be changed).
2278
Load_log_event(const char* buf, uint event_len,
2279
const Format_description_log_event* description_event);
2282
Log_event_type get_type_code()
2284
return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
2287
bool write_data_header(IO_CACHE* file);
2288
bool write_data_body(IO_CACHE* file);
2290
bool is_valid() const { return table_name != 0; }
2293
return (table_name_len + db_len + 2 + fname_len
2295
+ sql_ex.data_size() + field_block_len + num_fields);
2298
public: /* !!! Public in this patch to allow old usage */
2299
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2300
virtual int do_apply_event(Relay_log_info const* rli)
2302
return do_apply_event(thd->slave_net,rli,0);
2305
int do_apply_event(NET *net, Relay_log_info const *rli,
2306
bool use_rli_only_for_errors);
2311
@class Start_log_event_v3
2313
Start_log_event_v3 is the Start_log_event of binlog format 3 (MySQL 3.23 and
2316
Format_description_log_event derives from Start_log_event_v3; it is
2317
the Start_log_event of binlog format 4 (MySQL 5.0), that is, the
2318
event that describes the other events' Common-Header/Post-Header
2319
lengths. This event is sent by MySQL 5.0 whenever it starts sending
2320
a new binlog if the requested position is >4 (otherwise if ==4 the
2321
event will be sent naturally).
2323
@section Start_log_event_v3_binary_format Binary Format
2325
class Start_log_event_v3: public Log_event
2329
If this event is at the start of the first binary log since server
2330
startup 'created' should be the timestamp when the event (and the
2331
binary log) was created. In the other case (i.e. this event is at
2332
the start of a binary log created by FLUSH LOGS or automatic
2333
rotation), 'created' should be 0. This "trick" is used by MySQL
2334
>=4.0.14 slaves to know whether they must drop stale temporary
2335
tables and whether they should abort unfinished transaction.
2337
Note that when 'created'!=0, it is always equal to the event's
2338
timestamp; indeed Start_log_event is written only in log.cc where
2339
the first constructor below is called, in which 'created' is set
2340
to 'when'. So in fact 'created' is a useless variable. When it is
2341
0 we can read the actual value from timestamp ('when') and when it
2342
is non-zero we can read the same value from timestamp
2343
('when'). Conclusion:
2344
- we use timestamp to print when the binlog was created.
2345
- we use 'created' only to know if this is a first binlog or not.
2346
In 3.23.57 we did not pay attention to this identity, so mysqlbinlog in
2347
3.23.57 does not print 'created the_date' if created was zero. This is now
2351
uint16 binlog_version;
2352
char server_version[ST_SERVER_VER_LEN];
2354
We set this to 1 if we don't want to have the created time in the log,
2355
which is the case when we rollover to a new log.
2357
bool dont_set_created;
2360
Start_log_event_v3();
2361
#ifdef HAVE_REPLICATION
2362
void pack_info(THD *thd, Protocol* protocol);
2363
#endif /* HAVE_REPLICATION */
2365
Start_log_event_v3() {}
2366
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2369
Start_log_event_v3(const char* buf,
2370
const Format_description_log_event* description_event);
2371
~Start_log_event_v3() {}
2372
Log_event_type get_type_code() { return START_EVENT_V3;}
2374
bool write(IO_CACHE* file);
2376
bool is_valid() const { return 1; }
2379
return START_V3_HEADER_LEN; //no variable-sized part
2383
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2384
virtual int do_apply_event(Relay_log_info const *rli);
2385
virtual enum_skip_reason do_shall_skip(Relay_log_info*)
2388
Events from ourself should be skipped, but they should not
2389
decrease the slave skip counter.
2391
if (this->server_id == ::server_id)
2392
return Log_event::EVENT_SKIP_IGNORE;
2394
return Log_event::EVENT_SKIP_NOT;
2401
@class Format_description_log_event
2403
For binlog version 4.
2404
This event is saved by threads which read it, as they need it for future
2405
use (to decode the ordinary events).
2407
@section Format_description_log_event_binary_format Binary Format
2410
class Format_description_log_event: public Start_log_event_v3
2414
The size of the fixed header which _all_ events have
2415
(for binlogs written by this version, this is equal to
2416
LOG_EVENT_HEADER_LEN), except FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT
2417
(those have a header of size LOG_EVENT_MINIMAL_HEADER_LEN).
2419
uint8 common_header_len;
2420
uint8 number_of_event_types;
2422
The list of post-headers' lengths followed
2423
by the checksum alg decription byte
2425
uint8 *post_header_len;
2426
struct master_version_split {
2427
enum {KIND_MYSQL, KIND_MARIADB};
2431
master_version_split server_version_split;
2432
const uint8 *event_type_permutation;
2434
Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
2435
Format_description_log_event(const char* buf, uint event_len,
2436
const Format_description_log_event
2437
*description_event);
2438
~Format_description_log_event()
2440
my_free(post_header_len);
2442
Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
2444
bool write(IO_CACHE* file);
2446
bool header_is_valid() const
2448
return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN :
2449
LOG_EVENT_MINIMAL_HEADER_LEN)) &&
2450
(post_header_len != NULL));
2453
bool version_is_valid() const
2455
/* It is invalid only when all version numbers are 0 */
2456
return !(server_version_split.ver[0] == 0 &&
2457
server_version_split.ver[1] == 0 &&
2458
server_version_split.ver[2] == 0);
2461
bool is_valid() const
2463
return header_is_valid() && version_is_valid();
2469
The vector of post-header lengths is considered as part of the
2470
post-header, because in a given version it never changes (contrary to the
2471
query in a Query_log_event).
2473
return FORMAT_DESCRIPTION_HEADER_LEN;
2476
void calc_server_version_split();
2477
static bool is_version_before_checksum(const master_version_split *version_split);
2479
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2480
virtual int do_apply_event(Relay_log_info const *rli);
2481
virtual int do_update_pos(Relay_log_info *rli);
2482
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2488
@class Intvar_log_event
2490
An Intvar_log_event will be created just before a Query_log_event,
2491
if the query uses one of the variables LAST_INSERT_ID or INSERT_ID.
2492
Each Intvar_log_event holds the value of one of these variables.
2494
@section Intvar_log_event_binary_format Binary Format
2496
The Post-Header for this event type is empty. The Body has two
2500
<caption>Body for Intvar_log_event</caption>
2505
<th>Description</th>
2510
<td>1 byte enumeration</td>
2511
<td>One byte identifying the type of variable stored. Currently,
2512
two identifiers are supported: LAST_INSERT_ID_EVENT==1 and
2519
<td>8 byte unsigned integer</td>
2520
<td>The value of the variable.</td>
2525
class Intvar_log_event: public Log_event
2532
Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg,
2533
bool using_trans, bool direct)
2534
:Log_event(thd_arg,0,using_trans),val(val_arg),type(type_arg)
2537
cache_type= Log_event::EVENT_NO_CACHE;
2539
#ifdef HAVE_REPLICATION
2540
void pack_info(THD *thd, Protocol* protocol);
2541
#endif /* HAVE_REPLICATION */
2543
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2546
Intvar_log_event(const char* buf,
2547
const Format_description_log_event *description_event);
2548
~Intvar_log_event() {}
2549
Log_event_type get_type_code() { return INTVAR_EVENT;}
2550
const char* get_var_type_name();
2551
int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;}
2553
bool write(IO_CACHE* file);
2555
bool is_valid() const { return 1; }
2558
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2559
virtual int do_apply_event(Relay_log_info const *rli);
2560
virtual int do_update_pos(Relay_log_info *rli);
2561
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2567
@class Rand_log_event
2569
Logs random seed used by the next RAND(), and by PASSWORD() in 4.1.0.
2570
4.1.1 does not need it (it's repeatable again) so this event needn't be
2571
written in 4.1.1 for PASSWORD() (but the fact that it is written is just a
2572
waste, it does not cause bugs).
2574
The state of the random number generation consists of 128 bits,
2575
which are stored internally as two 64-bit numbers.
2577
@section Rand_log_event_binary_format Binary Format
2579
The Post-Header for this event type is empty. The Body has two
2583
<caption>Body for Rand_log_event</caption>
2588
<th>Description</th>
2593
<td>8 byte unsigned integer</td>
2594
<td>64 bit random seed1.</td>
2599
<td>8 byte unsigned integer</td>
2600
<td>64 bit random seed2.</td>
2605
class Rand_log_event: public Log_event
2612
Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg,
2613
bool using_trans, bool direct)
2614
:Log_event(thd_arg,0,using_trans),seed1(seed1_arg),seed2(seed2_arg)
2617
cache_type= Log_event::EVENT_NO_CACHE;
2619
#ifdef HAVE_REPLICATION
2620
void pack_info(THD *thd, Protocol* protocol);
2621
#endif /* HAVE_REPLICATION */
2623
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2626
Rand_log_event(const char* buf,
2627
const Format_description_log_event *description_event);
2628
~Rand_log_event() {}
2629
Log_event_type get_type_code() { return RAND_EVENT;}
2630
int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ }
2632
bool write(IO_CACHE* file);
2634
bool is_valid() const { return 1; }
2637
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2638
virtual int do_apply_event(Relay_log_info const *rli);
2639
virtual int do_update_pos(Relay_log_info *rli);
2640
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2645
@class Xid_log_event
2647
Logs xid of the transaction-to-be-committed in the 2pc protocol.
2648
Has no meaning in replication, slaves ignore it.
2650
@section Xid_log_event_binary_format Binary Format
2653
typedef ulonglong my_xid; // this line is the same as in handler.h
2656
class Xid_log_event: public Log_event
2662
Xid_log_event(THD* thd_arg, my_xid x, bool direct):
2663
Log_event(thd_arg, 0, TRUE), xid(x)
2666
cache_type= Log_event::EVENT_NO_CACHE;
2668
#ifdef HAVE_REPLICATION
2669
void pack_info(THD *thd, Protocol* protocol);
2670
#endif /* HAVE_REPLICATION */
2672
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2675
Xid_log_event(const char* buf,
2676
const Format_description_log_event *description_event);
2678
Log_event_type get_type_code() { return XID_EVENT;}
2679
int get_data_size() { return sizeof(xid); }
2681
bool write(IO_CACHE* file);
2683
bool is_valid() const { return 1; }
2686
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2687
virtual int do_apply_event(Relay_log_info const *rli);
2688
enum_skip_reason do_shall_skip(Relay_log_info *rli);
2693
@class User_var_log_event
2695
Every time a query uses the value of a user variable, a User_var_log_event is
2696
written before the Query_log_event, to set the user variable.
2698
@section User_var_log_event_binary_format Binary Format
2701
class User_var_log_event: public Log_event
2713
uint charset_number;
2718
query_id_t query_id;
2719
User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
2720
char *val_arg, ulong val_len_arg, Item_result type_arg,
2721
uint charset_number_arg, uchar flags_arg,
2722
bool using_trans, bool direct)
2723
:Log_event(thd_arg, 0, using_trans),
2724
name(name_arg), name_len(name_len_arg), val(val_arg),
2725
val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg),
2726
flags(flags_arg), deferred(false)
2730
cache_type= Log_event::EVENT_NO_CACHE;
2732
void pack_info(THD *thd, Protocol* protocol);
2734
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2737
User_var_log_event(const char* buf, uint event_len,
2738
const Format_description_log_event *description_event);
2739
~User_var_log_event() {}
2740
Log_event_type get_type_code() { return USER_VAR_EVENT;}
2742
bool write(IO_CACHE* file);
2744
Getter and setter for deferred User-event.
2745
Returns true if the event is not applied directly
2746
and which case the applier adjusts execution path.
2748
bool is_deferred() { return deferred; }
2750
In case of the deffered applying the variable instance is flagged
2751
and the parsing time query id is stored to be used at applying time.
2753
void set_deferred(query_id_t qid) { deferred= true; query_id= qid; }
2755
bool is_valid() const { return name != 0; }
2758
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2759
virtual int do_apply_event(Relay_log_info const *rli);
2760
virtual int do_update_pos(Relay_log_info *rli);
2761
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2767
@class Stop_log_event
2769
@section Stop_log_event_binary_format Binary Format
2771
The Post-Header and Body for this event type are empty; it only has
2774
class Stop_log_event: public Log_event
2778
Stop_log_event() :Log_event()
2781
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2784
Stop_log_event(const char* buf,
2785
const Format_description_log_event *description_event):
2786
Log_event(buf, description_event)
2788
~Stop_log_event() {}
2789
Log_event_type get_type_code() { return STOP_EVENT;}
2790
bool is_valid() const { return 1; }
2793
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2794
virtual int do_update_pos(Relay_log_info *rli);
2795
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli)
2798
Events from ourself should be skipped, but they should not
2799
decrease the slave skip counter.
2801
if (this->server_id == ::server_id)
2802
return Log_event::EVENT_SKIP_IGNORE;
2804
return Log_event::EVENT_SKIP_NOT;
2810
@class Rotate_log_event
2812
This will be deprecated when we move to using sequence ids.
2814
@section Rotate_log_event_binary_format Binary Format
2816
The Post-Header has one component:
2819
<caption>Post-Header for Rotate_log_event</caption>
2824
<th>Description</th>
2829
<td>8 byte integer</td>
2830
<td>The position within the binlog to rotate to.</td>
2835
The Body has one component:
2838
<caption>Body for Rotate_log_event</caption>
2843
<th>Description</th>
2848
<td>variable length string without trailing zero, extending to the
2849
end of the event (determined by the length field of the
2852
<td>Name of the binlog to rotate to.</td>
2858
class Rotate_log_event: public Log_event
2862
DUP_NAME= 2, // if constructor should dup the string argument
2863
RELAY_LOG=4 // rotate event for relay log
2865
const char* new_log_ident;
2870
Rotate_log_event(const char* new_log_ident_arg,
2872
ulonglong pos_arg, uint flags);
2873
#ifdef HAVE_REPLICATION
2874
void pack_info(THD *thd, Protocol* protocol);
2875
#endif /* HAVE_REPLICATION */
2877
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2880
Rotate_log_event(const char* buf, uint event_len,
2881
const Format_description_log_event* description_event);
2884
if (flags & DUP_NAME)
2885
my_free((void*) new_log_ident);
2887
Log_event_type get_type_code() { return ROTATE_EVENT;}
2888
int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
2889
bool is_valid() const { return new_log_ident != 0; }
2891
bool write(IO_CACHE* file);
2895
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2896
virtual int do_update_pos(Relay_log_info *rli);
2897
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2902
/* the classes below are for the new LOAD DATA INFILE logging */
2905
@class Create_file_log_event
2907
@section Create_file_log_event_binary_format Binary Format
2910
class Create_file_log_event: public Load_log_event
2914
Pretend we are Load event, so we can write out just
2915
our Load part - used on the slave when writing event out to
2916
SQL_LOAD-*.info file
2921
const char *event_buf;
2924
bool inited_from_old;
2927
Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
2928
const char* table_name_arg,
2929
List<Item>& fields_arg,
2930
bool is_concurrent_arg,
2931
enum enum_duplicates handle_dup, bool ignore,
2932
uchar* block_arg, uint block_len_arg,
2934
#ifdef HAVE_REPLICATION
2935
void pack_info(THD *thd, Protocol* protocol);
2936
#endif /* HAVE_REPLICATION */
2938
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2939
void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
2943
Create_file_log_event(const char* buf, uint event_len,
2944
const Format_description_log_event* description_event);
2945
~Create_file_log_event()
2947
my_free((void*) event_buf);
2950
Log_event_type get_type_code()
2952
return fake_base ? Load_log_event::get_type_code() : CREATE_FILE_EVENT;
2956
return (fake_base ? Load_log_event::get_data_size() :
2957
Load_log_event::get_data_size() +
2960
bool is_valid() const { return inited_from_old || block != 0; }
2962
bool write_data_header(IO_CACHE* file);
2963
bool write_data_body(IO_CACHE* file);
2965
Cut out Create_file extentions and
2966
write it as Load event - used on the slave
2968
bool write_base(IO_CACHE* file);
2972
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
2973
virtual int do_apply_event(Relay_log_info const *rli);
2979
@class Append_block_log_event
2981
@section Append_block_log_event_binary_format Binary Format
2984
class Append_block_log_event: public Log_event
2991
'db' is filled when the event is created in mysql_load() (the
2992
event needs to have a 'db' member to be well filtered by
2993
binlog-*-db rules). 'db' is not written to the binlog (it's not
2994
used by Append_block_log_event::write()), so it can't be read in
2995
the Append_block_log_event(const char* buf, int event_len)
2996
constructor. In other words, 'db' is used only for filtering by
2997
binlog-*-db rules. Create_file_log_event is different: it's 'db'
2998
(which is inherited from Load_log_event) is written to the binlog
3004
Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
3005
uint block_len_arg, bool using_trans);
3006
#ifdef HAVE_REPLICATION
3007
void pack_info(THD *thd, Protocol* protocol);
3008
virtual int get_create_or_append() const;
3009
#endif /* HAVE_REPLICATION */
3011
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
3014
Append_block_log_event(const char* buf, uint event_len,
3015
const Format_description_log_event
3016
*description_event);
3017
~Append_block_log_event() {}
3018
Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
3019
int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;}
3020
bool is_valid() const { return block != 0; }
3022
bool write(IO_CACHE* file);
3023
const char* get_db() { return db; }
3027
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3028
virtual int do_apply_event(Relay_log_info const *rli);
3034
@class Delete_file_log_event
3036
@section Delete_file_log_event_binary_format Binary Format
3039
class Delete_file_log_event: public Log_event
3043
const char* db; /* see comment in Append_block_log_event */
3046
Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
3047
#ifdef HAVE_REPLICATION
3048
void pack_info(THD *thd, Protocol* protocol);
3049
#endif /* HAVE_REPLICATION */
3051
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
3052
void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
3056
Delete_file_log_event(const char* buf, uint event_len,
3057
const Format_description_log_event* description_event);
3058
~Delete_file_log_event() {}
3059
Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
3060
int get_data_size() { return DELETE_FILE_HEADER_LEN ;}
3061
bool is_valid() const { return file_id != 0; }
3063
bool write(IO_CACHE* file);
3064
const char* get_db() { return db; }
3068
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3069
virtual int do_apply_event(Relay_log_info const *rli);
3075
@class Execute_load_log_event
3077
@section Delete_file_log_event_binary_format Binary Format
3080
class Execute_load_log_event: public Log_event
3084
const char* db; /* see comment in Append_block_log_event */
3087
Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
3088
#ifdef HAVE_REPLICATION
3089
void pack_info(THD *thd, Protocol* protocol);
3090
#endif /* HAVE_REPLICATION */
3092
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
3095
Execute_load_log_event(const char* buf, uint event_len,
3096
const Format_description_log_event
3097
*description_event);
3098
~Execute_load_log_event() {}
3099
Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
3100
int get_data_size() { return EXEC_LOAD_HEADER_LEN ;}
3101
bool is_valid() const { return file_id != 0; }
3103
bool write(IO_CACHE* file);
3104
const char* get_db() { return db; }
3108
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3109
virtual int do_apply_event(Relay_log_info const *rli);
3115
@class Begin_load_query_log_event
3117
Event for the first block of file to be loaded, its only difference from
3118
Append_block event is that this event creates or truncates existing file
3119
before writing data.
3121
@section Begin_load_query_log_event_binary_format Binary Format
3123
class Begin_load_query_log_event: public Append_block_log_event
3127
Begin_load_query_log_event(THD* thd_arg, const char *db_arg,
3128
uchar* block_arg, uint block_len_arg,
3130
#ifdef HAVE_REPLICATION
3131
Begin_load_query_log_event(THD* thd);
3132
int get_create_or_append() const;
3133
#endif /* HAVE_REPLICATION */
3135
Begin_load_query_log_event(const char* buf, uint event_len,
3136
const Format_description_log_event
3137
*description_event);
3138
~Begin_load_query_log_event() {}
3139
Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
3141
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3142
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
3148
Elements of this enum describe how LOAD DATA handles duplicates.
3150
enum enum_load_dup_handling { LOAD_DUP_ERROR= 0, LOAD_DUP_IGNORE,
3154
@class Execute_load_query_log_event
3156
Event responsible for LOAD DATA execution, it similar to Query_log_event
3157
but before executing the query it substitutes original filename in LOAD DATA
3158
query with name of temporary file.
3160
@section Execute_load_query_log_event_binary_format Binary Format
3162
class Execute_load_query_log_event: public Query_log_event
3165
uint file_id; // file_id of temporary file
3166
uint fn_pos_start; // pointer to the part of the query that should
3168
uint fn_pos_end; // pointer to the end of this part of query
3170
We have to store type of duplicate handling explicitly, because
3171
for LOAD DATA it also depends on LOCAL option. And this part
3172
of query will be rewritten during replication so this information
3175
enum_load_dup_handling dup_handling;
3178
Execute_load_query_log_event(THD* thd, const char* query_arg,
3179
ulong query_length, uint fn_pos_start_arg,
3180
uint fn_pos_end_arg,
3181
enum_load_dup_handling dup_handling_arg,
3182
bool using_trans, bool direct,
3183
bool suppress_use, int errcode);
3184
#ifdef HAVE_REPLICATION
3185
void pack_info(THD *thd, Protocol* protocol);
3186
#endif /* HAVE_REPLICATION */
3188
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
3189
/* Prints the query as LOAD DATA LOCAL and with rewritten filename */
3190
void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
3191
const char *local_fname);
3193
Execute_load_query_log_event(const char* buf, uint event_len,
3194
const Format_description_log_event
3195
*description_event);
3196
~Execute_load_query_log_event() {}
3198
Log_event_type get_type_code() { return EXECUTE_LOAD_QUERY_EVENT; }
3199
bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; }
3201
ulong get_post_header_size_for_derived();
3203
bool write_post_header_for_derived(IO_CACHE* file);
3207
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3208
virtual int do_apply_event(Relay_log_info const *rli);
3215
@class Unknown_log_event
3217
@section Unknown_log_event_binary_format Binary Format
3219
class Unknown_log_event: public Log_event
3223
Even if this is an unknown event, we still pass description_event to
3224
Log_event's ctor, this way we can extract maximum information from the
3225
event's header (the unique ID for example).
3227
Unknown_log_event(const char* buf,
3228
const Format_description_log_event *description_event):
3229
Log_event(buf, description_event)
3231
~Unknown_log_event() {}
3232
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
3233
Log_event_type get_type_code() { return UNKNOWN_EVENT;}
3234
bool is_valid() const { return 1; }
3237
char *str_to_hex(char *to, const char *from, uint len);
3240
@class Annotate_rows_log_event
3242
In row-based mode, if binlog_annotate_row_events = ON, each group of
3243
Table_map_log_events is preceded by an Annotate_rows_log_event which
3244
contains the query which caused the subsequent rows operations.
3246
The Annotate_rows_log_event has no post-header and its body contains
3247
the corresponding query (without trailing zero). Note. The query length
3248
is to be calculated as a difference between the whole event length and
3249
the common header length.
3251
class Annotate_rows_log_event: public Log_event
3254
#ifndef MYSQL_CLIENT
3255
Annotate_rows_log_event(THD*, bool using_trans, bool direct);
3257
Annotate_rows_log_event(const char *buf, uint event_len,
3258
const Format_description_log_event*);
3259
~Annotate_rows_log_event();
3261
virtual int get_data_size();
3262
virtual Log_event_type get_type_code();
3263
virtual bool is_valid() const;
3265
#ifndef MYSQL_CLIENT
3266
virtual bool write_data_header(IO_CACHE*);
3267
virtual bool write_data_body(IO_CACHE*);
3270
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3271
virtual void pack_info(THD *thd, Protocol*);
3275
virtual void print(FILE*, PRINT_EVENT_INFO*);
3278
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3280
virtual int do_apply_event(Relay_log_info const*);
3281
virtual int do_update_pos(Relay_log_info*);
3282
virtual enum_skip_reason do_shall_skip(Relay_log_info*);
3288
char *m_save_thd_query_txt;
3289
uint m_save_thd_query_len;
3293
@class Table_map_log_event
3295
In row-based mode, every row operation event is preceded by a
3296
Table_map_log_event which maps a table definition to a number. The
3297
table definition consists of database name, table name, and column
3300
@section Table_map_log_event_binary_format Binary Format
3302
The Post-Header has the following components:
3305
<caption>Post-Header for Table_map_log_event</caption>
3310
<th>Description</th>
3315
<td>6 bytes unsigned integer</td>
3316
<td>The number that identifies the table.</td>
3321
<td>2 byte bitfield</td>
3322
<td>Reserved for future use; currently always 0.</td>
3327
The Body has the following components:
3330
<caption>Body for Table_map_log_event</caption>
3335
<th>Description</th>
3339
<td>database_name</td>
3340
<td>one byte string length, followed by null-terminated string</td>
3341
<td>The name of the database in which the table resides. The name
3342
is represented as a one byte unsigned integer representing the
3343
number of bytes in the name, followed by length bytes containing
3344
the database name, followed by a terminating 0 byte. (Note the
3345
redundancy in the representation of the length.) </td>
3350
<td>one byte string length, followed by null-terminated string</td>
3351
<td>The name of the table, encoded the same way as the database
3356
<td>column_count</td>
3357
<td>@ref packed_integer "Packed Integer"</td>
3358
<td>The number of columns in the table, represented as a packed
3359
variable-length integer.</td>
3363
<td>column_type</td>
3364
<td>List of column_count 1 byte enumeration values</td>
3365
<td>The type of each column in the table, listed from left to
3366
right. Each byte is mapped to a column type according to the
3367
enumeration type enum_field_types defined in mysql_com.h. The
3368
mapping of types to numbers is listed in the table @ref
3369
Table_table_map_log_event_column_types "below" (along with
3370
description of the associated metadata field). </td>
3374
<td>metadata_length</td>
3375
<td>@ref packed_integer "Packed Integer"</td>
3376
<td>The length of the following metadata block</td>
3381
<td>list of metadata for each column</td>
3382
<td>For each column from left to right, a chunk of data who's
3383
length and semantics depends on the type of the column. The
3384
length and semantics for the metadata for each column are listed
3385
in the table @ref Table_table_map_log_event_column_types
3391
<td>column_count bits, rounded up to nearest byte</td>
3392
<td>For each column, a bit indicating whether data in the column
3393
can be NULL or not. The number of bytes needed for this is
3394
int((column_count+7)/8). The flag for the first column from the
3395
left is in the least-significant bit of the first byte, the second
3396
is in the second least significant bit of the first byte, the
3397
ninth is in the least significant bit of the second byte, and so
3403
The table below lists all column types, along with the numerical
3404
identifier for it and the size and interpretation of meta-data used
3405
to describe the type.
3407
@anchor Table_table_map_log_event_column_types
3409
<caption>Table_map_log_event column types: numerical identifier and
3414
<th>Size of metadata in bytes</th>
3415
<th>Description of metadata</th>
3419
<td>MYSQL_TYPE_DECIMAL</td><td>0</td>
3421
<td>No column metadata.</td>
3425
<td>MYSQL_TYPE_TINY</td><td>1</td>
3427
<td>No column metadata.</td>
3431
<td>MYSQL_TYPE_SHORT</td><td>2</td>
3433
<td>No column metadata.</td>
3437
<td>MYSQL_TYPE_LONG</td><td>3</td>
3439
<td>No column metadata.</td>
3443
<td>MYSQL_TYPE_FLOAT</td><td>4</td>
3445
<td>1 byte unsigned integer, representing the "pack_length", which
3446
is equal to sizeof(float) on the server from which the event
3451
<td>MYSQL_TYPE_DOUBLE</td><td>5</td>
3453
<td>1 byte unsigned integer, representing the "pack_length", which
3454
is equal to sizeof(double) on the server from which the event
3459
<td>MYSQL_TYPE_NULL</td><td>6</td>
3461
<td>No column metadata.</td>
3465
<td>MYSQL_TYPE_TIMESTAMP</td><td>7</td>
3467
<td>No column metadata.</td>
3471
<td>MYSQL_TYPE_LONGLONG</td><td>8</td>
3473
<td>No column metadata.</td>
3477
<td>MYSQL_TYPE_INT24</td><td>9</td>
3479
<td>No column metadata.</td>
3483
<td>MYSQL_TYPE_DATE</td><td>10</td>
3485
<td>No column metadata.</td>
3489
<td>MYSQL_TYPE_TIME</td><td>11</td>
3491
<td>No column metadata.</td>
3495
<td>MYSQL_TYPE_DATETIME</td><td>12</td>
3497
<td>No column metadata.</td>
3501
<td>MYSQL_TYPE_YEAR</td><td>13</td>
3503
<td>No column metadata.</td>
3507
<td><i>MYSQL_TYPE_NEWDATE</i></td><td><i>14</i></td>
3509
<td><i>This enumeration value is only used internally and cannot
3510
exist in a binlog.</i></td>
3514
<td>MYSQL_TYPE_VARCHAR</td><td>15</td>
3516
<td>2 byte unsigned integer representing the maximum length of
3521
<td>MYSQL_TYPE_BIT</td><td>16</td>
3523
<td>A 1 byte unsigned int representing the length in bits of the
3524
bitfield (0 to 64), followed by a 1 byte unsigned int
3525
representing the number of bytes occupied by the bitfield. The
3526
number of bytes is either int((length+7)/8) or int(length/8).</td>
3530
<td>MYSQL_TYPE_NEWDECIMAL</td><td>246</td>
3532
<td>A 1 byte unsigned int representing the precision, followed
3533
by a 1 byte unsigned int representing the number of decimals.</td>
3537
<td><i>MYSQL_TYPE_ENUM</i></td><td><i>247</i></td>
3539
<td><i>This enumeration value is only used internally and cannot
3540
exist in a binlog.</i></td>
3544
<td><i>MYSQL_TYPE_SET</i></td><td><i>248</i></td>
3546
<td><i>This enumeration value is only used internally and cannot
3547
exist in a binlog.</i></td>
3551
<td>MYSQL_TYPE_TINY_BLOB</td><td>249</td>
3553
<td><i>This enumeration value is only used internally and cannot
3554
exist in a binlog.</i></td>
3558
<td><i>MYSQL_TYPE_MEDIUM_BLOB</i></td><td><i>250</i></td>
3560
<td><i>This enumeration value is only used internally and cannot
3561
exist in a binlog.</i></td>
3565
<td><i>MYSQL_TYPE_LONG_BLOB</i></td><td><i>251</i></td>
3567
<td><i>This enumeration value is only used internally and cannot
3568
exist in a binlog.</i></td>
3572
<td>MYSQL_TYPE_BLOB</td><td>252</td>
3574
<td>The pack length, i.e., the number of bytes needed to represent
3575
the length of the blob: 1, 2, 3, or 4.</td>
3579
<td>MYSQL_TYPE_VAR_STRING</td><td>253</td>
3581
<td>This is used to store both strings and enumeration values.
3582
The first byte is a enumeration value storing the <i>real
3583
type</i>, which may be either MYSQL_TYPE_VAR_STRING or
3584
MYSQL_TYPE_ENUM. The second byte is a 1 byte unsigned integer
3585
representing the field size, i.e., the number of bytes needed to
3586
store the length of the string.</td>
3590
<td>MYSQL_TYPE_STRING</td><td>254</td>
3592
<td>The first byte is always MYSQL_TYPE_VAR_STRING (i.e., 253).
3593
The second byte is the field size, i.e., the number of bytes in
3594
the representation of size of the string: 3 or 4.</td>
3598
<td>MYSQL_TYPE_GEOMETRY</td><td>255</td>
3600
<td>The pack length, i.e., the number of bytes needed to represent
3601
the length of the geometry: 1, 2, 3, or 4.</td>
3606
class Table_map_log_event : public Log_event
3612
TYPE_CODE = TABLE_MAP_EVENT
3616
Enumeration of the errors that can be returned.
3620
ERR_OPEN_FAILURE = -1, /**< Failure to open table */
3621
ERR_OK = 0, /**< No error */
3622
ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
3623
ERR_OUT_OF_MEM = 2, /**< Out of memory */
3624
ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
3625
ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
3631
Nothing here right now, but the flags support is there in
3632
preparation for changes that are coming. Need to add a
3633
constant to make it compile under HP-UX: aCC does not like
3639
typedef uint16 flag_set;
3641
/* Special constants representing sets of flags */
3645
TM_BIT_LEN_EXACT_F = (1U << 0)
3648
flag_set get_flags(flag_set flag) const { return m_flags & flag; }
3651
Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, bool is_transactional);
3653
#ifdef HAVE_REPLICATION
3654
Table_map_log_event(const char *buf, uint event_len,
3655
const Format_description_log_event *description_event);
3658
~Table_map_log_event();
3661
table_def *create_table_def()
3663
return new table_def(m_coltype, m_colcnt, m_field_metadata,
3664
m_field_metadata_size, m_null_bits, m_flags);
3666
int rewrite_db(const char* new_name, size_t new_name_len,
3667
const Format_description_log_event*);
3669
ulong get_table_id() const { return m_table_id; }
3670
const char *get_table_name() const { return m_tblnam; }
3671
const char *get_db_name() const { return m_dbnam; }
3673
virtual Log_event_type get_type_code() { return TABLE_MAP_EVENT; }
3674
virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
3676
virtual int get_data_size() { return (uint) m_data_size; }
3678
virtual int save_field_metadata();
3679
virtual bool write_data_header(IO_CACHE *file);
3680
virtual bool write_data_body(IO_CACHE *file);
3681
virtual const char *get_db() { return m_dbnam; }
3684
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3685
virtual void pack_info(THD *thd, Protocol *protocol);
3689
virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
3694
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3695
virtual int do_apply_event(Relay_log_info const *rli);
3696
virtual int do_update_pos(Relay_log_info *rli);
3697
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
3703
char const *m_dbnam;
3705
char const *m_tblnam;
3716
uchar *m_field_metadata; // buffer for field metadata
3718
The size of field metadata buffer set by calling save_field_metadata()
3720
ulong m_field_metadata_size;
3722
uchar *m_meta_memory;
3727
@class Rows_log_event
3729
Common base class for all row-containing log events.
3733
Encode the common parts of all events containing rows, which are:
3734
- Write data header and data body to an IO_CACHE.
3735
- Provide an interface for adding an individual row to the event.
3737
@section Rows_log_event_binary_format Binary Format
3741
class Rows_log_event : public Log_event
3745
Enumeration of the errors that can be returned.
3749
ERR_OPEN_FAILURE = -1, /**< Failure to open table */
3750
ERR_OK = 0, /**< No error */
3751
ERR_TABLE_LIMIT_EXCEEDED = 1, /**< No more room for tables */
3752
ERR_OUT_OF_MEM = 2, /**< Out of memory */
3753
ERR_BAD_TABLE_DEF = 3, /**< Table definition does not match */
3754
ERR_RBR_TO_SBR = 4 /**< daisy-chanining RBR to SBR not allowed */
3758
These definitions allow you to combine the flags into an
3759
appropriate flag set using the normal bitwise operators. The
3760
implicit conversion from an enum-constant to an integer is
3761
accepted by the compiler, which is then used to set the real set
3766
/* Last event of a statement */
3767
STMT_END_F = (1U << 0),
3769
/* Value of the OPTION_NO_FOREIGN_KEY_CHECKS flag in thd->options */
3770
NO_FOREIGN_KEY_CHECKS_F = (1U << 1),
3772
/* Value of the OPTION_RELAXED_UNIQUE_CHECKS flag in thd->options */
3773
RELAXED_UNIQUE_CHECKS_F = (1U << 2),
3776
Indicates that rows in this event are complete, that is contain
3777
values for all columns of the table.
3779
COMPLETE_ROWS_F = (1U << 3)
3782
typedef uint16 flag_set;
3784
/* Special constants representing sets of flags */
3790
virtual ~Rows_log_event();
3792
void set_flags(flag_set flags_arg) { m_flags |= flags_arg; }
3793
void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
3794
flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
3796
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3797
virtual void pack_info(THD *thd, Protocol *protocol);
3801
/* not for direct call, each derived has its own ::print() */
3802
virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info)= 0;
3803
void print_verbose(IO_CACHE *file,
3804
PRINT_EVENT_INFO *print_event_info);
3805
size_t print_verbose_one_row(IO_CACHE *file, table_def *td,
3806
PRINT_EVENT_INFO *print_event_info,
3807
MY_BITMAP *cols_bitmap,
3808
const uchar *ptr, const uchar *prefix);
3812
int add_row_data(uchar *data, size_t length)
3814
return do_add_row_data(data,length);
3818
/* Member functions to implement superclass interface */
3819
virtual int get_data_size();
3821
MY_BITMAP const *get_cols() const { return &m_cols; }
3822
size_t get_width() const { return m_width; }
3823
ulong get_table_id() const { return m_table_id; }
3826
virtual bool write_data_header(IO_CACHE *file);
3827
virtual bool write_data_body(IO_CACHE *file);
3828
virtual const char *get_db() { return m_table->s->db.str; }
3831
Check that malloc() succeeded in allocating memory for the rows
3832
buffer and the COLS vector. Checking that an Update_rows_log_event
3833
is valid is done in the Update_rows_log_event::is_valid()
3836
virtual bool is_valid() const
3838
return m_rows_buf && m_cols.bitmap;
3841
uint m_row_count; /* The number of rows added to the event */
3845
The constructors are protected since you're supposed to inherit
3846
this class, not create instances of this class.
3849
Rows_log_event(THD*, TABLE*, ulong table_id,
3850
MY_BITMAP const *cols, bool is_transactional);
3852
Rows_log_event(const char *row_data, uint event_len,
3853
Log_event_type event_type,
3854
const Format_description_log_event *description_event);
3857
void print_helper(FILE *, PRINT_EVENT_INFO *, char const *const name);
3861
virtual int do_add_row_data(uchar *data, size_t length);
3865
TABLE *m_table; /* The table the rows belong to */
3867
ulong m_table_id; /* Table ID */
3868
MY_BITMAP m_cols; /* Bitmap denoting columns available */
3869
ulong m_width; /* The width of the columns bitmap */
3871
Bitmap for columns available in the after image, if present. These
3872
fields are only available for Update_rows events. Observe that the
3873
width of both the before image COLS vector and the after image
3874
COLS vector is the same: the number of columns of the table on the
3877
MY_BITMAP m_cols_ai;
3879
ulong m_master_reclength; /* Length of record on master side */
3881
/* Bit buffers in the same memory as the class */
3882
uint32 m_bitbuf[128/(sizeof(uint32)*8)];
3883
uint32 m_bitbuf_ai[128/(sizeof(uint32)*8)];
3885
uchar *m_rows_buf; /* The rows in packed format */
3886
uchar *m_rows_cur; /* One-after the end of the data */
3887
uchar *m_rows_end; /* One-after the end of the allocated space */
3889
flag_set m_flags; /* Flags for row-level events */
3891
/* helper functions */
3893
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3894
const uchar *m_curr_row; /* Start of the row being processed */
3895
const uchar *m_curr_row_end; /* One-after the end of the current row */
3896
uchar *m_key; /* Buffer to keep key value during searches */
3897
KEY *m_key_info; /* Pointer to KEY info for m_key_nr */
3898
uint m_key_nr; /* Key number */
3900
int find_key(); // Find a best key to use in find_row()
3901
int find_row(const Relay_log_info *const);
3902
int write_row(const Relay_log_info *const, const bool);
3904
// Unpack the current row into m_table->record[0]
3905
int unpack_current_row(const Relay_log_info *const rli)
3907
DBUG_ASSERT(m_table);
3909
ASSERT_OR_RETURN_ERROR(m_curr_row < m_rows_end, HA_ERR_CORRUPT_EVENT);
3910
return ::unpack_row(rli, m_table, m_width, m_curr_row, &m_cols,
3911
&m_curr_row_end, &m_master_reclength, m_rows_end);
3915
Helper function to check whether there is an auto increment
3916
column on the table where the event is to be applied.
3918
@return true if there is an autoincrement field on the extra
3919
columns, false otherwise.
3921
inline bool is_auto_inc_in_extra_columns()
3923
DBUG_ASSERT(m_table);
3924
return (m_table->next_number_field &&
3925
m_table->next_number_field->field_index >= m_width);
3931
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
3932
virtual int do_apply_event(Relay_log_info const *rli);
3933
virtual int do_update_pos(Relay_log_info *rli);
3934
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
3937
Primitive to prepare for a sequence of row executions.
3941
Before doing a sequence of do_prepare_row() and do_exec_row()
3942
calls, this member function should be called to prepare for the
3943
entire sequence. Typically, this member function will allocate
3944
space for any buffers that are needed for the two member
3945
functions mentioned above.
3949
The member function will return 0 if all went OK, or a non-zero
3950
error code otherwise.
3953
int do_before_row_operations(const Slave_reporting_capability *const log) = 0;
3956
Primitive to clean up after a sequence of row executions.
3960
After doing a sequence of do_prepare_row() and do_exec_row(),
3961
this member function should be called to clean up and release
3962
any allocated buffers.
3964
The error argument, if non-zero, indicates an error which happened during
3965
row processing before this function was called. In this case, even if
3966
function is successful, it should return the error code given in the argument.
3969
int do_after_row_operations(const Slave_reporting_capability *const log,
3973
Primitive to do the actual execution necessary for a row.
3976
The member function will do the actual execution needed to handle a row.
3977
The row is located at m_curr_row. When the function returns,
3978
m_curr_row_end should point at the next row (one byte after the end
3979
of the current row).
3982
0 if execution succeeded, 1 if execution failed.
3985
virtual int do_exec_row(const Relay_log_info *const rli) = 0;
3986
#endif /* defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) */
3988
friend class Old_rows_log_event;
3992
@class Write_rows_log_event
3994
Log row insertions and updates. The event contain several
3995
insert/update rows for a table. Note that each event contains only
3998
@section Write_rows_log_event_binary_format Binary Format
4000
class Write_rows_log_event : public Rows_log_event
4005
/* Support interface to THD::binlog_prepare_pending_rows_event */
4006
TYPE_CODE = WRITE_ROWS_EVENT
4009
#if defined(MYSQL_SERVER)
4010
Write_rows_log_event(THD*, TABLE*, ulong table_id,
4011
MY_BITMAP const *cols, bool is_transactional);
4013
#ifdef HAVE_REPLICATION
4014
Write_rows_log_event(const char *buf, uint event_len,
4015
const Format_description_log_event *description_event);
4017
#if defined(MYSQL_SERVER)
4018
static bool binlog_row_logging_function(THD *thd, TABLE *table,
4019
bool is_transactional,
4022
const uchar *before_record
4023
__attribute__((unused)),
4024
const uchar *after_record)
4026
return thd->binlog_write_row(table, is_transactional,
4027
cols, fields, after_record);
4032
virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
4035
void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
4038
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
4039
virtual int do_before_row_operations(const Slave_reporting_capability *const);
4040
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
4041
virtual int do_exec_row(const Relay_log_info *const);
4047
@class Update_rows_log_event
4049
Log row updates with a before image. The event contain several
4050
update rows for a table. Note that each event contains only rows for
4053
Also note that the row data consists of pairs of row data: one row
4054
for the old data and one row for the new data.
4056
@section Update_rows_log_event_binary_format Binary Format
4058
class Update_rows_log_event : public Rows_log_event
4063
/* Support interface to THD::binlog_prepare_pending_rows_event */
4064
TYPE_CODE = UPDATE_ROWS_EVENT
4068
Update_rows_log_event(THD*, TABLE*, ulong table_id,
4069
MY_BITMAP const *cols_bi,
4070
MY_BITMAP const *cols_ai,
4071
bool is_transactional);
4073
Update_rows_log_event(THD*, TABLE*, ulong table_id,
4074
MY_BITMAP const *cols,
4075
bool is_transactional);
4077
void init(MY_BITMAP const *cols);
4080
virtual ~Update_rows_log_event();
4082
#ifdef HAVE_REPLICATION
4083
Update_rows_log_event(const char *buf, uint event_len,
4084
const Format_description_log_event *description_event);
4088
static bool binlog_row_logging_function(THD *thd, TABLE *table,
4089
bool is_transactional,
4092
const uchar *before_record,
4093
const uchar *after_record)
4095
return thd->binlog_update_row(table, is_transactional,
4096
cols, fields, before_record, after_record);
4100
virtual bool is_valid() const
4102
return Rows_log_event::is_valid() && m_cols_ai.bitmap;
4106
virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
4109
void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
4112
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
4113
virtual int do_before_row_operations(const Slave_reporting_capability *const);
4114
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
4115
virtual int do_exec_row(const Relay_log_info *const);
4116
#endif /* defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) */
4120
@class Delete_rows_log_event
4122
Log row deletions. The event contain several delete rows for a
4123
table. Note that each event contains only rows for one table.
4127
- Act as a container for rows that has been deleted on the master
4128
and should be deleted on the slave.
4133
Create the event and add rows to the event.
4135
Extract the rows from the event.
4137
@section Delete_rows_log_event_binary_format Binary Format
4139
class Delete_rows_log_event : public Rows_log_event
4144
/* Support interface to THD::binlog_prepare_pending_rows_event */
4145
TYPE_CODE = DELETE_ROWS_EVENT
4149
Delete_rows_log_event(THD*, TABLE*, ulong,
4150
MY_BITMAP const *cols, bool is_transactional);
4152
#ifdef HAVE_REPLICATION
4153
Delete_rows_log_event(const char *buf, uint event_len,
4154
const Format_description_log_event *description_event);
4157
static bool binlog_row_logging_function(THD *thd, TABLE *table,
4158
bool is_transactional,
4161
const uchar *before_record,
4162
const uchar *after_record
4163
__attribute__((unused)))
4165
return thd->binlog_delete_row(table, is_transactional,
4166
cols, fields, before_record);
4171
virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
4174
void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
4177
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
4178
virtual int do_before_row_operations(const Slave_reporting_capability *const);
4179
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
4180
virtual int do_exec_row(const Relay_log_info *const);
4185
#include "log_event_old.h"
4188
@class Incident_log_event
4190
Class representing an incident, an occurance out of the ordinary,
4191
that happened on the master.
4193
The event is used to inform the slave that something out of the
4194
ordinary happened on the master that might cause the database to be
4195
in an inconsistent state.
4197
<table id="IncidentFormat">
4198
<caption>Incident event format</caption>
4202
<th>Description</th>
4206
<td align="right">2</td>
4207
<td>Incident number as an unsigned integer</td>
4211
<td align="right">1</td>
4212
<td>Message length as an unsigned integer</td>
4216
<td align="right">MSGLEN</td>
4217
<td>The message, if present. Not null terminated.</td>
4221
@section Delete_rows_log_event_binary_format Binary Format
4223
class Incident_log_event : public Log_event {
4226
Incident_log_event(THD *thd_arg, Incident incident)
4227
: Log_event(thd_arg, 0, FALSE), m_incident(incident)
4229
DBUG_ENTER("Incident_log_event::Incident_log_event");
4230
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
4231
m_message.str= NULL; /* Just as a precaution */
4232
m_message.length= 0;
4233
set_direct_logging();
4234
/* Replicate the incident irregardless of @@skip_replication. */
4235
flags&= ~LOG_EVENT_SKIP_REPLICATION_F;
4239
Incident_log_event(THD *thd_arg, Incident incident, LEX_STRING const msg)
4240
: Log_event(thd_arg, 0, FALSE), m_incident(incident)
4242
DBUG_ENTER("Incident_log_event::Incident_log_event");
4243
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
4245
set_direct_logging();
4246
/* Replicate the incident irregardless of @@skip_replication. */
4247
flags&= ~LOG_EVENT_SKIP_REPLICATION_F;
4253
void pack_info(THD *thd, Protocol*);
4256
Incident_log_event(const char *buf, uint event_len,
4257
const Format_description_log_event *descr_event);
4259
virtual ~Incident_log_event();
4262
virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
4265
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
4266
virtual int do_apply_event(Relay_log_info const *rli);
4269
virtual bool write_data_header(IO_CACHE *file);
4270
virtual bool write_data_body(IO_CACHE *file);
4272
virtual Log_event_type get_type_code() { return INCIDENT_EVENT; }
4274
virtual bool is_valid() const
4276
return m_incident > INCIDENT_NONE && m_incident < INCIDENT_COUNT;
4278
virtual int get_data_size() {
4279
return INCIDENT_HEADER_LEN + 1 + (uint) m_message.length;
4283
const char *description() const;
4285
Incident m_incident;
4286
LEX_STRING m_message;
4289
static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
4293
my_b_copy_to_file(cache, file) ||
4294
reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE);
4298
/*****************************************************************************
4300
Heartbeat Log Event class
4302
Replication event to ensure to slave that master is alive.
4303
The event is originated by master's dump thread and sent straight to
4304
slave without being logged. Slave itself does not store it in relay log
4305
but rather uses a data for immediate checks and throws away the event.
4307
Two members of the class log_ident and Log_event::log_pos comprise
4308
@see the event_coordinates instance. The coordinates that a heartbeat
4309
instance carries correspond to the last event master has sent from
4312
****************************************************************************/
4313
class Heartbeat_log_event: public Log_event
4316
Heartbeat_log_event(const char* buf, uint event_len,
4317
const Format_description_log_event* description_event);
4318
Log_event_type get_type_code() { return HEARTBEAT_LOG_EVENT; }
4319
bool is_valid() const
4321
return (log_ident != NULL &&
4322
log_pos >= BIN_LOG_HEADER_SIZE);
4324
const char * get_log_ident() { return log_ident; }
4325
uint get_ident_len() { return ident_len; }
4328
const char* log_ident;
4333
The function is called by slave applier in case there are
4334
active table filtering rules to force gathering events associated
4335
with Query-log-event into an array to execute
4336
them once the fate of the Query is determined for execution.
4338
bool slave_execute_deferred_events(THD *thd);
4341
int append_query_string(THD *thd, CHARSET_INFO *csinfo,
4342
String const *from, String *to);
4344
bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
4345
const char **group_relay_log_name,
4346
ulonglong *relay_log_pos);
4348
bool event_checksum_test(uchar *buf, ulong event_len, uint8 alg);
4349
uint8 get_checksum_alg(const char* buf, ulong len);
4350
extern TYPELIB binlog_checksum_typelib;
4352
#ifndef MYSQL_CLIENT
4354
The function is called by slave applier in case there are
4355
active table filtering rules to force gathering events associated
4356
with Query-log-event into an array to execute
4357
them once the fate of the Query is determined for execution.
4359
bool slave_execute_deferred_events(THD *thd);
4363
@} (end of group Replication)
4366
#endif /* _log_event_h */