Re: pgbench -i progress output on terminal - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: pgbench -i progress output on terminal
Date
Msg-id alpine.DEB.2.21.1911291157500.12886@pseudo
Whole thread Raw
In response to pgbench -i progress output on terminal  (Amit Langote <amitlangote09@gmail.com>)
Responses Re: pgbench -i progress output on terminal  (Amit Langote <amitlangote09@gmail.com>)
List pgsql-hackers
> I wonder why we don't use the same style for $subject as pg_basebackup
> --progress, that is, use a carriage return instead of a newline after
> each line reporting the number of tuples copied?

Patch applies cleanly, compiles, and works for me.

My 0.02€:

fprintf -> fputs or fputc to avoid a format parsing, or maybe use %c in 
the formats.

As the format is not constant, ISTM that vfprintf should be called, not 
fprintf (even if in practice fprintf does call vfprintf internally).

I'm not sure what the compilers does with isatty(fileno(stderr)), maybe
the eol could be precomputed:

   char eol = isatty(...) ? '\r' : '\n';

and reused afterwards in the loop:

   fprintf(stderr, ".... %c", ..., eol);

that would remove the added in-loop printing.

-- 
Fabien.

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Update minimum SSL version
Next
From: Masahiko Sawada
Date:
Subject: Re: [HACKERS] Block level parallel vacuum