summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2003-08-19 15:12:44 +0200
committerunknown <guilhem@mysql.com>2003-08-19 15:12:44 +0200
commitc7578701e3e3a67fe137ef5788f6d8b98a2d6655 (patch)
treef818729d6b3c18989e67bc2caef91c6e3dc46840
parentd8df84aa438a2dfe4a90d7889713c2ccd52cca1d (diff)
downloadmariadb-git-c7578701e3e3a67fe137ef5788f6d8b98a2d6655.tar.gz
Fixes for BUG#1091,1092,1093. Synopsis of these bugs:
mysqlbinlog segfaults if --position is just before Exec_load event mysqlbinlog prints uncommented warnings if --database and compiled with debug mysqlbinlog --database does not filter LOAD DATA INFILE client/mysqlbinlog.cc: * Don't stop in Append_block when there is no Create_file. Just print a warning. * Test LOAD DATA (Create_file) against --database. * Don't print "no skip" when you don't skip an event when using --database (it causes syntax errors in 'mysql'). * Print a warning in Exec_load if there is no Create_file.
-rw-r--r--client/mysqlbinlog.cc80
1 files changed, 49 insertions, 31 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index ac1c9db30e6..954e9290a76 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -183,7 +183,16 @@ public:
void process(Append_block_log_event *ae)
{
if (ae->file_id >= file_names.elements)
- die("Skiped CreateFile event for file_id: %u",ae->file_id);
+ {
+ /*
+ There is no Create_file event (a bad binlog or a big
+ --position). Assuming it's a big --position, we just do nothing and
+ print a warning.
+ */
+ fprintf(stderr,"Warning: ignoring Append_block as there is no \
+Create_file event for file_id: %u\n",ae->file_id);
+ return;
+ }
Create_file_log_event* ce=
*((Create_file_log_event**)file_names.buffer + ae->file_id);
append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY,ae->block,ae->block_len);
@@ -568,44 +577,42 @@ Could not read entry at offset %s : Error in log format or read error",
}
if (rec_count >= offset)
{
- // see if we should skip this event (only care about queries for now)
- if (one_database)
- {
- if (ev->get_type_code() == QUERY_EVENT)
+ if (!short_form)
+ fprintf(result_file, "# at %s\n",llstr(old_off,llbuff));
+
+ switch (ev->get_type_code()) {
+ case QUERY_EVENT:
+ if (one_database)
{
- //const char * log_dbname = ev->get_db();
const char * log_dbname = ((Query_log_event*)ev)->db;
- //printf("entry: %llu, database: %s\n", rec_count, log_dbname);
-
if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
{
- //printf("skipping, %s is not %s\n", log_dbname, database);
rec_count++;
delete ev;
continue; // next
}
-#ifndef DBUG_OFF
- else
- {
- printf("no skip\n");
- }
-#endif
}
-#ifndef DBUG_OFF
- else
- {
- const char * query_type = ev->get_type_str();
- printf("not query -- %s\n", query_type);
- }
-#endif
- }
- if (!short_form)
- fprintf(result_file, "# at %s\n",llstr(old_off,llbuff));
-
- switch (ev->get_type_code()) {
+ ev->print(result_file, short_form, last_db);
+ break;
case CREATE_FILE_EVENT:
{
Create_file_log_event* ce= (Create_file_log_event*)ev;
+ if (one_database)
+ {
+ /*
+ We test if this event has to be ignored. If yes, we don't save this
+ event; this will have the good side-effect of ignoring all related
+ Append_block and Exec_load.
+ Note that Load event from 3.23 is not tested.
+ */
+ const char * log_dbname = ce->db;
+ if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
+ {
+ rec_count++;
+ delete ev;
+ continue; // next
+ }
+ }
ce->print(result_file, short_form, last_db,true);
load_processor.process(ce);
ev= 0;
@@ -620,9 +627,20 @@ Could not read entry at offset %s : Error in log format or read error",
ev->print(result_file, short_form, last_db);
Execute_load_log_event *exv= (Execute_load_log_event*)ev;
Create_file_log_event *ce= load_processor.grab_event(exv->file_id);
- ce->print(result_file, short_form, last_db,true);
- my_free((char*)ce->fname,MYF(MY_WME));
- delete ce;
+ /*
+ if ce is 0, it probably means that we have not seen the Create_file
+ event (a bad binlog, or most probably --position is after the
+ Create_file event). Print a warning comment.
+ */
+ if (ce)
+ {
+ ce->print(result_file, short_form, last_db,true);
+ my_free((char*)ce->fname,MYF(MY_WME));
+ delete ce;
+ }
+ else
+ fprintf(stderr,"Warning: ignoring Exec_load as there is no \
+Create_file event for file_id: %u\n",exv->file_id);
break;
}
default:
@@ -634,7 +652,7 @@ Could not read entry at offset %s : Error in log format or read error",
delete ev;
}
if (fd >= 0)
- my_close(fd, MYF(MY_WME));
+ my_close(fd, MYF(MY_WME));
end_io_cache(file);
}