aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_ctl/t/004_logrotate.pl
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-07-09 16:02:23 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-07-09 16:02:23 -0400
commit2564e2d08546dfedc1482e10205be58a20ffe3cc (patch)
tree1b0b93b1d9b33b6db1d3899cbe97b4811cbf8c30 /src/bin/pg_ctl/t/004_logrotate.pl
parent0df3f9cb92deb81cdb12367d641c0a7855507e5b (diff)
downloadpostgresql-2564e2d08546dfedc1482e10205be58a20ffe3cc.tar.gz
postgresql-2564e2d08546dfedc1482e10205be58a20ffe3cc.zip
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
Diffstat (limited to 'src/bin/pg_ctl/t/004_logrotate.pl')
-rw-r--r--src/bin/pg_ctl/t/004_logrotate.pl6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bin/pg_ctl/t/004_logrotate.pl b/src/bin/pg_ctl/t/004_logrotate.pl
index 71dbfd20301..acaade8d812 100644
--- a/src/bin/pg_ctl/t/004_logrotate.pl
+++ b/src/bin/pg_ctl/t/004_logrotate.pl
@@ -3,7 +3,7 @@ use warnings;
use PostgresNode;
use TestLib;
-use Test::More tests => 4;
+use Test::More tests => 5;
use Time::HiRes qw(usleep);
# Set up node with logging collector
@@ -47,6 +47,10 @@ for (my $attempts = 0; $attempts < $max_attempts; $attempts++)
like($first_logfile, qr/division by zero/, 'found expected log file content');
+# While we're at it, test pg_current_logfile() function
+is($node->safe_psql('postgres', "SELECT pg_current_logfile('stderr')"),
+ $lfname, 'pg_current_logfile() gives correct answer');
+
# Sleep 2 seconds and ask for log rotation; this should result in
# output into a different log file name.
sleep(2);