MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Log_event Class Reference

#include <log_event.h>

Inheritance diagram for Log_event:
Collaboration diagram for Log_event:

Public Types

enum  enum_skip_reason { EVENT_SKIP_NOT, EVENT_SKIP_IGNORE, EVENT_SKIP_COUNT }
typedef unsigned char Byte

Public Member Functions

 Log_event (enum_event_cache_type cache_type_arg=EVENT_INVALID_CACHE, enum_event_logging_type logging_type_arg=EVENT_INVALID_LOGGING)
virtual void print (FILE *file, PRINT_EVENT_INFO *print_event_info)=0
void print_timestamp (IO_CACHE *file, time_t *ts)
void print_header (IO_CACHE *file, PRINT_EVENT_INFO *print_event_info, bool is_more)
void print_base64 (IO_CACHE *file, PRINT_EVENT_INFO *print_event_info, bool is_more)
bool wrapper_my_b_safe_write (IO_CACHE *file, const uchar *buf, ulong data_length)
virtual Log_event_type get_type_code ()=0
virtual bool is_valid () const =0
void set_artificial_event ()
void set_relay_log_event ()
bool is_artificial_event () const
bool is_relay_log_event () const
bool is_ignorable_event () const
bool is_no_filter_event () const
bool is_using_trans_cache () const
bool is_using_stmt_cache () const
bool is_using_immediate_logging () const
 Log_event (const char *buf, const Format_description_log_event *description_event)
void register_temp_buf (char *buf)
void free_temp_buf ()
virtual int get_data_size ()
const char * get_type_str ()

Static Public Member Functions

static Log_eventread_log_event (IO_CACHE *file, const Format_description_log_event *description_event, my_bool crc_check)
static void * operator new (size_t size)
static void operator delete (void *ptr, size_t)
static void * operator new (size_t, void *ptr)
static void operator delete (void *, void *)
static Log_eventread_log_event (const char *buf, uint event_len, const char **error, const Format_description_log_event *description_event, my_bool crc_check)
static const char * get_type_str (Log_event_type type)

Public Attributes

my_off_t log_pos
char * temp_buf
struct timeval when
ulong exec_time
ulong data_written
uint32 server_id
uint32 unmasked_server_id
uint16 flags
ulong slave_exec_mode
enum_event_cache_type event_cache_type
enum_event_logging_type event_logging_type
ha_checksum crc
ulong mts_group_idx
Relay_log_infoworker
ulonglong future_event_relay_log_pos
uint8 checksum_alg

Protected Types

enum  enum_event_cache_type {
  EVENT_INVALID_CACHE = 0, EVENT_STMT_CACHE, EVENT_TRANSACTIONAL_CACHE, EVENT_NO_CACHE,
  EVENT_CACHE_COUNT
}
enum  enum_event_logging_type { EVENT_INVALID_LOGGING = 0, EVENT_NORMAL_LOGGING, EVENT_IMMEDIATE_LOGGING, EVENT_CACHE_LOGGING_COUNT }

Detailed Description

This is the abstract base class for binary log events.

Binary Format

Any Log_event saved on disk consists of the following three components.

  • Common-Header
  • Post-Header
  • Body

The Common-Header, documented in the table below, always has the same form and length within one version of MySQL. Each event type specifies a format and length of the Post-Header. The length of the Common-Header is the same for all events of the same type. The Body may be of different format and length even for different events of the same type. The binary formats of Post-Header and Body are documented separately in each subclass. The binary format of Common-Header is as follows.

Common-Header
Name Format

Description

timestamp 4 byte unsigned integer

The time when the query started, in seconds since 1970.

type 1 byte enumeration

See enum Log_event_type.

server_id 4 byte unsigned integer

Server ID of the server that created the event.

total_size 4 byte unsigned integer

The total size of this event, in bytes. In other words, this is the sum of the sizes of Common-Header, Post-Header, and Body.

master_position 4 byte unsigned integer

The position of the next event in the master binary log, in bytes from the beginning of the file. In a binlog that is not a relay log, this is just the position of the next event, in bytes from the beginning of the file. In a relay log, this is the position of the next event in the master's binlog.

flags 2 byte bitfield See Log_event::flags.

Summing up the numbers above, we see that the total size of the common header is 19 bytes.

Format of Atomic Primitives

  • All numbers, whether they are 16-, 24-, 32-, or 64-bit numbers, are stored in little endian, i.e., the least significant byte first, unless otherwise specified.

  • Some events use a special format for efficient representation of unsigned integers, called Packed Integer. A Packed Integer has the capacity of storing up to 8-byte integers, while small integers still can use 1, 3, or 4 bytes. The value of the first byte determines how to read the number, according to the following table:
Format of Packed Integer
First byte

Format

0-250

The first byte is the number (in the range 0-250), and no more bytes are used.

252

Two more bytes are used. The number is in the range 251-0xffff.

253

Three more bytes are used. The number is in the range 0xffff-0xffffff.

254

Eight more bytes are used. The number is in the range 0xffffff-0xffffffffffffffff.

  • Strings are stored in various formats. The format of each string is documented separately.

Definition at line 970 of file log_event.h.

Member Enumeration Documentation

Enumeration of what kinds of skipping (and non-skipping) that can occur when the slave executes an event.

See Also
shall_skip
do_shall_skip
Enumerator:
EVENT_SKIP_NOT 

Don't skip event.

EVENT_SKIP_IGNORE 

Skip event by ignoring it.

This means that the slave skip counter will not be changed.

EVENT_SKIP_COUNT 

Skip event and decrease skip counter.

Definition at line 980 of file log_event.h.

Constructor & Destructor Documentation

Log_event::Log_event ( enum_event_cache_type  cache_type_arg = EVENT_INVALID_CACHE,
enum_event_logging_type  logging_type_arg = EVENT_INVALID_LOGGING 
)
inline

This minimal constructor is for when you are not even sure that there is a valid THD. For example in the server when we are shutting down or flushing logs after receiving a SIGHUP (then we must write a Rotate to the binlog but we have no THD, so we need this minimal constructor).

Definition at line 1228 of file log_event.h.

Member Function Documentation

const char * Log_event::get_type_str ( Log_event_type  type)
static

Returns the human readable name of the given event type.

Prints a "session_var=value" string. Used by mysqlbinlog to print some SET commands just before it prints a query.

Returns
returns the human readable name of the event's type

Definition at line 661 of file log_event.cc.

Here is the caller graph for this function:

const char * Log_event::get_type_str ( )

Returns the human readable name of this event's type.

Definition at line 702 of file log_event.cc.

Here is the caller graph for this function:

Log_event * Log_event::read_log_event ( const char *  buf,
uint  event_len,
const char **  error,
const Format_description_log_event description_event,
my_bool  crc_check 
)
static

Binlog format tolerance is in (buf, event_len, description_event) constructors.

Definition at line 1412 of file log_event.cc.

Here is the call graph for this function:

Member Data Documentation

ha_checksum Log_event::crc

Placeholder for event checksum while writing to binlog.

Definition at line 1124 of file log_event.h.

enum_event_cache_type Log_event::event_cache_type

Defines the type of the cache, if any, where the event will be stored before being flushed to disk.

Definition at line 1113 of file log_event.h.

enum_event_logging_type Log_event::event_logging_type

Defines when information, i.e. event or cache, will be flushed to disk.

Definition at line 1119 of file log_event.h.

uint16 Log_event::flags

Some 16 flags. See the definitions above for LOG_EVENT_TIME_F, LOG_EVENT_FORCED_ROTATE_F, LOG_EVENT_THREAD_SPECIFIC_F, and LOG_EVENT_SUPPRESS_USE_F for notes.

Definition at line 1101 of file log_event.h.

ulonglong Log_event::future_event_relay_log_pos

A copy of the main rli value stored into event to pass to MTS worker rli

Definition at line 1144 of file log_event.h.

ulong Log_event::mts_group_idx

Index in rli->gaq array to indicate a group that this event is purging. The index is set by Coordinator to a group terminator event is checked by Worker at the event execution. The indexed data represent the Worker progress status.

Definition at line 1132 of file log_event.h.

ulong Log_event::slave_exec_mode

A storage to cache the global system variable's value. Handling of a separate event will be governed its member.

Definition at line 1107 of file log_event.h.

Relay_log_info* Log_event::worker

MTS: associating the event with either an assigned Worker or Coordinator. Additionally the member serves to tag deferred (IRU) events to avoid the event regular time destruction.

Definition at line 1139 of file log_event.h.


The documentation for this class was generated from the following files: