Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtD8j-0008BX-U4 for pgsql-general@arkaria.postgresql.org; Wed, 08 Jul 2020 16:41:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jtD8i-0002dH-N0 for pgsql-general@arkaria.postgresql.org; Wed, 08 Jul 2020 16:41:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtD8i-0002dA-FF for pgsql-general@lists.postgresql.org; Wed, 08 Jul 2020 16:41:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtD8f-0001Ln-Qk for pgsql-general@lists.postgresql.org; Wed, 08 Jul 2020 16:41:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 068GfaGx1716647; Wed, 8 Jul 2020 12:41:36 -0400 From: Tom Lane To: Thomas Kellerer cc: pgsql-general@lists.postgresql.org Subject: Re: Is this a bug in pg_current_logfile() on Windows? In-reply-to: <412ae8da-76bb-640f-039a-f3513499e53d@gmx.net> References: <412ae8da-76bb-640f-039a-f3513499e53d@gmx.net> Comments: In-reply-to Thomas Kellerer message dated "Wed, 08 Jul 2020 15:05:25 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1716645.1594226496.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 08 Jul 2020 12:41:36 -0400 Message-ID: <1716646.1594226496@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Kellerer writes: > I noticed the following strage output when running Postgres 12.3 (not ps= ql) on Windows > postgres=3D# 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 =3D 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 =3D 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