Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gO3FO-0000pU-St for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Nov 2018 16:15:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gO3FN-0002X9-9G for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Nov 2018 16:15:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gO3FM-0002VM-VF for pgsql-hackers@lists.postgresql.org; Sat, 17 Nov 2018 16:15:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gO3FK-0002nW-AD for pgsql-hackers@lists.postgresql.org; Sat, 17 Nov 2018 16:14:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wAHGEnGJ023490; Sat, 17 Nov 2018 11:14:50 -0500 From: Tom Lane To: Etsuro Fujita cc: Kyotaro HORIGUCHI , thomas.munro@enterprisedb.com, eric.cyr@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: BUG #15449: file_fdw using program cause exit code error when using LIMIT In-reply-to: <9660.1542409841@sss.pgh.pa.us> References: <5BE4318F.4040002@lab.ntt.co.jp> <20181109.143931.243136889.horiguchi.kyotaro@lab.ntt.co.jp> <5BE552ED.4040304@lab.ntt.co.jp> <20181112.185214.76711162.horiguchi.kyotaro@lab.ntt.co.jp> <5BE966F4.1040702@lab.ntt.co.jp> <5BEA9E82.1080709@lab.ntt.co.jp> <30744.1542388851@sss.pgh.pa.us> <31355.1542389631@sss.pgh.pa.us> <7865.1542407597@sss.pgh.pa.us> <9660.1542409841@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 16 Nov 2018 18:10:41 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23488.1542471289.1@sss.pgh.pa.us> Date: Sat, 17 Nov 2018 11:14:49 -0500 Message-ID: <23489.1542471289@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > After still further thought, it seems like "if (bytesread == 0)" > is the right way to proceed. That protects us against incorrectly > setting reached_eof if the pipe is being run in unbuffered or > line-buffered mode. (Which copy.c doesn't do, at the moment, > but I'd just as soon this code didn't need to assume that. > Also, I'm not 100% convinced that Windows or other platforms > might not act that way.) In the case where we terminate early > because we saw an in-band EOF marker, we would also not set reached_eof, > and again that seems like a good outcome: if we see SIGPIPE it > must mean that the program kept sending data after the EOF marker, > and that seems like a good thing to complain about. (It's only > guaranteed to fail if the program sends more than the current pipe > buffer-ful, but I don't feel a need to add extra code to check for > nonempty buffer contents as we exit.) Oh, wait, that last bit is backwards: if we see an in-band EOF mark, and as a consequence exit without having set reached_eof, then the exit code will think that SIGPIPE is ignorable. So transmitting more data after an EOF mark will not be complained of, whether it's within the same bufferload or not. Still, I can't get very excited about that. Potentially we could improve it by having the places that recognize EOF marks set reached_eof, but I'm unconvinced that it's worth the trouble. I'm thinking that it's better to err in the direction of reporting SIGPIPE less often not more often, considering that up to now we've never reported it at all and there've been so few complaints. regards, tom lane