Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g2IUv-0003x0-9W for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Sep 2018 16:05:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g2IUt-0002P2-1P for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Sep 2018 16:05:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g2IUs-0002Ov-Qv for pgsql-hackers@lists.postgresql.org; Tue, 18 Sep 2018 16:05:06 +0000 Received: from mx2a.mailbox.org ([2001:67c:2050:104:0:2:25:2] helo=mx2.mailbox.org) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g2IUq-0003LI-6X for pgsql-hackers@lists.postgresql.org; Tue, 18 Sep 2018 16:05:06 +0000 Received: from smtp2.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 77B0E4159B; Tue, 18 Sep 2018 18:05:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id 10BK472Wttoa; Tue, 18 Sep 2018 18:04:59 +0200 (CEST) Message-ID: Subject: Re: pgsql: Allow concurrent-safe open() and fopen() in frontend code for Wi From: Laurenz Albe To: Tom Lane Cc: Michael Paquier , pgsql-hackers@lists.postgresql.org Date: Tue, 18 Sep 2018 18:04:58 +0200 In-Reply-To: <25361.1537285137@sss.pgh.pa.us> References: <23543.1536938575@sss.pgh.pa.us> <20180914224939.GA1178@paquier.xyz> <20180917114113.GA31460@paquier.xyz> <17194.1537191697@sss.pgh.pa.us> <20180917140202.GF31460@paquier.xyz> <19655.1537195712@sss.pgh.pa.us> <3883.1537200836@sss.pgh.pa.us> <11148.1537227504@sss.pgh.pa.us> <20180918001143.GG31460@paquier.xyz> <20180918024227.GI31460@paquier.xyz> <23296.1537281909@sss.pgh.pa.us> <71bf47219037a5e3839748eb55e4fa175b58f523.camel@cybertec.at> <25361.1537285137@sss.pgh.pa.us> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane wrote: > Laurenz Albe 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