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: Michael Paquier <michael@paquier.xyz>
Cc: Dmitry Koval <d.koval@postgrespro.ru>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2021-11-18T11:37:08Z
Lists: pgsql-bugs

Attachments

Thanks for reporting.

On Thu, Nov 18, 2021 at 8:40 AM Michael Paquier <michael@paquier.xyz> wrote:

> On Wed, Nov 17, 2021 at 01:29:02PM +0300, Dmitry Koval wrote:
> > Attachments: patch + screenshot with error.
>
> I think that we had better never call GetFileInformationByHandle() if
> we use a fileno that maps to stdin, stdout or stderr.  The 10000$
> question is what to use though.  One option is to let our emulation
> code fill in the gap for those three cases with at least st_mode
> filled with S_IFIFO, then return 0 as error code :/
>
> When the file descriptor is coming from a stream I don't think we have to
use GetFileInformationByHandle() or stat() to get any information, but we
can directly return the stat information. Please find attached a patch for
so.

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