| Bug #23735 | mysqlbinlog client fails when reading binlog from stdin | ||
|---|---|---|---|
| Submitted: | 27 Oct 2006 21:14 | Modified: | 3 Feb 2007 3:37 |
| Reporter: | Chuck Bell | ||
| Status: | Closed | ||
| Category: | Client | Severity: | S3 (Non-critical) |
| Version: | 5.1.13 | OS: | Microsoft Windows (Windows) |
| Assigned to: | Chuck Bell | Target Version: | |
[27 Oct 2006 21:14]
Chuck Bell
[27 Oct 2006 21:44]
Miguel Solorzano
Thank you for the bug report. c:\mysql\bin>mysqlbinlog --short-form - < c:\mysql\data\light-bin.000002 /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; ERROR: Error in Log_event::read_log_event(): 'read error', data_len: 98, event_type: 15 Could not read entry at offset 4:Error in log format or read error # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; c:\mysql\bin>mysqld-nt -V mysqld-nt Ver 5.1.13-beta-nt for Win32 on ia32 (Source distribution)
[5 Nov 2006 10:18]
Magnus Blaudd
Please attach the patch or a link to the patch to the bug report
[7 Nov 2006 19:08]
Chuck Bell
I pushed this to the mysql-5.1-new-rpl tree.
[18 Nov 2006 18:35]
Igor Babaev
Chuck, where's commit for this patch?
[20 Nov 2006 16:36]
Lars Thalmann
Pushed into 5.1.14.
This is the patch:
--- 1.134/client/mysqlbinlog.cc 2006-11-01 10:56:52 -05:00
+++ 1.135/client/mysqlbinlog.cc 2006-11-01 10:56:52 -05:00
@@ -1360,6 +1360,24 @@
}
else // reading from stdin;
{
+ /*
+ Bug fix: #23735
+ Author: Chuck Bell
+ Description:
+ Windows opens stdin in text mode by default. Certain characters
+ such as CTRL-Z are interpeted as events and the read() method
+ will stop. CTRL-Z is the EOF marker in Windows. to get past this
+ you have to open stdin in binary mode. Setmode() is used to set
+ stdin in binary mode. Errors on setting this mode result in
+ halting the function and printing an error message to stderr.
+ */
+#if defined (__WIN__) || (_WIN64)
+ if (_setmode(fileno(stdin), O_BINARY) == -1)
+ {
+ fprintf(stderr, "Could not set binary mode on stdin.\n");
+ return 1;
+ }
+#endif
if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0,
0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE)))
return 1;
[28 Nov 2006 21:45]
Paul DuBois
Noted in 5.1.14 changelog. When reading from the standard input on Windows, mysqlbinlog opened the input in text mode rather than binary mode and consequently misinterpreted some characters such as Control-Z. Resetting bug report to NDI pending decision about whether the fix should go in 5.0. (If not, just close the report.)
[11 Dec 2006 11:25]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/16760 ChangeSet@1.2348, 2006-12-11 11:25:45+01:00, msvensson@neptunus.(none) +1 -0 Bug#23735 mysqlbinlog client fails when reading binlog from stdin - Windows opens stdin in text mode by default. Certain characters such as CTRL-Z are interpeted as events and the read() method will stop. CTRL-Z is the EOF marker in Windows. to get past this you have to open stdin in binary mode. Setmode() is used to set stdin in binary mode. Errors on setting this mode result in halting the function and printing an error message to stderr.
[31 Jan 2007 20:16]
Chad MILLER
Available in 5.0.36, 5.1.15-beta.
[3 Feb 2007 3:37]
Paul DuBois
Noted in 5.0.36 changelog, and I moved the 5.1 entry from 5.1.14 to 5.1.15.
