summaryrefslogtreecommitdiff
path: root/client/mysqlbinlog.cc
diff options
context:
space:
mode:
authorRohit Kalhans <rohit.kalhans@oracle.com>2012-08-08 22:20:05 +0530
committerRohit Kalhans <rohit.kalhans@oracle.com>2012-08-08 22:20:05 +0530
commit17c5725cd263149bd6bc5cd8dc8187f63a81e031 (patch)
treeef3c0cdc4c661c954289407ed8ae86628d8bb1d7 /client/mysqlbinlog.cc
parentffdc4bc8cdac169a406a0d0fbad7b3733a173a32 (diff)
parentff04c5bd6e753a7afd8f209918e900267ba2544f (diff)
downloadmariadb-git-17c5725cd263149bd6bc5cd8dc8187f63a81e031.tar.gz
upmerge from mysql-5.1=>mysql-5.5
Diffstat (limited to 'client/mysqlbinlog.cc')
-rw-r--r--client/mysqlbinlog.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 70a89fade53..a58aa65207d 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -36,6 +36,7 @@
#include "sql_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
@@ -1775,6 +1776,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)))
@@ -1784,7 +1786,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.");