diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 4a7ac1f821..d0f2cadaaf 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3906,7 +3906,7 @@ initGenerateDataClientSide(PGconn *con) elapsed_sec = INSTR_TIME_GET_DOUBLE(diff); remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j; - fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)\n", + fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)", j, (int64) naccounts * scale, (int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec); @@ -3923,7 +3923,7 @@ initGenerateDataClientSide(PGconn *con) /* have we reached the next interval (or end)? */ if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS)) { - fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)\n", + fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)", j, (int64) naccounts * scale, (int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec); @@ -3932,7 +3932,13 @@ initGenerateDataClientSide(PGconn *con) } } + /* Stay on the same line if reporting to a terminal */ + fprintf(stderr, isatty(fileno(stderr)) ? "\r" : "\n"); } + + if (isatty(fileno(stderr))) + fprintf(stderr, "\n"); + if (PQputline(con, "\\.\n")) { fprintf(stderr, "very last PQputline failed\n");