public inbox for [email protected]
help / color / mirror / Atom feed[PATCH 1/1] Fix printing last progress report line in client programs.
2+ 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; 2+ 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] 2+ messages in thread
* Re: is ErrorResponse possible on Sync?
@ 2022-01-12 19:39 Alvaro Herrera <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Alvaro Herrera @ 2022-01-12 19:39 UTC (permalink / raw)
To: Andrei Matei <[email protected]>; +Cc: Tom Lane <[email protected]>; [email protected]
On 2022-Jan-12, Andrei Matei wrote:
> If Sync itself cannot fail, then what is this
> sentence really saying: "This parameterless message (ed. Sync) causes the
> backend to close the current transaction if it's not inside a BEGIN/COMMIT
> transaction block (“close” meaning to commit if no error, or roll back if
> error)." ?
> This seems to say that, outside of BEGIN/END, the transaction is committed
> at Sync time (i.e. if the Sync is never sent, nothing is committed).
> Presumably, committing a transaction can fail even if no
> previous command/statement failed, right?
A deferred trigger can cause a failure at COMMIT time for which no
previous error was reported.
alvherre=# create table t (a int unique deferrable initially deferred);
CREATE TABLE
alvherre=# insert into t values (1);
INSERT 0 1
alvherre=# begin;
BEGIN
alvherre=*# insert into t values (1);
INSERT 0 1
alvherre=*# commit;
ERROR: duplicate key value violates unique constraint "t_a_key"
DETALLE: Key (a)=(1) already exists.
I'm not sure if you can cause this to explode with just a Sync message, though.
--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-01-12 19:39 UTC | newest]
Thread overview: 2+ 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]>
2022-01-12 19:39 Re: is ErrorResponse possible on Sync? Alvaro Herrera <[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