Below is the list of changes that have just been committed into a local
5.1 repository of guilhem. When guilhem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-02-09 16:16:01+01:00, guilhem@stripped +5 -0
Fix for BUG#26194 "mysqlbinlog --base64-output produces invalid SQL";
when it was printing a Query event, it produced invalid SQL (missing
the BINLOG keyword, so the SQL started with the base64 string, which
is incorrect).
Note: the .test will NOT be pushed; indeed, it triggers BUG#20929
("BINLOG command causes invalid free") and so gives Valgrind warnings
or crashes mysqld. Instead, I'll ship this test to the fixer of
BUG#20929 for her/him to push when she/he fixes BUG#20929.
client/mysqlbinlog.cc@stripped, 2007-02-09 16:15:58+01:00, guilhem@stripped +7 -9
writing the header (a line started with "#", i.e. a comment) and the
body (the real operation) of an event to the same IO_CACHE
(result_cache) confused the logic of Log_event::print_base64()
(which is that if the cache is not empty then the BINLOG keyword
should not be printed); it caused the BINLOG keyword to miss hence
a syntactically wrong output of "mysqlbinlog --base64-output"
for Query events.
So we just use the two IO_CACHE already available in "print_event_info".
mysql-test/r/mysqlbinlog_base64.result@stripped, 2007-02-09 16:15:58+01:00,
guilhem@stripped +9 -0
result upate. The fact that the test does not give an error like:
mysqlbinlog_base64 [ fail ]
Errors are (from
/home/mysql_src/mysql-5.1-rpl-26194/mysql-test/var/log/mysqltest-time) :
ERROR 1064 (42000) at line 8: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use near
'AG15c3FsdGVzdA<cut>
shows that the bug is fixed.
mysql-test/t/mysqlbinlog_base64.test@stripped, 2007-02-09 16:15:58+01:00,
guilhem@stripped +20 -2
testing (BUG#26194) if "mysqlbinlog --base64-output" on a Query event
produces output parsable by mysqld. Testing that it also works when
one adds --hexdump.
sql/log_event.cc@stripped, 2007-02-09 16:15:58+01:00, guilhem@stripped +3 -6
using the new small inline function.
Note that the replication code should one day be fixed to trap all
errors (like disk write errors).
sql/log_event.h@stripped, 2007-02-09 16:15:58+01:00, guilhem@stripped +8 -0
small inline function to group two operations: copying an IO_CACHE
to a FILE, and reinitializing this IO_CACHE for being filled again.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: guilhem
# Host: gbichot3.local
# Root: /home/mysql_src/mysql-5.1-rpl-26194
--- 1.260/sql/log_event.cc 2007-02-09 16:16:12 +01:00
+++ 1.261/sql/log_event.cc 2007-02-09 16:16:12 +01:00
@@ -76,8 +76,7 @@ public:
~Write_on_release_cache()
{
- if (!my_b_copy_to_file(m_cache, m_file))
- reinit_io_cache(m_cache, WRITE_CACHE, 0L, FALSE, TRUE);
+ copy_event_cache_to_file_and_reinit(m_cache, m_file);
if (m_flags | FLUSH_F)
fflush(m_file);
}
@@ -6043,10 +6042,8 @@ void Rows_log_event::print_helper(FILE *
if (get_flags(STMT_END_F))
{
- my_b_copy_to_file(head, file);
- my_b_copy_to_file(body, file);
- reinit_io_cache(head, WRITE_CACHE, 0, FALSE, TRUE);
- reinit_io_cache(body, WRITE_CACHE, 0, FALSE, TRUE);
+ copy_event_cache_to_file_and_reinit(head, file);
+ copy_event_cache_to_file_and_reinit(body, file);
}
}
#endif
--- 1.143/sql/log_event.h 2007-02-09 16:16:12 +01:00
+++ 1.144/sql/log_event.h 2007-02-09 16:16:12 +01:00
@@ -2204,4 +2204,12 @@ private:
#endif
};
+static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
+ FILE *file)
+{
+ return
+ my_b_copy_to_file(cache, file) ||
+ reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE);
+}
+
#endif /* _log_event_h */
--- 1.142/client/mysqlbinlog.cc 2007-02-09 16:16:12 +01:00
+++ 1.143/client/mysqlbinlog.cc 2007-02-09 16:16:12 +01:00
@@ -485,19 +485,17 @@ static int
write_event_header_and_base64(Log_event *ev, FILE *result_file,
PRINT_EVENT_INFO *print_event_info)
{
+ IO_CACHE *head= &print_event_info->head_cache;
+ IO_CACHE *body= &print_event_info->body_cache;
DBUG_ENTER("write_event_header_and_base64");
- /* Write header and base64 output to cache */
- IO_CACHE result_cache;
- if (open_cached_file(&result_cache, NULL, NULL, 0, MYF(MY_WME | MY_NABP)))
- return 1;
- ev->print_header(&result_cache, print_event_info, FALSE);
- ev->print_base64(&result_cache, print_event_info, FALSE);
+ /* Write header and base64 output to cache */
+ ev->print_header(head, print_event_info, FALSE);
+ ev->print_base64(body, print_event_info, FALSE);
/* Read data from cache and write to result file */
- my_b_copy_to_file(&result_cache, result_file);
- close_cached_file(&result_cache);
- DBUG_RETURN(0);
+ DBUG_RETURN(copy_event_cache_to_file_and_reinit(head, result_file) ||
+ copy_event_cache_to_file_and_reinit(body, result_file));
}
--- 1.4/mysql-test/r/mysqlbinlog_base64.result 2007-02-09 16:16:12 +01:00
+++ 1.5/mysql-test/r/mysqlbinlog_base64.result 2007-02-09 16:16:12 +01:00
@@ -108,3 +108,12 @@ count(*)
35840
drop table t1;
drop table t2;
+drop database if exists mysqltest;
+flush logs;
+CREATE DATABASE mysqltest;
+USE mysqltest;
+CREATE TABLE t (a DATETIME);
+INSERT INTO t VALUES(NOW());
+DROP DATABASE mysqltest;
+flush logs;
+flush logs;
--- 1.4/mysql-test/t/mysqlbinlog_base64.test 2007-02-09 16:16:12 +01:00
+++ 1.5/mysql-test/t/mysqlbinlog_base64.test 2007-02-09 16:16:12 +01:00
@@ -58,10 +58,28 @@ flush logs;
# Verify that all binlog events have been executed
#
select count(*) from t2;
+drop table t1;
+drop table t2;
+
+# BUG#26194
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+flush logs;
+CREATE DATABASE mysqltest;
+USE mysqltest;
+CREATE TABLE t (a DATETIME);
+INSERT INTO t VALUES(NOW());
+DROP DATABASE mysqltest;
+flush logs;
+--exec $MYSQL_BINLOG --base64-output $MYSQLTEST_VARDIR/log/master-bin.000005 >
$MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
+# once again with --hexdump, to see if it all mixes well
+flush logs;
+--exec $MYSQL_BINLOG --hexdump --base64-output $MYSQLTEST_VARDIR/log/master-bin.000005
> $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
#
# Test cleanup
#
--exec rm $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
-drop table t1;
-drop table t2;
| Thread |
|---|
| • bk commit into 5.1 tree (guilhem:1.2373) BUG#26194 | Guilhem Bichot | 9 Feb |