Re: [HACKERS] COPY FROM STDIN behaviour on end-of-file
От | Tom Lane |
---|---|
Тема | Re: [HACKERS] COPY FROM STDIN behaviour on end-of-file |
Дата | |
Msg-id | 27246.1495038695@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: [HACKERS] COPY FROM STDIN behaviour on end-of-file (Thomas Munro <thomas.munro@enterprisedb.com>) |
Список | pgsql-hackers |
Thomas Munro <thomas.munro@enterprisedb.com> writes: > On Wed, May 17, 2017 at 2:39 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Thanks for checking. So that's two major platforms where it works "as >> expected" already. > Ah... the reason this is happening is that BSD-derived fread() > implementations return immediately if the EOF flag is set[1], but > others do not. Hah, good detective work. I tried this on the lone SysV-derived box I have (ancient HPUX), and did not see the problem, so that seems to confirm the comment you found that says this is a SysV-tradition vs BSD-tradition thing. >> If we're going >> to go out of our way to make it work, should we mention it in psql-ref? > I went looking for the place to put that and found that it already says: > For <literal>\copy ... from stdin</>, data rows are read from the same > source that issued the command, continuing until <literal>\.</literal> > is read or the stream reaches <acronym>EOF</>. Yeah, it seems like that's clear enough already; I don't feel a need to complicate it. Another thing that would be nice is a regression test, but I don't see any way to do that in our standard test environments. I could imagine building a test rig that fires up psql through a PTY, but making it portable is a daunting prospect, and probably not worth the trouble. > Here's a version incorporating your other suggestions and a comment to explain. I editorialized on the comment a bit and pushed it. Thanks for the report and patch! regards, tom lane
В списке pgsql-hackers по дате отправления: