Commit 4a80a6c7 authored by guilhem@mysql.com's avatar guilhem@mysql.com

One-line fix for bug 576 (DBUG_ASSERT failure when using CHANGE MASTER TO RELAY_LOG_POS=4).

Plus a changeset which I had committed but forgot to push (and this changeset is lost on
another computer, so I recreate it here). This changeset is "user-friendly SHOW BINLOG EVENTS
and CHANGE MASTER TO when log positions < 4 are used.
parent 3b974039
...@@ -269,7 +269,7 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log, ...@@ -269,7 +269,7 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,
goto err; goto err;
rli->cur_log = &rli->cache_buf; rli->cur_log = &rli->cache_buf;
} }
if (pos > BIN_LOG_HEADER_SIZE) if (pos >= BIN_LOG_HEADER_SIZE)
my_b_seek(rli->cur_log,(off_t)pos); my_b_seek(rli->cur_log,(off_t)pos);
err: err:
......
...@@ -961,7 +961,7 @@ int show_binlog_events(THD* thd) ...@@ -961,7 +961,7 @@ int show_binlog_events(THD* thd)
{ {
LEX_MASTER_INFO *lex_mi = &thd->lex.mi; LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
ha_rows event_count, limit_start, limit_end; ha_rows event_count, limit_start, limit_end;
my_off_t pos = lex_mi->pos; my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
char search_file_name[FN_REFLEN], *name; char search_file_name[FN_REFLEN], *name;
const char *log_file_name = lex_mi->log_file_name; const char *log_file_name = lex_mi->log_file_name;
pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock(); pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
...@@ -989,12 +989,6 @@ int show_binlog_events(THD* thd) ...@@ -989,12 +989,6 @@ int show_binlog_events(THD* thd)
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0) if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
goto err; goto err;
if (pos < 4)
{
errmsg = "Invalid log position";
goto err;
}
pthread_mutex_lock(log_lock); pthread_mutex_lock(log_lock);
my_b_seek(&log, pos); my_b_seek(&log, pos);
......
...@@ -706,6 +706,18 @@ master_def: ...@@ -706,6 +706,18 @@ master_def:
MASTER_LOG_POS_SYM EQ ulonglong_num MASTER_LOG_POS_SYM EQ ulonglong_num
{ {
Lex->mi.pos = $3; Lex->mi.pos = $3;
/*
If the user specified a value < BIN_LOG_HEADER_SIZE, adjust it
instead of causing subsequent errors.
We need to do it in this file, because only there we know that
MASTER_LOG_POS has been explicitely specified. On the contrary
in change_master() (sql_repl.cc) we cannot distinguish between 0
(MASTER_LOG_POS explicitely specified as 0) and 0 (unspecified),
whereas we want to distinguish (specified 0 means "read the binlog
from 0" (4 in fact), unspecified means "don't change the position
(keep the preceding value)").
*/
Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
} }
| |
MASTER_CONNECT_RETRY_SYM EQ ULONG_NUM MASTER_CONNECT_RETRY_SYM EQ ULONG_NUM
...@@ -721,6 +733,8 @@ master_def: ...@@ -721,6 +733,8 @@ master_def:
RELAY_LOG_POS_SYM EQ ULONG_NUM RELAY_LOG_POS_SYM EQ ULONG_NUM
{ {
Lex->mi.relay_log_pos = $3; Lex->mi.relay_log_pos = $3;
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
Lex->mi.relay_log_pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
}; };
......
...@@ -130,7 +130,11 @@ bfill((A)->null_flags,(A)->null_bytes,255);\ ...@@ -130,7 +130,11 @@ bfill((A)->null_flags,(A)->null_bytes,255);\
*/ */
#define MIN_TURBOBM_PATTERN_LEN 3 #define MIN_TURBOBM_PATTERN_LEN 3
/* Defines for binary logging */ /*
Defines for binary logging.
Do not decrease the value of BIN_LOG_HEADER_SIZE.
Do not even increase it before checking code.
*/
#define BIN_LOG_HEADER_SIZE 4 #define BIN_LOG_HEADER_SIZE 4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment