From: | Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com> |
---|---|
To: | Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #17288: PSQL bug with COPY command (Windows) |
Date: | 2021-11-18 18:13:53 |
Message-ID: | CAC+AXB3BKByL8O39qARu3XYMWmrNqMWhcHZZ_2ygqvrK-W6O1g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, Nov 18, 2021 at 2:40 PM Dmitry Koval <d(dot)koval(at)postgrespro(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Dmitry Koval | 2021-11-18 18:48:55 | Re: BUG #17288: PSQL bug with COPY command (Windows) |
Previous Message | Дмитрий Иванов | 2021-11-18 18:07:12 | Re: pg_restore depending on user functions |