summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mkindahl@dl145h.mysql.com>2008-01-30 12:53:33 +0100
committerunknown <mkindahl@dl145h.mysql.com>2008-01-30 12:53:33 +0100
commit9a51d88bfdd74099e9b98234de57c2a0a83620a0 (patch)
tree74b925b2949170822b288f1dccb6bf327fa36a08 /sql
parentb0f52885519dd934c88574f72baec0008fdf110d (diff)
parent817bfa350c6ea2464f1357969f17acd08b909e14 (diff)
downloadmariadb-git-9a51d88bfdd74099e9b98234de57c2a0a83620a0.tar.gz
Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl
into dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl-merge BitKeeper/deleted/.del-binlog_start_comment.result: Auto merged include/my_sys.h: Auto merged mysql-test/extra/binlog_tests/blackhole.test: Auto merged mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Auto merged mysql-test/r/case.result: Auto merged mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result: Auto merged mysql-test/suite/binlog/r/binlog_stm_blackhole.result: Auto merged mysql-test/suite/rpl/r/rpl_000015.result: Auto merged mysql-test/suite/rpl/t/rpl_000015.test: Auto merged mysql-test/t/case.test: Auto merged sql/log_event.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_parse.cc: Auto merged BitKeeper/deleted/.del-binlog_start_comment.test: Using remote file. mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result: Manual merge. Taking remote file to update result set after merge, mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result: Manual merge. mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result: Manual merge.
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc86
-rw-r--r--sql/log_event.h6
-rw-r--r--sql/sql_acl.cc27
-rw-r--r--sql/sql_parse.cc1
-rw-r--r--sql/sql_repl.cc75
5 files changed, 155 insertions, 40 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index a8099e9db8a..46ac5e6f571 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1071,6 +1071,29 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
}
else
{
+ /*
+ In some previuos versions (see comment in
+ Format_description_log_event::Format_description_log_event(char*,...)),
+ event types were assigned different id numbers than in the
+ present version. In order to replicate from such versions to the
+ present version, we must map those event type id's to our event
+ type id's. The mapping is done with the event_type_permutation
+ array, which was set up when the Format_description_log_event
+ was read.
+ */
+ if (description_event->event_type_permutation)
+ {
+ IF_DBUG({
+ int new_event_type=
+ description_event->event_type_permutation[event_type];
+ DBUG_PRINT("info",
+ ("converting event type %d to %d (%s)",
+ event_type, new_event_type,
+ get_type_str((Log_event_type)new_event_type)));
+ });
+ event_type= description_event->event_type_permutation[event_type];
+ }
+
switch(event_type) {
case QUERY_EVENT:
ev = new Query_log_event(buf, event_len, description_event, QUERY_EVENT);
@@ -2773,7 +2796,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
Format_description_log_event::
Format_description_log_event(uint8 binlog_ver, const char* server_ver)
- :Start_log_event_v3()
+ :Start_log_event_v3(), event_type_permutation(0)
{
binlog_version= binlog_ver;
switch (binlog_ver) {
@@ -2898,7 +2921,7 @@ Format_description_log_event(const char* buf,
const
Format_description_log_event*
description_event)
- :Start_log_event_v3(buf, description_event)
+ :Start_log_event_v3(buf, description_event), event_type_permutation(0)
{
DBUG_ENTER("Format_description_log_event::Format_description_log_event(char*,...)");
buf+= LOG_EVENT_MINIMAL_HEADER_LEN;
@@ -2913,6 +2936,65 @@ Format_description_log_event(const char* buf,
number_of_event_types*
sizeof(*post_header_len), MYF(0));
calc_server_version_split();
+
+ /*
+ In some previous versions, the events were given other event type
+ id numbers than in the present version. When replicating from such
+ a version, we therefore set up an array that maps those id numbers
+ to the id numbers of the present server.
+
+ If post_header_len is null, it means malloc failed, and is_valid
+ will fail, so there is no need to do anything.
+
+ The trees which have wrong event id's are:
+ mysql-5.1-wl2325-5.0-drop6p13-alpha, mysql-5.1-wl2325-5.0-drop6,
+ mysql-5.1-wl2325-5.0, mysql-5.1-wl2325-no-dd (`grep -C2
+ BEGIN_LOAD_QUERY_EVENT /home/bk/ * /sql/log_event.h`). The
+ corresponding version (`grep mysql, configure.in` in those trees)
+ strings are 5.2.2-a_drop6p13-alpha, 5.2.2-a_drop6p13c,
+ 5.1.5-a_drop5p20, 5.1.2-a_drop5p5.
+ */
+ if (post_header_len &&
+ (strncmp(server_version, "5.1.2-a_drop5", 13) == 0 ||
+ strncmp(server_version, "5.1.5-a_drop5", 13) == 0 ||
+ strncmp(server_version, "5.2.2-a_drop6", 13) == 0))
+ {
+ if (number_of_event_types != 22)
+ {
+ DBUG_PRINT("info", (" number_of_event_types=%d",
+ number_of_event_types));
+ /* this makes is_valid() return false. */
+ my_free(post_header_len, MYF(MY_ALLOW_ZERO_PTR));
+ post_header_len= NULL;
+ DBUG_VOID_RETURN;
+ }
+ static const uint8 perm[23]=
+ {
+ UNKNOWN_EVENT, START_EVENT_V3, QUERY_EVENT, STOP_EVENT, ROTATE_EVENT,
+ INTVAR_EVENT, LOAD_EVENT, SLAVE_EVENT, CREATE_FILE_EVENT,
+ APPEND_BLOCK_EVENT, EXEC_LOAD_EVENT, DELETE_FILE_EVENT,
+ NEW_LOAD_EVENT,
+ RAND_EVENT, USER_VAR_EVENT,
+ FORMAT_DESCRIPTION_EVENT,
+ TABLE_MAP_EVENT,
+ PRE_GA_WRITE_ROWS_EVENT,
+ PRE_GA_UPDATE_ROWS_EVENT,
+ PRE_GA_DELETE_ROWS_EVENT,
+ XID_EVENT,
+ BEGIN_LOAD_QUERY_EVENT,
+ EXECUTE_LOAD_QUERY_EVENT,
+ };
+ event_type_permutation= perm;
+ /*
+ Since we use (permuted) event id's to index the post_header_len
+ array, we need to permute the post_header_len array too.
+ */
+ uint8 post_header_len_temp[23];
+ for (int i= 1; i < 23; i++)
+ post_header_len_temp[perm[i] - 1]= post_header_len[i - 1];
+ for (int i= 0; i < 22; i++)
+ post_header_len[i] = post_header_len_temp[i];
+ }
DBUG_VOID_RETURN;
}
diff --git a/sql/log_event.h b/sql/log_event.h
index 4a75f330203..31c1ab7173a 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -2106,12 +2106,16 @@ public:
/* The list of post-headers' lengthes */
uint8 *post_header_len;
uchar server_version_split[3];
+ const uint8 *event_type_permutation;
Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
Format_description_log_event(const char* buf, uint event_len,
const Format_description_log_event
*description_event);
- ~Format_description_log_event() { my_free((uchar*)post_header_len, MYF(0)); }
+ ~Format_description_log_event()
+ {
+ my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR));
+ }
Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index d2d26da229a..0d563ab9051 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -5579,6 +5579,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_name, *tmp_user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
+ bool some_users_created= FALSE;
DBUG_ENTER("mysql_create_user");
/*
@@ -5614,6 +5615,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
continue;
}
+ some_users_created= TRUE;
sql_mode= thd->variables.sql_mode;
if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
{
@@ -5624,12 +5626,14 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- write_bin_log(thd, FALSE, thd->query, thd->query_length);
+ if (result)
+ my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
+
+ if (some_users_created)
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
- if (result)
- my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
DBUG_RETURN(result);
}
@@ -5654,6 +5658,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_name, *tmp_user_name;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
+ bool some_users_deleted= FALSE;
DBUG_ENTER("mysql_drop_user");
/*
@@ -5682,7 +5687,9 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
{
append_user(&wrong_users, user_name);
result= TRUE;
+ continue;
}
+ some_users_deleted= TRUE;
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
@@ -5693,7 +5700,8 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
if (result)
my_error(ER_CANNOT_USER, MYF(0), "DROP USER", wrong_users.c_ptr_safe());
- write_bin_log(thd, FALSE, thd->query, thd->query_length);
+ if (some_users_deleted)
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
@@ -5722,6 +5730,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
LEX_USER *user_to, *tmp_user_to;
List_iterator <LEX_USER> user_list(list);
TABLE_LIST tables[GRANT_TABLES];
+ bool some_users_renamed= FALSE;
DBUG_ENTER("mysql_rename_user");
/*
@@ -5762,7 +5771,9 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
{
append_user(&wrong_users, user_from);
result= TRUE;
+ continue;
}
+ some_users_renamed= TRUE;
}
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
@@ -5770,12 +5781,14 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
VOID(pthread_mutex_unlock(&acl_cache->lock));
- write_bin_log(thd, FALSE, thd->query, thd->query_length);
+ if (result)
+ my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
+
+ if (some_users_renamed && mysql_bin_log.is_open())
+ write_bin_log(thd, FALSE, thd->query, thd->query_length);
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
- if (result)
- my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
DBUG_RETURN(result);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index b60a72e4c53..7261668c05e 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1272,7 +1272,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
unregister_slave(thd,1,1);
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
error = TRUE;
- net->error = 0;
break;
}
#endif
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 88040e2933c..49c4f089298 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1243,9 +1243,6 @@ bool change_master(THD* thd, Master_info* mi)
DBUG_RETURN(TRUE);
}
}
- mi->rli.group_master_log_pos = mi->master_log_pos;
- DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
-
/*
Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block,
so restore them to good values. If we left them to ''/0, that would work;
@@ -1257,6 +1254,7 @@ bool change_master(THD* thd, Master_info* mi)
That's why we always save good coords in rli.
*/
mi->rli.group_master_log_pos= mi->master_log_pos;
+ DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
strmake(mi->rli.group_master_log_name,mi->master_log_name,
sizeof(mi->rli.group_master_log_name)-1);
@@ -1376,6 +1374,11 @@ bool mysql_show_binlog_events(THD* thd)
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
goto err;
+ /*
+ to account binlog event header size
+ */
+ thd->variables.max_allowed_packet += MAX_LOG_EVENT_HEADER;
+
pthread_mutex_lock(log_lock);
/*
@@ -1386,7 +1389,6 @@ bool mysql_show_binlog_events(THD* thd)
This code will fail on a mixed relay log (one which has Format_desc then
Rotate then Format_desc).
*/
-
ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event);
if (ev)
{
@@ -1578,39 +1580,54 @@ err:
DBUG_RETURN(TRUE);
}
-
+/**
+ Load data's io cache specific hook to be executed
+ before a chunk of data is being read into the cache's buffer
+ The fuction instantianates and writes into the binlog
+ replication events along LOAD DATA processing.
+
+ @param file pointer to io-cache
+ @return 0
+*/
int log_loaded_block(IO_CACHE* file)
{
+ DBUG_ENTER("log_loaded_block");
LOAD_FILE_INFO *lf_info;
- uint block_len ;
-
- /* file->request_pos contains position where we started last read */
- char* buffer = (char*) file->request_pos;
- if (!(block_len = (char*) file->read_end - (char*) buffer))
- return 0;
- lf_info = (LOAD_FILE_INFO*) file->arg;
+ uint block_len;
+ /* buffer contains position where we started last read */
+ char* buffer= my_b_get_buffer_start(file);
+ uint max_event_size= current_thd->variables.max_allowed_packet;
+ lf_info= (LOAD_FILE_INFO*) file->arg;
if (lf_info->thd->current_stmt_binlog_row_based)
return 0;
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
- lf_info->last_pos_in_file >= file->pos_in_file)
- return 0;
- lf_info->last_pos_in_file = file->pos_in_file;
- if (lf_info->wrote_create_file)
- {
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
- block_len, lf_info->log_delayed);
- mysql_bin_log.write(&a);
- }
- else
+ lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
+ DBUG_RETURN(0);
+
+ for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0;
+ buffer += min(block_len, max_event_size),
+ block_len -= min(block_len, max_event_size))
{
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
- buffer, block_len,
- lf_info->log_delayed);
- mysql_bin_log.write(&b);
- lf_info->wrote_create_file = 1;
- DBUG_SYNC_POINT("debug_lock.created_file_event",10);
+ lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
+ if (lf_info->wrote_create_file)
+ {
+ Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
+ min(block_len, max_event_size),
+ lf_info->log_delayed);
+ mysql_bin_log.write(&a);
+ }
+ else
+ {
+ Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
+ buffer,
+ min(block_len, max_event_size),
+ lf_info->log_delayed);
+ mysql_bin_log.write(&b);
+ lf_info->wrote_create_file= 1;
+ DBUG_SYNC_POINT("debug_lock.created_file_event",10);
+ }
}
- return 0;
+ DBUG_RETURN(0);
}
/*