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

Commitf1cb5e5

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 parentde01960 commitf1cb5e5

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,6 +3840,8 @@ initGenerateDataClientSide(PGconn *con)
38403840
PGresult*res;
38413841
inti;
38423842
int64k;
3843+
intchars=0;
3844+
intprev_chars=0;
38433845

38443846
/* used to track elapsed time and estimate of the remaining time */
38453847
instr_timestart,
@@ -3926,10 +3928,10 @@ initGenerateDataClientSide(PGconn *con)
39263928
elapsed_sec=INSTR_TIME_GET_DOUBLE(diff);
39273929
remaining_sec= ((double)scale*naccounts-j)*elapsed_sec /j;
39283930

3929-
fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)%c",
3930-
j, (int64)naccounts*scale,
3931-
(int) (((int64)j*100) / (naccounts* (int64)scale)),
3932-
elapsed_sec,remaining_sec,eol);
3931+
chars=fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)",
3932+
j, (int64)naccounts*scale,
3933+
(int) (((int64)j*100) / (naccounts* (int64)scale)),
3934+
elapsed_sec,remaining_sec);
39333935
}
39343936
/* let's not call the timing for each row, but only each 100 rows */
39353937
elseif (use_quiet&& (j %100==0))
@@ -3943,14 +3945,24 @@ initGenerateDataClientSide(PGconn *con)
39433945
/* have we reached the next interval (or end)? */
39443946
if ((j==scale*naccounts)|| (elapsed_sec >=log_interval*LOG_STEP_SECONDS))
39453947
{
3946-
fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)%c",
3947-
j, (int64)naccounts*scale,
3948-
(int) (((int64)j*100) / (naccounts* (int64)scale)),elapsed_sec,remaining_sec,eol);
3948+
chars=fprintf(stderr,INT64_FORMAT" of "INT64_FORMAT" tuples (%d%%) done (elapsed %.2f s, remaining %.2f s)",
3949+
j, (int64)naccounts*scale,
3950+
(int) (((int64)j*100) / (naccounts* (int64)scale)),elapsed_sec,remaining_sec);
39493951

39503952
/* skip to the next interval */
39513953
log_interval= (int)ceil(elapsed_sec /LOG_STEP_SECONDS);
39523954
}
39533955
}
3956+
3957+
/*
3958+
* If the previous progress message is longer than the current one,
3959+
* add spaces to the current line to fully overwrite any remaining
3960+
* characters from the previous message.
3961+
*/
3962+
if (prev_chars>chars)
3963+
fprintf(stderr,"%*c",prev_chars-chars,' ');
3964+
fputc(eol,stderr);
3965+
prev_chars=chars;
39543966
}
39553967

39563968
if (eol!='\n')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp