Re: Is this a bug in pg_current_logfile() on Windows?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Is this a bug in pg_current_logfile() on Windows?
Дата
Msg-id 1716646.1594226496@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Is this a bug in pg_current_logfile() on Windows?  (Thomas Kellerer <shammat@gmx.net>)
Ответы Re: Is this a bug in pg_current_logfile() on Windows?
Список pgsql-general
Thomas Kellerer <shammat@gmx.net> writes:
> I noticed the following strage output when running Postgres 12.3 (not psql) on Windows

>     postgres=# select pg_current_logfile();
>              pg_current_logfile
>     ------------------------------------
>      pg_log/postgresql-2020-07-08.log\r
>     (1 row)

> Note the "\r" at the end of the file name.

Yeah, that seems like a bug.  I think the reason is that syslogger.c
does this when writing the log metafile:

    fh = fopen(LOG_METAINFO_DATAFILE_TMP, "w");
...
#ifdef WIN32
        /* use CRLF line endings on Windows */
        _setmode(_fileno(fh), _O_TEXT);
#endif

while misc.c only does this when reading the file:

    fd = AllocateFile(LOG_METAINFO_DATAFILE, "r");

Somehow, the reading file is being left in binary mode and thus it's
failing to convert \r\n back to plain \n.

Now the weird thing about that is I'd have expected "r" and "w" modes
to imply Windows text mode already, so that I'd have figured that
_setmode call to be a useless no-op.  Apparently on some Windows libc
implementations, it's not.  How was your installation built exactly?

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: BigSerial and txid issuance
Следующее
От: Tom Lane
Дата:
Сообщение: Re: PostgreSQL 12 - ERROR: could not rename file "pg_logical/snapshots/1A-7C00D890.snap.13594.tmp" to "pg_logical/snapshots/1A-7C00D890.snap": No space left on device