Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitadb103f

Browse files
committed
pgbench: Ensure previous progress message is fully cleared when updating.
During pgbench's table initialization, progress updates could displayleftover characters from the previous message if the new messagewas shorter. This commit resolves the issue by appending spaces tothe current message to fully overwrite any remaining characters fromthe previous line.Back-patch to all the supported versions.Author: Yushi Ogiwara, Tatsuo Ishii, Fujii MasaoReviewed-by: Tatsuo Ishii, Fujii MasaoDiscussion:https://postgr.es/m/9a9b8b95b6a709877ae48ad5b0c59bb9@oss.nttdata.com
1 parent6e79358 commitadb103f

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4943,6 +4943,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
49434943
intn;
49444944
int64k;
49454945
intchars=0;
4946+
intprev_chars=0;
49464947
PGresult*res;
49474948
PQExpBufferDatasql;
49484949
charcopy_statement[256];
@@ -5003,10 +5004,10 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
50035004
doubleelapsed_sec=PG_TIME_GET_DOUBLE(pg_time_now()-start);
50045005
doubleremaining_sec= ((double)total-j)*elapsed_sec /j;
50055006

5006-
chars=fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s)%c",
5007+
chars=fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s)",
50075008
j,total,
50085009
(int) ((j*100) /total),
5009-
table,elapsed_sec,remaining_sec,eol);
5010+
table,elapsed_sec,remaining_sec);
50105011
}
50115012
/* let's not call the timing for each row, but only each 100 rows */
50125013
elseif (use_quiet&& (j %100==0))
@@ -5017,19 +5018,29 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
50175018
/* have we reached the next interval (or end)? */
50185019
if ((j==total)|| (elapsed_sec >=log_interval*LOG_STEP_SECONDS))
50195020
{
5020-
chars=fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s)%c",
5021+
chars=fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) of %s done (elapsed %.2f s, remaining %.2f s)",
50215022
j,total,
50225023
(int) ((j*100) /total),
5023-
table,elapsed_sec,remaining_sec,eol);
5024+
table,elapsed_sec,remaining_sec);
50245025

50255026
/* skip to the next interval */
50265027
log_interval= (int)ceil(elapsed_sec /LOG_STEP_SECONDS);
50275028
}
50285029
}
5030+
5031+
/*
5032+
* If the previous progress message is longer than the current one,
5033+
* add spaces to the current line to fully overwrite any remaining
5034+
* characters from the previous message.
5035+
*/
5036+
if (prev_chars>chars)
5037+
fprintf(stderr,"%*c",prev_chars-chars,' ');
5038+
fputc(eol,stderr);
5039+
prev_chars=chars;
50295040
}
50305041

50315042
if (chars!=0&&eol!='\n')
5032-
fprintf(stderr,"%*c\r",chars-1,' ');/* Clear the current line */
5043+
fprintf(stderr,"%*c\r",chars,' ');/* Clear the current line */
50335044

50345045
if (PQputline(con,"\\.\n"))
50355046
pg_fatal("very last PQputline failed");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp