@@ -3835,6 +3835,9 @@ initGenerateDataClientSide(PGconn *con)
3835
3835
remaining_sec ;
3836
3836
int log_interval = 1 ;
3837
3837
3838
+ /* Stay on the same line if reporting to a terminal */
3839
+ char eol = isatty (fileno (stderr )) ? '\r' : '\n' ;
3840
+
3838
3841
fprintf (stderr , "generating data (client-side)...\n" );
3839
3842
3840
3843
/*
@@ -3910,10 +3913,10 @@ initGenerateDataClientSide(PGconn *con)
3910
3913
elapsed_sec = INSTR_TIME_GET_DOUBLE (diff );
3911
3914
remaining_sec = ((double ) scale * naccounts - j ) * elapsed_sec / j ;
3912
3915
3913
- fprintf (stderr , INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)\n " ,
3916
+ fprintf (stderr , INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)%c " ,
3914
3917
j , (int64 ) naccounts * scale ,
3915
3918
(int ) (((int64 ) j * 100 ) / (naccounts * (int64 ) scale )),
3916
- elapsed_sec , remaining_sec );
3919
+ elapsed_sec , remaining_sec , eol );
3917
3920
}
3918
3921
/* let's not call the timing for each row, but only each 100 rows */
3919
3922
else if (use_quiet && (j % 100 == 0 ))
@@ -3927,16 +3930,19 @@ initGenerateDataClientSide(PGconn *con)
3927
3930
/* have we reached the next interval (or end)? */
3928
3931
if ((j == scale * naccounts ) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS ))
3929
3932
{
3930
- fprintf (stderr , INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)\n " ,
3933
+ fprintf (stderr , INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)%c " ,
3931
3934
j , (int64 ) naccounts * scale ,
3932
- (int ) (((int64 ) j * 100 ) / (naccounts * (int64 ) scale )), elapsed_sec , remaining_sec );
3935
+ (int ) (((int64 ) j * 100 ) / (naccounts * (int64 ) scale )), elapsed_sec , remaining_sec , eol );
3933
3936
3934
3937
/* skip to the next interval */
3935
3938
log_interval = (int ) ceil (elapsed_sec / LOG_STEP_SECONDS );
3936
3939
}
3937
3940
}
3938
-
3939
3941
}
3942
+
3943
+ if (eol != '\n' )
3944
+ fputc ('\n' , stderr ); /* Need to move to next line */
3945
+
3940
3946
if (PQputline (con , "\\.\n" ))
3941
3947
{
3942
3948
fprintf (stderr , "very last PQputline failed\n" );
0 commit comments