Thread

Commits

  1. Avoid non-constant format string argument to fprintf().

  2. Fix printing last progress report line in client programs.

  1. Newline after --progress report

    Heikki Linnakangas <hlinnaka@iki.fi> — 2020-08-14T07:57:10Z

    While hacking on pg_rewind, this in pg_rewind's main() function caught 
    my eye:
    
         progress_report(true);
         printf("\n");
    
    It is peculiar, because progress_report() uses fprintf(stderr, ...) for 
    all its printing, and in fact the only other use of printf() in 
    pg_rewind is in printing the "pg_rewind --help" text.
    
    I think the idea here was to move to the next line, after 
    progress_report() has updated the progress line for the last time. It 
    probably also should not be printed, when "--progress" is not used.
    
    Attached is a patch to fix this, as well as a similar issue in 
    pg_checksums. pg_basebackup and pgbench also print progres reports like 
    this, but they seem correct to me.
    
    - Heikki
    
  2. Re: Newline after --progress report

    Tom Lane <tgl@sss.pgh.pa.us> — 2020-08-14T13:51:44Z

    Heikki Linnakangas <hlinnaka@iki.fi> writes:
    > While hacking on pg_rewind, this in pg_rewind's main() function caught 
    > my eye:
    
    Good catch.
    
    > Attached is a patch to fix this, as well as a similar issue in 
    > pg_checksums. pg_basebackup and pgbench also print progres reports like 
    > this, but they seem correct to me.
    
    I wonder whether it'd be better to push the responsibility for this
    into progress_report(), by adding an additional parameter "bool last"
    or the like.  Then the callers would not need such an unseemly amount
    of knowledge about what progress_report() is doing.
    
    			regards, tom lane
    
    
    
    
  3. Re: Newline after --progress report

    Heikki Linnakangas <hlinnaka@iki.fi> — 2020-08-17T07:14:38Z

    On 14/08/2020 16:51, Tom Lane wrote:
    > Heikki Linnakangas <hlinnaka@iki.fi> writes:
    >> Attached is a patch to fix this, as well as a similar issue in
    >> pg_checksums. pg_basebackup and pgbench also print progres reports like
    >> this, but they seem correct to me.
    > 
    > I wonder whether it'd be better to push the responsibility for this
    > into progress_report(), by adding an additional parameter "bool last"
    > or the like.  Then the callers would not need such an unseemly amount
    > of knowledge about what progress_report() is doing.
    
    Good point. Pushed a patch along those lines.
    
    - Heikki
    
    
    
    
  4. Re: Newline after --progress report

    Tom Lane <tgl@sss.pgh.pa.us> — 2020-08-17T13:59:39Z

    Heikki Linnakangas <hlinnaka@iki.fi> writes:
    > Good point. Pushed a patch along those lines.
    
    Uh ... you patched v12 but not v13?
    
    Also, I'd recommend that you NOT do this:
    
    +   fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
    
    as it breaks printf format verification in many/most compilers.
    
    			regards, tom lane
    
    
    
    
  5. Re: Newline after --progress report

    Heikki Linnakangas <hlinnaka@iki.fi> — 2020-08-17T14:20:46Z

    On 17/08/2020 16:59, Tom Lane wrote:
    > Heikki Linnakangas <hlinnaka@iki.fi> writes:
    >> Good point. Pushed a patch along those lines.
    > 
    > Uh ... you patched v12 but not v13?
    
    Darn, I forgot it exists.
    
    > Also, I'd recommend that you NOT do this:
    > 
    > +   fprintf(stderr, (!finished && isatty(fileno(stderr))) ? "\r" : "\n");
    > 
    > as it breaks printf format verification in many/most compilers.
    
    Ok. I pushed the same commit to v12 as to other branches now, to keep 
    them in sync. I'll go fix that as a separate commit. Thanks!
    
    - Heikki