Re: BUG #17288: PSQL bug with COPY command (Windows)
От | Juan José Santamaría Flecha |
---|---|
Тема | Re: BUG #17288: PSQL bug with COPY command (Windows) |
Дата | |
Msg-id | CAC+AXB3BKByL8O39qARu3XYMWmrNqMWhcHZZ_2ygqvrK-W6O1g@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: BUG #17288: PSQL bug with COPY command (Windows) (Dmitry Koval <d.koval@postgrespro.ru>) |
Ответы |
Re: BUG #17288: PSQL bug with COPY command (Windows)
|
Список | pgsql-bugs |
On Thu, Nov 18, 2021 at 2:40 PM Dmitry Koval <d.koval@postgrespro.ru> wrote:
>I think that we had better never call GetFileInformationByHandle() if
>we use a fileno that maps to stdin, stdout or stderr.
Probably we should call GetFileInformationByHandle() for case standard
streams stdin/stdout/stderr are redirected to files.
See file src\backend\utils\error\elog.c, for example. It contains
lines:
if (!freopen(OutputFileName, "a", stderr))
if (!freopen(OutputFileName, "a", stdout))
And this command with "stderr" works in PSQL without crash (in
contrast to "stdout"):
\copy (SELECT 1) TO stderr
(it put resullt into file with name "stderr").
We can emulate stats for stdin/stdout/stderr after call
GetFileInformationByHandle().
You are right about freopen(), but stderr works just because it's being parsed as a file, not a stream, by parse_slash_copy().
I attached new patch version.
I would keep the memset(buf, 0, sizeof(*buf)) for the members we are not setting.
Regards,
Juan José Santamaría Flecha
В списке pgsql-bugs по дате отправления: