From 607b7166d8c99ed42f26110f7ac2eee11d7b1fbf Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 24 Sep 2008 08:59:42 +0000 Subject: [PATCH] Make sure pg_control is opened in binary mode, to deal with situtations when the file contains an EOF maker (0x1A) on Windows. ITAGAKI Takahiro --- src/bin/pg_controldata/pg_controldata.c | 4 ++-- src/bin/pg_resetxlog/pg_resetxlog.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index 50a4754cd5..96827c3aac 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -6,7 +6,7 @@ * copyright (c) Oliver Elphick , 2001; * licence: BSD * - * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.40 2008/09/23 09:20:37 heikki Exp $ + * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.41 2008/09/24 08:59:42 mha Exp $ */ #include "postgres_fe.h" @@ -107,7 +107,7 @@ main(int argc, char *argv[]) snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir); - if ((fd = open(ControlFilePath, O_RDONLY, 0)) == -1) + if ((fd = open(ControlFilePath, O_RDONLY | PG_BINARY, 0)) == -1) { fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), progname, ControlFilePath, strerror(errno)); diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index c3cfafea7a..c2db7bd966 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.66 2008/09/23 09:20:38 heikki Exp $ + * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.67 2008/09/24 08:59:42 mha Exp $ * *------------------------------------------------------------------------- */ @@ -373,7 +373,7 @@ ReadControlFile(void) char *buffer; pg_crc32 crc; - if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY, 0)) < 0) + if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY | PG_BINARY, 0)) < 0) { /* * If pg_control is not there at all, or we can't read it, the odds