Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit143b54d

Browse files
committed
pg_basebackup: Fix progress messages when writing to a file
The progress messages print out \r to keep overwriting the same line onthe screen. But this does not yield useful results when writing theoutput to a file. So in that case, print out \n instead.Author: Martín Marqués <martin@2ndquadrant.com>Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
1 parent06ae669 commit143b54d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,10 @@ progress_report(int tablespacenum, const char *filename, bool force)
811811
totaldone_str,totalsize_str,percent,
812812
tablespacenum,tablespacecount);
813813

814-
fprintf(stderr,"\r");
814+
if (isatty(fileno(stderr)))
815+
fprintf(stderr,"\r");
816+
else
817+
fprintf(stderr,"\n");
815818
}
816819

817820
staticint32
@@ -1796,7 +1799,13 @@ BaseBackup(void)
17961799
progname);
17971800

17981801
if (showprogress&& !verbose)
1799-
fprintf(stderr,"waiting for checkpoint\r");
1802+
{
1803+
fprintf(stderr,"waiting for checkpoint");
1804+
if (isatty(fileno(stderr)))
1805+
fprintf(stderr,"\r");
1806+
else
1807+
fprintf(stderr,"\n");
1808+
}
18001809

18011810
basebkp=
18021811
psprintf("BASE_BACKUP LABEL '%s' %s %s %s %s %s %s",
@@ -1929,7 +1938,8 @@ BaseBackup(void)
19291938
if (showprogress)
19301939
{
19311940
progress_report(PQntuples(res),NULL, true);
1932-
fprintf(stderr,"\n");/* Need to move to next line */
1941+
if (isatty(fileno(stderr)))
1942+
fprintf(stderr,"\n");/* Need to move to next line */
19331943
}
19341944

19351945
PQclear(res);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp