Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 607b716

Browse files
committed
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
1 parent cdf5357 commit 607b716

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.40 2008/09/23 09:20:37 heikki Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.41 2008/09/24 08:59:42 mha Exp $
1010
*/
1111
#include "postgres_fe.h"
1212

@@ -107,7 +107,7 @@ main(int argc, char *argv[])
107107

108108
snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
109109

110-
if ((fd = open(ControlFilePath, O_RDONLY, 0)) == -1)
110+
if ((fd = open(ControlFilePath, O_RDONLY | PG_BINARY, 0)) == -1)
111111
{
112112
fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
113113
progname, ControlFilePath, strerror(errno));

src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.66 2008/09/23 09:20:38 heikki Exp $
26+
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.67 2008/09/24 08:59:42 mha Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -373,7 +373,7 @@ ReadControlFile(void)
373373
char *buffer;
374374
pg_crc32 crc;
375375

376-
if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY, 0)) < 0)
376+
if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY | PG_BINARY, 0)) < 0)
377377
{
378378
/*
379379
* If pg_control is not there at all, or we can't read it, the odds

0 commit comments

Comments
 (0)