summaryrefslogtreecommitdiff
path: root/client/mysqlbinlog.cc
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2006-12-11 11:25:45 +0100
committerunknown <msvensson@neptunus.(none)>2006-12-11 11:25:45 +0100
commit29ff97f8cce5b5857070982f9ee9ef46c8577488 (patch)
tree0d729a6f1c385a9a9166f4962108a52429042d68 /client/mysqlbinlog.cc
parent8ba0259a5f5a38eb8f4ca31c9e3edd2ad90fc753 (diff)
downloadmariadb-git-29ff97f8cce5b5857070982f9ee9ef46c8577488.tar.gz
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. client/mysqlbinlog.cc: Apply fix to 5.0 as well
Diffstat (limited to 'client/mysqlbinlog.cc')
-rw-r--r--client/mysqlbinlog.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index ff4e0b5a5cf..102c665031d 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -1310,6 +1310,25 @@ static int dump_local_log_entries(const char* logname)
}
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;