public inbox for [email protected]
help / color / mirror / Atom feed[PATCH 1/1] Fix printing last progress report line in client programs.
21+ messages / 3 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ 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; 21+ 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] 21+ messages in thread
* Re: anonymous unions (C11)
@ 2026-01-19 21:10 Álvaro Herrera <[email protected]>
2026-01-21 11:21 ` Re: anonymous unions (C11) Peter Eisentraut <[email protected]>
0 siblings, 1 reply; 21+ messages in thread
From: Álvaro Herrera @ 2026-01-19 21:10 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: pgsql-hackers
On 2025-Sep-23, Peter Eisentraut wrote:
> Here is another patch set to sprinkle some C11 features around the
> code. My aim is to make a little bit of use of several C11 features
> as examples and encouragement for future code, and to test compilers
> (although we're not yet at the point where this should really stress
> any compiler).
I was going over patch [1] today and came across the union in
relopt_value. Vaguely remembering this thread, I patched it out
(attached) ... and now that I come here to post it, I realize that it's
probably identical to your patch 0009 here.
Would you push it or can I?
[1] https://postgr.es/m/4047390.3Lj2Plt8kZ@thinkpad-pgpro
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: anonymous unions (C11)
2026-01-19 21:10 Re: anonymous unions (C11) Álvaro Herrera <[email protected]>
@ 2026-01-21 11:21 ` Peter Eisentraut <[email protected]>
0 siblings, 0 replies; 21+ messages in thread
From: Peter Eisentraut @ 2026-01-21 11:21 UTC (permalink / raw)
To: Álvaro Herrera <[email protected]>; +Cc: pgsql-hackers
On 19.01.26 22:10, Álvaro Herrera wrote:
> On 2025-Sep-23, Peter Eisentraut wrote:
>
>> Here is another patch set to sprinkle some C11 features around the
>> code. My aim is to make a little bit of use of several C11 features
>> as examples and encouragement for future code, and to test compilers
>> (although we're not yet at the point where this should really stress
>> any compiler).
>
> I was going over patch [1] today and came across the union in
> relopt_value. Vaguely remembering this thread, I patched it out
> (attached) ... and now that I come here to post it, I realize that it's
> probably identical to your patch 0009 here.
>
> Would you push it or can I?
Go ahead please.
^ permalink raw reply [nested|flat] 21+ messages in thread
end of thread, other threads:[~2026-01-21 11:21 UTC | newest]
Thread overview: 21+ 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]>
2026-01-19 21:10 Re: anonymous unions (C11) Álvaro Herrera <[email protected]>
2026-01-21 11:21 ` Re: anonymous unions (C11) Peter Eisentraut <[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