diff options
author | unknown <guilhem@mysql.com> | 2004-03-18 19:29:07 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-03-18 19:29:07 +0200 |
commit | 83e696e61cf55da401d985cc6e14b759f7391820 (patch) | |
tree | 68c70274ca7376ba1d68fa15a8d3d4a57f8b2586 /client | |
parent | 8bdbfee96b876e48387cdc14d6b44a18d82a1043 (diff) | |
download | mariadb-git-83e696e61cf55da401d985cc6e14b759f7391820.tar.gz |
Fix for BUG#3204 ""mysqlbinlog --read-from-remote-server this_binlog.001" prints all binlogs":
we now detect that the server is sending us a log which we did not request
by testing the info in the fake Rotate event.
I also changed code to not print the fake Rotate which describes the
log we asked for (it's always the first received event but old masters
may not send it).
client/mysqlbinlog.cc:
Detect when the master is sending us a binlog which we have not requested,
then stop.
Skip the fake Rotate event if there is one (there may be none if
the server to which we connect is < 4.0.14).
mysql-test/r/mysqlbinlog.result:
result update: master-bin.000002 is not printed anymore (as mysqlbinlog
stops at the end of the requested log, master-bin.000001).
mysql-test/t/mysqlbinlog.test:
comment is wrong now
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqlbinlog.cc | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 50c6e8ca6dc..de79d017c8a 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -651,7 +651,7 @@ static int dump_remote_log_entries(const char* logname) { char buf[128]; char last_db[FN_REFLEN+1] = ""; - uint len; + uint len, logname_len; NET* net = &mysql->net; int old_format; DBUG_ENTER("dump_remote_log_entries"); @@ -668,10 +668,10 @@ static int dump_remote_log_entries(const char* logname) } int4store(buf, position); int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags); - len = (uint) strlen(logname); + logname_len = (uint) strlen(logname); int4store(buf + 6, 0); - memcpy(buf + 10, logname,len); - if (simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1)) + memcpy(buf + 10, logname, logname_len); + if (simple_command(mysql, COM_BINLOG_DUMP, buf, logname_len + 10, 1)) { fprintf(stderr,"Got fatal error sending the log dump command\n"); DBUG_RETURN(1); @@ -706,6 +706,37 @@ static int dump_remote_log_entries(const char* logname) Log_event_type type= ev->get_type_code(); if (!old_format || ( type != LOAD_EVENT && type != CREATE_FILE_EVENT)) { + /* + If this is a Rotate event, maybe it's the end of the requested binlog; + in this case we are done (stop transfer). + This is suitable for binlogs, not relay logs (but for now we don't read + relay logs remotely because the server is not able to do that). If one + day we read relay logs remotely, then we will have a problem with the + detection below: relay logs contain Rotate events which are about the + binlogs, so which would trigger the end-detection below. + */ + if (ev->get_type_code() == ROTATE_EVENT) + { + Rotate_log_event *rev= (Rotate_log_event *)ev; + /* + If this is a fake Rotate event, and not about our log, we can stop + transfer. If this a real Rotate event (so it's not about our log, + it's in our log describing the next log), we print it (because it's + part of our log) and then we will stop when we receive the fake one + soon. + */ + if (rev->when == 0) + { + if ((rev->ident_len != logname_len) || + memcmp(rev->new_log_ident, logname, logname_len)) + DBUG_RETURN(0); + /* + Otherwise, this is a fake Rotate for our log, at the very beginning + for sure. Skip it. + */ + continue; + } + } if (process_event(&rec_count,last_db,ev,old_off,old_format)) DBUG_RETURN(1); } |