Skip to content

Commit 8fa8f80

Browse files
committed
I've recently written to pgsql-ports about a problem with PG7.0 on NT
(Subj: [PORTS] initdb problem on NT with 7.0). Since nobody helped me, I had to find out the reson. The difference between NT and Linux (for instance) is that "open( path, O_RDWR );" opens a file in text mode. So sometime less block can be read than required. I suggest a following patch. BTW the situation appeared before, see hba.c, pqcomm.c and others. Alexei Zakharov
1 parent 9606f36 commit 8fa8f80

File tree

1 file changed

+21
-1
lines changed
  • src/backend/access/transam

1 file changed

+21
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.10 2000/02/15 03:00:37 thomas Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.11 2000/03/07 23:49:31 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -726,7 +726,11 @@ XLogFileInit(uint32 log, uint32 seg)
726726
unlink(path);
727727

728728
tryAgain:
729+
#ifndef __CYGWIN__
729730
fd = open(path, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
731+
#else
732+
fd = open(path, O_RDWR|O_CREAT|O_EXCL|O_BINARY, S_IRUSR|S_IWUSR);
733+
#endif
730734
if (fd < 0 && (errno == EMFILE || errno == ENFILE))
731735
{
732736
fd = errno;
@@ -767,7 +771,11 @@ XLogFileOpen(uint32 log, uint32 seg, bool econt)
767771
XLogFileName(path, log, seg);
768772

769773
tryAgain:
774+
#ifndef __CYGWIN__
770775
fd = open(path, O_RDWR);
776+
#else
777+
fd = open(path, O_RDWR | O_BINARY);
778+
#endif
771779
if (fd < 0 && (errno == EMFILE || errno == ENFILE))
772780
{
773781
fd = errno;
@@ -1083,7 +1091,11 @@ UpdateControlFile()
10831091
int fd;
10841092

10851093
tryAgain:
1094+
#ifndef __CYGWIN__
10861095
fd = open(ControlFilePath, O_RDWR);
1096+
#else
1097+
fd = open(ControlFilePath, O_RDWR | O_BINARY);
1098+
#endif
10871099
if (fd < 0 && (errno == EMFILE || errno == ENFILE))
10881100
{
10891101
fd = errno;
@@ -1145,7 +1157,11 @@ BootStrapXLOG()
11451157
CheckPoint checkPoint;
11461158
XLogRecord *record;
11471159

1160+
#ifndef __CYGWIN__
11481161
fd = open(ControlFilePath, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
1162+
#else
1163+
fd = open(ControlFilePath, O_RDWR|O_CREAT|O_EXCL|O_BINARY, S_IRUSR|S_IWUSR);
1164+
#endif
11491165
if (fd < 0)
11501166
elog(STOP, "BootStrapXLOG failed to create control file (%s): %d",
11511167
ControlFilePath, errno);
@@ -1249,7 +1265,11 @@ StartupXLOG()
12491265
* Open/read Control file
12501266
*/
12511267
tryAgain:
1268+
#ifndef __CYGWIN__
12521269
fd = open(ControlFilePath, O_RDWR);
1270+
#else
1271+
fd = open(ControlFilePath, O_RDWR | O_BINARY);
1272+
#endif
12531273
if (fd < 0 && (errno == EMFILE || errno == ENFILE))
12541274
{
12551275
fd = errno;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy