summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2004-04-07 18:34:31 +0200
committerunknown <guilhem@mysql.com>2004-04-07 18:34:31 +0200
commit726917a28e7e8ef4dee3e4e7bee43674adee6f21 (patch)
tree82c9c3cc139791c6c30ca08088942353b885f052
parent1f50a0345c78ff969ddabf52322d3feeb163ec67 (diff)
downloadmariadb-git-726917a28e7e8ef4dee3e4e7bee43674adee6f21.tar.gz
Fix for BUG#3415 "mysqlbinlog loses a USE command when LOAD DATA INFILE is involved":
if you are printing LOAD DATA INFILE and its USE as comments, don't update 'last_db' (because you have not actually changed the db in the server). sql/log_event.cc: if you are printing LOAD DATA INFILE and its USE as comments, don't update 'last_db' (because you have not actually changed the db in the server).
-rw-r--r--sql/log_event.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index cd94ee2804d..9c8676192a1 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -891,15 +891,15 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db)
(ulong) thread_id, (ulong) exec_time, error_code);
}
- bool same_db = 0;
+ bool different_db= 1;
if (db && last_db)
{
- if (!(same_db = !memcmp(last_db, db, db_len + 1)))
+ if (different_db= memcmp(last_db, db, db_len + 1))
memcpy(last_db, db, db_len + 1);
}
- if (db && db[0] && !same_db)
+ if (db && db[0] && different_db)
fprintf(file, "use %s;\n", db);
end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
*end++=';';
@@ -1324,14 +1324,21 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db,
thread_id, exec_time);
}
- bool same_db = 0;
+ bool different_db= 1;
if (db && last_db)
{
- if (!(same_db = !memcmp(last_db, db, db_len + 1)))
+ /*
+ If the database is different from the one of the previous statement, we
+ need to print the "use" command, and we update the last_db.
+ But if commented, the "use" is going to be commented so we should not
+ update the last_db.
+ */
+ if ((different_db= memcmp(last_db, db, db_len + 1)) &&
+ !commented)
memcpy(last_db, db, db_len + 1);
}
- if (db && db[0] && !same_db)
+ if (db && db[0] && different_db)
fprintf(file, "%suse %s;\n",
commented ? "# " : "",
db);