Skip to content

Compressed binary log #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion client/mysqlbinlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1535,9 +1535,15 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
case binary_log::WRITE_ROWS_EVENT:
case binary_log::DELETE_ROWS_EVENT:
case binary_log::UPDATE_ROWS_EVENT:
case binary_log::WRITE_ROWS_COMPRESSED_EVENT:
case binary_log::DELETE_ROWS_COMPRESSED_EVENT:
case binary_log::UPDATE_ROWS_COMPRESSED_EVENT:
case binary_log::WRITE_ROWS_EVENT_V1:
case binary_log::UPDATE_ROWS_EVENT_V1:
case binary_log::DELETE_ROWS_EVENT_V1:
case binary_log::WRITE_ROWS_COMPRESSED_EVENT_V1:
case binary_log::DELETE_ROWS_COMPRESSED_EVENT_V1:
case binary_log::UPDATE_ROWS_COMPRESSED_EVENT_V1:
case binary_log::PRE_GA_WRITE_ROWS_EVENT:
case binary_log::PRE_GA_DELETE_ROWS_EVENT:
case binary_log::PRE_GA_UPDATE_ROWS_EVENT:
Expand All @@ -1547,9 +1553,15 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
if (ev_type == binary_log::WRITE_ROWS_EVENT ||
ev_type == binary_log::DELETE_ROWS_EVENT ||
ev_type == binary_log::UPDATE_ROWS_EVENT ||
ev_type == binary_log::WRITE_ROWS_COMPRESSED_EVENT ||
ev_type == binary_log::DELETE_ROWS_COMPRESSED_EVENT ||
ev_type == binary_log::UPDATE_ROWS_COMPRESSED_EVENT ||
ev_type == binary_log::WRITE_ROWS_EVENT_V1 ||
ev_type == binary_log::DELETE_ROWS_EVENT_V1 ||
ev_type == binary_log::UPDATE_ROWS_EVENT_V1)
ev_type == binary_log::UPDATE_ROWS_EVENT_V1 ||
ev_type == binary_log::WRITE_ROWS_COMPRESSED_EVENT_V1 ||
ev_type == binary_log::DELETE_ROWS_COMPRESSED_EVENT_V1 ||
ev_type == binary_log::UPDATE_ROWS_COMPRESSED_EVENT_V1)
{
Rows_log_event *new_ev= (Rows_log_event*) ev;
if (new_ev->get_flags(Rows_log_event::STMT_END_F))
Expand Down
9 changes: 9 additions & 0 deletions libbinlogevents/include/binlog_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ enum Log_event_type

/* Prepared XA transaction terminal event similar to Xid */
XA_PREPARE_LOG_EVENT= 38,

/* Compressed binlog event. */
QUERY_COMPRESSED_EVENT = 50,
WRITE_ROWS_COMPRESSED_EVENT_V1 = 51,
UPDATE_ROWS_COMPRESSED_EVENT_V1 = 52,
DELETE_ROWS_COMPRESSED_EVENT_V1 = 53,
WRITE_ROWS_COMPRESSED_EVENT = 54,
UPDATE_ROWS_COMPRESSED_EVENT = 55,
DELETE_ROWS_COMPRESSED_EVENT = 56,
/**
Add new events here - right above this comment!
Existing events (except ENUM_END_EVENT) should never change their numbers
Expand Down
13 changes: 13 additions & 0 deletions libbinlogevents/src/control_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ Format_description_event::Format_description_event(uint8_t binlog_ver,
*/
post_header_len.insert(post_header_len.begin(), server_event_header_length,
server_event_header_length + number_of_event_types);
/*
Each time add a new type event, if the event are not continuous,
you must set the event head len explicit
*/
for (int i = PREVIOUS_GTIDS_LOG_EVENT; i < QUERY_COMPRESSED_EVENT; i++)
post_header_len[i] = 0;
post_header_len[QUERY_COMPRESSED_EVENT - 1] = QUERY_HEADER_LEN;
post_header_len[WRITE_ROWS_COMPRESSED_EVENT_V1 - 1] = ROWS_HEADER_LEN_V1;
post_header_len[UPDATE_ROWS_COMPRESSED_EVENT_V1 - 1] = ROWS_HEADER_LEN_V1;
post_header_len[DELETE_ROWS_COMPRESSED_EVENT_V1 - 1] = ROWS_HEADER_LEN_V1;
post_header_len[WRITE_ROWS_COMPRESSED_EVENT - 1] = ROWS_HEADER_LEN_V2;
post_header_len[UPDATE_ROWS_COMPRESSED_EVENT - 1] = ROWS_HEADER_LEN_V2;
post_header_len[DELETE_ROWS_COMPRESSED_EVENT - 1] = ROWS_HEADER_LEN_V2;
// Sanity-check that all post header lengths are initialized.
#ifndef DBUG_OFF
for (int i= 0; i < number_of_event_types; i++)
Expand Down
4 changes: 3 additions & 1 deletion libbinlogevents/src/rows_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ Rows_event::Rows_event(const char *buf, unsigned int event_len,

columns_after_image= columns_before_image;
if ((event_type == UPDATE_ROWS_EVENT) ||
(event_type == UPDATE_ROWS_EVENT_V1))
(event_type == UPDATE_ROWS_COMPRESSED_EVENT) ||
(event_type == UPDATE_ROWS_EVENT_V1) ||
(event_type == UPDATE_ROWS_COMPRESSED_EVENT_V1))
{
columns_after_image.reserve((m_width + 7) / 8);
columns_after_image.clear();
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/r/flush2.result
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ show variables like 'log_bin%';
Variable_name Value
log_bin OFF
log_bin_basename
log_bin_compress OFF
log_bin_compress_min_len 256
log_bin_index
log_bin_trust_function_creators ON
log_bin_use_v1_row_events OFF
Expand All @@ -22,6 +24,8 @@ show variables like 'log_bin%';
Variable_name Value
log_bin OFF
log_bin_basename
log_bin_compress OFF
log_bin_compress_min_len 256
log_bin_index
log_bin_trust_function_creators ON
log_bin_use_v1_row_events OFF
Expand Down
Loading