Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXqMT-0003AL-7g for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Oct 2020 18:39:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXqMR-0008JG-MS for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Oct 2020 18:39:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXqMR-0008J9-GR for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2020 18:39:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXqMN-0004JT-Cl for pgsql-bugs@lists.postgresql.org; Wed, 28 Oct 2020 18:39:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09SIdd1g1441559; Wed, 28 Oct 2020 14:39:39 -0400 From: Tom Lane To: Bruce Momjian cc: kensuke.okamura@kantei.co.jp, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16688: psql removes only LF without CR at end of backquotes on windows. In-reply-to: <20201028032942.GA21830@momjian.us> References: <16688-c649c7b69cd7e6f8@postgresql.org> <1224124.1603855625@sss.pgh.pa.us> <20201028032942.GA21830@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Tue, 27 Oct 2020 23:29:42 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1441557.1603910379.1@sss.pgh.pa.us> Date: Wed, 28 Oct 2020 14:39:39 -0400 Message-ID: <1441558.1603910379@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Bruce Momjian writes: > On Tue, Oct 27, 2020 at 11:27:05PM -0400, Tom Lane wrote: >> But rather than mess with that newline-chomping code, I'm >> inclined to wonder why we're using PG_BINARY_R for input >> that we clearly expect to be textual. Most of our other >> popen's do not do that. >> >> Bruce, this seems to date to 98e9775a3 ... don't suppose >> you remember that? I see the point about control-Z in text >> files, but I wonder how plausible that is for popen cases. > It seems safe for popen to use TEXT mode, and it might help with > encoding conversion. I don't think I made a popen distinction when I > was working in this area. I double-checked, and verified that our only other popen() calls that use binary mode are dealing with COPY data. It seems appropriate to do so in that case, partly because the data might indeed be binary and partly because we have adequate newline recognition logic in copy.c. But it does seem best to uniformly use plain "r" or "w" for other popen's. So I've fixed this that way. regards, tom lane