Skip to content

Commit

Permalink
Port fix for stdin support in mysqlbinlog from MariaDB to Google MySQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
enisoc committed Aug 1, 2014
1 parent 4a40a69 commit 5600a7a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions third_party/mysql.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index f85219a..72081df 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -36,6 +36,7 @@
#include "mysql_priv.h"
#include "log_event.h"
#include "sql_common.h"
+#include "my_dir.h"
#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE

#define BIN_LOG_HEADER_SIZE 4
@@ -1790,6 +1791,7 @@ static Exit_status check_header(IO_CACHE* file,
uchar header[BIN_LOG_HEADER_SIZE];
uchar buf[PROBE_HEADER_LEN];
my_off_t tmp_pos, pos;
+ MY_STAT my_file_stat;

delete glob_description_event;
if (!(glob_description_event= new Format_description_log_event(3)))
@@ -1799,7 +1801,16 @@ static Exit_status check_header(IO_CACHE* file,
}

pos= my_b_tell(file);
- my_b_seek(file, (my_off_t)0);
+
+ /* fstat the file to check if the file is a regular file. */
+ if (my_fstat(file->file, &my_file_stat, MYF(0)) == -1)
+ {
+ error("Unable to stat the file.");
+ return ERROR_STOP;
+ }
+ if ((my_file_stat.st_mode & S_IFMT) == S_IFREG)
+ my_b_seek(file, (my_off_t)0);
+
if (my_b_read(file, header, sizeof(header)))
{
error("Failed reading header; probably an empty file.");
diff --git a/google/compile.inc b/google/compile.inc
index efdac62..edc9170 100644
--- a/google/compile.inc
Expand Down

0 comments on commit 5600a7a

Please sign in to comment.