From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp> |
Cc: | Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, thomas(dot)munro(at)enterprisedb(dot)com, eric(dot)cyr(at)gmail(dot)com, 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-16 23:10:41 |
Message-ID: | 9660.1542409841@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
I wrote:
> I'm not quite sure whether the reached_eof test should be
> "if (bytesread == 0)" or "if (bytesread < maxread)". The former
> seems more certain to indicate real EOF; are there other cases where
> the fread might return a short read? On the other hand, if we
> support in-band EOF indicators (\. for instance) then we might
> stop without having made an extra call to CopyGetData that would
> see bytesread == 0. On the third hand, if we do do that it's
> not quite clear to me whether SIGPIPE is ignorable or not.
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.)
So I think this version is probably good, although maybe it could
use an additional comment explaining the above reasoning.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2018-11-17 05:56:52 | BUG #15510: Anytime I boot my iMac Safari gets started and shows PgAdmin 4 page |
Previous Message | Tom Lane | 2018-11-16 22:33:17 | Re: BUG #15449: file_fdw using program cause exit code error when using LIMIT |
From | Date | Subject | |
---|---|---|---|
Next Message | Haribabu Kommi | 2018-11-16 23:17:00 | Re: New function pg_stat_statements_reset_query() to reset statistics of a specific query |
Previous Message | Andrew Gierth | 2018-11-16 23:04:38 | Re: Early WIP/PoC for inlining CTEs |