public inbox for [email protected]help / color / mirror / Atom feed
[PATCH 1/1] Fix printing last progress report line in client programs. 20+ messages / 2 participants [nested] [flat]
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* [PATCH 1/1] Fix printing last progress report line in client programs. @ 2020-08-12 20:27 Heikki Linnakangas <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Heikki Linnakangas @ 2020-08-12 20:27 UTC (permalink / raw) A number of client programs have a "--progress" option that when printing to a TTY, updates the current line by printing a '\r' and overwriting it. After the last line, an extra '\n' needs to be printed to move the cursor to the next line. pg_basebackup and pgbench got this right, but pg_rewind and pg_checksums were slightly wrong. pg_rewind printed the newline to stdout instead of stderr, and pg_checksum printed the newline even when not printing to a TTY. Fix them. --- src/bin/pg_checksums/pg_checksums.c | 3 ++- src/bin/pg_rewind/pg_rewind.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 1daa5aed0e0..9ae884897ef 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -626,7 +626,8 @@ main(int argc, char *argv[]) if (showprogress) { progress_report(true); - fprintf(stderr, "\n"); /* Need to move to next line */ + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ } printf(_("Checksum operation completed\n")); diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 0015d3b461a..c000c12fa58 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -422,7 +422,8 @@ main(int argc, char **argv) executeFileMap(); progress_report(true); - printf("\n"); + if (showprogress && isatty(fileno(stderr))) + fprintf(stderr, "\n"); /* Need to move to next line */ if (showprogress) pg_log_info("creating backup label and updating control file"); -- 2.20.1 --------------D7F229EC53544D857CE3A506-- ^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: Questions about logicalrep_worker_launch() @ 2025-04-25 18:03 Masahiko Sawada <[email protected]> 0 siblings, 0 replies; 20+ messages in thread From: Masahiko Sawada @ 2025-04-25 18:03 UTC (permalink / raw) To: Fujii Masao <[email protected]>; +Cc: pgsql-hackers Hi, On Fri, Apr 25, 2025 at 9:10 AM Fujii Masao <[email protected]> wrote: > > Hi, > > While reading the code of logicalrep_worker_launch(), I had two questions: > > (1) > When the sync worker limit per subscription is reached, logicalrep_worker_launch() > runs garbage collection to try to free up slots before checking the limit again. > That makes sense. > > But should we do the same when the parallel apply worker limit is reached? > Currently, if we've hit the parallel apply worker limit but not the sync worker limit > and we find an unused worker slot, garbage collection doesn't run. Would it > make sense to also run garbage collection in that case? Good point. In that case, we would end up not being able to launch parallel apply workers for the subscription until either we used up all worker slots or reached the sync worker limit, which is bad. > > (2) > If garbage collection removes at least one worker, logicalrep_worker_launch() > scans all worker slots again to look for a free one. But since we know at least one > slot was freed, this retry might be unnecessary. We could just reuse the freed > slot directly. Is that correct? Agreed. Since these codes are protected by LogicalRepWorkerLock in an exclusive mode, we should be able to use the worker slot that we just cleaned up. > The attached patch addresses both points. Since logicalrep_worker_launch() > isn't a performance-critical path, this might not be a high-priority change. > But if my understanding is correct, I'm a bit tempted to apply it as a refactoring. I agree with these changes. I think that while the changes for (2) should be for v19, the changes for (1) might be treated as a bug fix? Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com ^ permalink raw reply [nested|flat] 20+ messages in thread
end of thread, other threads:[~2025-04-25 18:03 UTC | newest] Thread overview: 20+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2020-08-12 20:27 [PATCH 1/1] Fix printing last progress report line in client programs. Heikki Linnakangas <[email protected]> 2025-04-25 18:03 Re: Questions about logicalrep_worker_launch() Masahiko Sawada <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox