summaryrefslogtreecommitdiff
path: root/client/mysqlbinlog.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/mysqlbinlog.cc')
-rw-r--r--client/mysqlbinlog.cc42
1 files changed, 24 insertions, 18 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 91fb5f2b99d..1ab90e0eb6d 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -155,11 +155,7 @@ class Load_log_processor
public:
Load_log_processor() {}
- ~Load_log_processor()
- {
- destroy();
- delete_dynamic(&file_names);
- }
+ ~Load_log_processor() {}
int init()
{
@@ -179,20 +175,22 @@ public:
target_dir_name_len= strlen(target_dir_name);
}
void destroy()
+ {
+ File_name_record *ptr= (File_name_record *)file_names.buffer;
+ File_name_record *end= ptr + file_names.elements;
+ for (; ptr < end; ptr++)
{
- File_name_record *ptr= (File_name_record *)file_names.buffer;
- File_name_record *end= ptr + file_names.elements;
- for (; ptr<end; ptr++)
+ if (ptr->fname)
{
- if (ptr->fname)
- {
- my_free(ptr->fname, MYF(MY_WME));
- delete ptr->event;
- bzero((char *)ptr, sizeof(File_name_record));
- }
+ my_free(ptr->fname, MYF(MY_WME));
+ delete ptr->event;
+ bzero((char *)ptr, sizeof(File_name_record));
}
}
+ delete_dynamic(&file_names);
+ }
+
/*
Obtain Create_file event for LOAD DATA statement by its file_id.
@@ -1044,7 +1042,7 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
uint logname_len;
NET* net;
int error= 0;
- my_off_t old_off= start_position_mot;
+ my_off_t old_off= min(start_position_mot, BIN_LOG_HEADER_SIZE);
char fname[FN_REFLEN+1];
DBUG_ENTER("dump_remote_log_entries");
@@ -1196,10 +1194,17 @@ could be out of memory");
}
}
/*
- Let's adjust offset for remote log as for local log to produce
- similar text.
+ Let's adjust offset for remote log as for local log to produce
+ similar text and to have --stop-position to work identically.
+
+ Exception - the server sends Format_description_log_event
+ in the beginning of the dump, and only after it the event from
+ start_position. Let the old_off reflect it.
*/
- old_off+= len-1;
+ if (old_off < start_position_mot)
+ old_off= start_position_mot;
+ else
+ old_off+= len-1;
}
err:
@@ -1517,6 +1522,7 @@ int main(int argc, char** argv)
cleanup();
free_defaults(defaults_argv);
my_free_open_file_info();
+ load_processor.destroy();
/* We cannot free DBUG, it is used in global destructors after exit(). */
my_end(MY_DONT_FREE_DBUG);
exit(exit_value);