]> granicus.if.org Git - postgresql/commitdiff
Make sure pg_control is opened in binary mode, to deal
authorMagnus Hagander <magnus@hagander.net>
Wed, 24 Sep 2008 08:59:46 +0000 (08:59 +0000)
committerMagnus Hagander <magnus@hagander.net>
Wed, 24 Sep 2008 08:59:46 +0000 (08:59 +0000)
with situtations when the file contains an EOF maker
(0x1A) on Windows.

ITAGAKI Takahiro

src/bin/pg_controldata/pg_controldata.c
src/bin/pg_resetxlog/pg_resetxlog.c

index 682a5cf380779646a197f9c6e3396e5624145630..9e9454ff26239d17df12b392f12c7680c4438a47 100644 (file)
@@ -6,7 +6,7 @@
  * copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
  * licence: BSD
  *
- * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.36 2008/01/21 11:17:46 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.36.2.1 2008/09/24 08:59:46 mha Exp $
  */
 #include "postgres.h"
 
@@ -106,7 +106,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));
index 83b6b4b1d7a9f8a2c98fd9f310c2d2c41374d10c..870b7a662253c12087c9c7eb0b41c92c1072f8c3 100644 (file)
@@ -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.63 2008/01/01 19:45:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.63.2.1 2008/09/24 08:59:46 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