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

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Thomas Kellerer <shammat(at)gmx(dot)net>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Is this a bug in pg_current_logfile() on Windows?
Date: 2020-07-08 14:16:00
Message-ID: 945c1120-888c-8164-ddf7-216dfc637de0@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message FOUTE K. Jaurès 2020-07-08 15:01:06 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
Previous Message Yorwerth, Adam 2020-07-08 14:09:22 BigSerial and txid issuance

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2020-07-08 14:44:11 Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
Previous Message Justin Pryzby 2020-07-08 14:10:45 Re: [PATCH v2] Allow COPY "text" to output a header and add header matching mode to COPY FROM