pgsql: Fix pg_current_logfile() to not emit a carriage return on Window

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix pg_current_logfile() to not emit a carriage return on Window
Date: 2020-07-09 20:03:05
Message-ID: E1jtcl7-0007Kd-1I@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix pg_current_logfile() to not emit a carriage return on Windows.

Due to not having our signals straight about CRLF vs. LF line
termination, the output of pg_current_logfile() included a trailing
\r on Windows. To fix, force the file descriptor it uses into text
mode.

While here, move a couple of local variable declarations to make
the function's logic clearer.

In v12 and v13, also back-patch the test added by 1c4e88e2f so that
this function has some test coverage. However, the 004_logrotate.pl
test script doesn't exist before v12, and it didn't seem worth adding
to older branches just for this.

Per report from Thomas Kellerer. Back-patch to v10 where this
function was added.

Discussion: https://postgr.es/m/412ae8da-76bb-640f-039a-f3513499e53d@gmx.net

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/765ad260a18fc65003ef244b401ef83525ff3da4

Modified Files
--------------
src/backend/utils/adt/misc.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-07-09 21:39:16 pgsql: Tighten up Windows CRLF conversion in our TAP test scripts.
Previous Message Tom Lane 2020-07-09 20:03:04 pgsql: Fix pg_current_logfile() to not emit a carriage return on Window