Re: BUG #17288: PSQL bug with COPY command (Windows)
Dmitry Koval <d.koval@postgrespro.ru>
From: Dmitry Koval <d.koval@postgrespro.ru>
To: Michael Paquier <michael@paquier.xyz>
Cc: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2021-11-19T08:47:02Z
Lists: pgsql-bugs
Attachments
- test.c (text/plain)
>I still think that we should not call GetFileInformationByHandle() >when it comes to an argument that we know will fail, ... Our program calls function freopen() (this function is used in file src\backend\utils\error\elog.c). So we don't know exactly that GetFileInformationByHandle() will fails for stdin/stdout/stderr. Ior illustration, I attached small example (test.c) for this case: 1) GetFileInformationByHandle() for "stdout" works without error; 2) file "1.txt" after running test contains: Sample string attributes = 0x2020, file size = 15 >Each fileno is going to be 0, 1 or 2 in those cases, still >it would be better to rely on the result of fileno() as v3 is >doing? I think fileno() is safer. We can call fclose(stdout) and _fileno(stdout) returns -1 after that. But I don't know: can OS reuse fileno=1 or not in this case? With best regards, Dmitry.
Commits
-
Fix compatibility thinko for fstat() on standard streams in win32stat.c
- 5550a9c38519 14.2 landed
- 58651d8dd6a5 15.0 landed
-
Fix fstat() emulation on Windows with standard streams
- d2198b4593cc 14.2 landed
- 10260c794b21 15.0 landed