Re: BUG #17288: PSQL bug with COPY command (Windows)

Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>

From: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>
To: Dmitry Koval <d.koval@postgrespro.ru>
Cc: Michael Paquier <michael@paquier.xyz>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2021-11-19T09:25:14Z
Lists: pgsql-bugs

Attachments

On Fri, Nov 19, 2021 at 9:47 AM Dmitry Koval <d.koval@postgrespro.ru> wrote:

>  >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
>
> We can check for redirection without calling GetFileInformationByHandle(),
please consider the attached patch.

Regards,

Juan José Santamaría Flecha

Commits

  1. Fix compatibility thinko for fstat() on standard streams in win32stat.c

  2. Fix fstat() emulation on Windows with standard streams