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

Commitaf35fe5

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 parent09d09d4 commitaf35fe5

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
@@ -4944,6 +4944,7 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
49444944
intn;
49454945
int64k;
49464946
intchars=0;
4947+
intprev_chars=0;
49474948
PGresult*res;
49484949
PQExpBufferDatasql;
49494950
charcopy_statement[256];
@@ -5004,10 +5005,10 @@ initPopulateTable(PGconn *con, const char *table, int64 base,
50045005
doubleelapsed_sec=PG_TIME_GET_DOUBLE(pg_time_now()-start);
50055006
doubleremaining_sec= ((double)total-j)*elapsed_sec /j;
50065007

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

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

50325043
if (chars!=0&&eol!='\n')
5033-
fprintf(stderr,"%*c\r",chars-1,' ');/* Clear the current line */
5044+
fprintf(stderr,"%*c\r",chars,' ');/* Clear the current line */
50345045

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp