Re: pgsql: Allow concurrent-safe open() and fopen() in frontendcode for Wi - Mailing list pgsql-hackers

From Laurenz Albe
Subject Re: pgsql: Allow concurrent-safe open() and fopen() in frontendcode for Wi
Date
Msg-id c68010480459c79f24a015096ae43b6f0bcd9854.camel@cybertec.at
Whole thread Raw
In response to Re: pgsql: Allow concurrent-safe open() and fopen() in frontend code for Wi  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgsql: Allow concurrent-safe open() and fopen() in frontend codefor Wi  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
Tom Lane wrote:
> Laurenz Albe <laurenz.albe@cybertec.at> writes:
> > Would it be an option to have pgwin32_open default to text mode in
> > frontend code and to binary mode in backend code?
> 
> Well, the question is why Michael's latest proposed patch doesn't
> accomplish that.

I was thinking of something trivial like this:

--- a/src/port/open.c
+++ b/src/port/open.c
@@ -71,6 +71,12 @@ pgwin32_open(const char *fileName, int fileFlags,...)
                         _O_SHORT_LIVED | O_DSYNC | O_DIRECT |
                         (O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags);
 
+#ifdef FRONTEND
+   /* default to text mode in frontend code */
+   if (fileFlags & O_BINARY == 0)
+       fileFlags |= O_TEXT;
+#endif
+
    sa.nLength = sizeof(sa);
    sa.bInheritHandle = TRUE;
    sa.lpSecurityDescriptor = NULL;

That wouldn't influence pipes, which was what Michael said was a
problem for pg_dump.

I currently have no Windows system close, so I cannot test...

Yours,
Laurenz Albe



pgsql-hackers by date:

Previous
From: Michael Banck
Date:
Subject: Re: Progress reporting for pg_verify_checksums
Next
From: Ashutosh Bapat
Date:
Subject: Re: Is it really difficult for postgres_fdw to implement READCOMMITTED isolation?