Re: BUG #17288: PSQL bug with COPY command (Windows)
| От | Dmitry Koval |
|---|---|
| Тема | Re: BUG #17288: PSQL bug with COPY command (Windows) |
| Дата | |
| Msg-id | 9e4efe29-0ff9-0808-fe32-d1d50e0be4fa@postgrespro.ru обсуждение исходный текст |
| Ответ на | Re: BUG #17288: PSQL bug with COPY command (Windows) (Michael Paquier <michael@paquier.xyz>) |
| Ответы |
Re: BUG #17288: PSQL bug with COPY command (Windows)
|
| Список | pgsql-bugs |
>_fstat64() and _stat64() have proved to be tricky to work with and >rather unworkable across all the build systems we support I agree, it is better not use them. >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(). >Just to be sure, this is the code path in psql's copy.c where we check >that a specified copystream is not a directory, right? Yes, fstat() called from file src/bin/psql/copy.c: /* make sure the specified file is not a directory */ if ((result = fstat(fileno(copystream), &st)) < 0) I attached new patch version. With best regards, Dmitry Koval.
Вложения
В списке pgsql-bugs по дате отправления: