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 08e102f391814dbf2d7cae719ab68f0e9e73c5a5..bdbedfd99e6c0fcb6b1a0518e2b2dc58a9fa96d4 100644 (file)
@@ -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));
index 0df796b680ec0cf69803ea422fe1dfdfa3fcdfb2..22e9e7213f9f4ff19222cc193a481ed80bddd2cf 100644 (file)
@@ -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