Re: BUG #15449: file_fdw using program cause exit code error when using LIMIT

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: thomas(dot)munro(at)enterprisedb(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, eric(dot)cyr(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15449: file_fdw using program cause exit code error when using LIMIT
Date: 2018-11-13 09:50:58
Message-ID: 5BEA9E82.1080709@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

(2018/11/12 20:41), Etsuro Fujita wrote:
> (2018/11/12 18:52), Kyotaro HORIGUCHI wrote:
>> I read the Thomas's messages as "TTIO/TTOU are not
>> needed to our busines and we don't have a reason to restore them
>> before calling external programs other than just plaster
>> seemingly consistency." And I agree to the analysis and I agree
>> to you on the point that it doens't need consideration just now.
>
> OK

Attached is an updated version of Tom's POC patch. Here are changes:

* I modified his patch so that the called program inherits SIG_DFL for
SIGUSR2 as well, as discussed upthread.

* I think it's better to ignore the SIGPIPE failure in
ClosePipeToProgram if we were in a COPY FROM PROGRAM that was allowed to
terminate early and keep the behavior as-is otherwise. If we ignore
that failure unconditionally in that function, eg, COPY TO PROGRAM would
fail to get a (better) error message in CopySendEndOfRow or EndCopy when
the invoked program was terminated on SIGPIPE, as discussed before [1].
And to do so, I added a new argument to BeginCopyFrom to specify
whether COPY FROM PROGRAM can terminate early or not.

Best regards,
Etsuro Fujita

[1] https://www.postgresql.org/message-id/5BE18409.2070004%40lab.ntt.co.jp

Attachment Content-Type Size
process-sigpipe-normally-in-copy-from-program-1-efujita-20181113.patch text/x-patch 7.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2018-11-13 09:57:39 Re: Fail to create PK or index for large table in Windows
Previous Message Thomas Munro 2018-11-13 09:49:26 Re: BUG #15460: Error while creating index or constraint

Browse pgsql-hackers by date

  From Date Subject
Next Message Ideriha, Takeshi 2018-11-13 09:59:36 RE: Copy data to DSA area
Previous Message Amit Kapila 2018-11-13 09:36:44 Re: doc fix for pg_stat_activity.backend_type