Re: Is this a bug in pg_current_logfile() on Windows?
Adrian Klaver <adrian.klaver@aklaver.com>
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Thomas Kellerer <shammat@gmx.net>, pgsql-general@lists.postgresql.org
Date: 2020-07-08T14:16:00Z
Lists: pgsql-hackers, pgsql-general
On 7/8/20 6:45 AM, Adrian Klaver wrote:
> On 7/8/20 6:05 AM, Thomas Kellerer wrote:
>> Hello,
>>
>> 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.
>>
>> This does not happen when running Postgres on Linux.
>>
>> Is this intended for some strange reason?
>> Or a bug or a technical limitation?
>
> I'm guessing the difference between Unix line ending:
>
> \n
>
> and Windows:
>
> \r\n
>
From source(backend/utils/adt/misc.c):
nlpos = strchr(log_filepath, '\n');
if (nlpos == NULL)
{
/* Uh oh. No newline found, so file content is corrupted. */
elog(ERROR,
"missing newline character in \"%s\"",
LOG_METAINFO_DATAFILE);
break;
}
*nlpos = '\0';
if (logfmt == NULL || strcmp(logfmt, log_format) == 0)
{
FreeFile(fd);
PG_RETURN_TEXT_P(cstring_to_text(log_filepath));
}
>>
>> Regards
>> Thomas
>>
>>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Commits
-
Tighten up Windows CRLF conversion in our TAP test scripts.
- d0390509a182 9.5.23 landed
- ce9d053423fd 9.6.19 landed
- a3cfb10764bb 12.4 landed
- 89162b7364bf 11.9 landed
- 4c17c5a8529c 10.14 landed
- 17b87b3049fa 13.0 landed
- 91bdf499b37b 14.0 landed
-
Fix pg_current_logfile() to not emit a carriage return on Windows.
- 90b418f81645 11.9 landed
- 765ad260a18f 10.14 landed
- 601d419b2b5d 13.0 landed
- 2564e2d08546 12.4 landed
- 183926da3162 14.0 landed
-
Further tighten Windows CRLF conversion in our TAP test scripts.
- ffb4cee43bdc 14.0 landed
-
Add test coverage for pg_current_logfile() function.
- 1c4e88e2fe41 14.0 landed
-
Fix failures to ignore \r when reading Windows-style newlines.
- b654714f9bcf 13.0 cited
-
Fix TAP infrastructure to support Mingw better
- 33f3bbc6d37d 10.0 cited