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

From: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17288: PSQL bug with COPY command (Windows)
Date: 2021-11-19 08:47:02
Message-ID: 4c22d38f-efa9-4d83-c551-707f1770e585@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>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.

Attachment Content-Type Size
test.c text/plain 726 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2021-11-19 09:07:42 Re: conchuela timeouts since 2021-10-09 system upgrade
Previous Message Andrey Borodin 2021-11-19 08:43:56 Re: conchuela timeouts since 2021-10-09 system upgrade