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

Commitd37ddb7

Browse files
committed
Use carriage returns for data insertion logs in pgbench on terminal
This is similar to what pg_basebackup and pg_rewind do when reportingcumulative data, and that's more user-friendly. Carriage returns arenow used when stderr points to a terminal, and newlines are used inother cases, like a redirection to a log file.Author: Amit LangoteReviewed-by: Fabien CoelhoDiscussion:https://postgr.es/m/CA+HiwqFNwEjPeVaQsp2L7DyCPv1Eg1guwhrVhzMYqUJUk8ULKg@mail.gmail.com
1 parent85b9ef5 commitd37ddb7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3835,6 +3835,9 @@ initGenerateDataClientSide(PGconn *con)
38353835
remaining_sec;
38363836
intlog_interval=1;
38373837

3838+
/* Stay on the same line if reporting to a terminal */
3839+
chareol=isatty(fileno(stderr)) ?'\r' :'\n';
3840+
38383841
fprintf(stderr,"generating data (client-side)...\n");
38393842

38403843
/*
@@ -3910,10 +3913,10 @@ initGenerateDataClientSide(PGconn *con)
39103913
elapsed_sec=INSTR_TIME_GET_DOUBLE(diff);
39113914
remaining_sec= ((double)scale*naccounts-j)*elapsed_sec /j;
39123915

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",
39143917
j, (int64)naccounts*scale,
39153918
(int) (((int64)j*100) / (naccounts* (int64)scale)),
3916-
elapsed_sec,remaining_sec);
3919+
elapsed_sec,remaining_sec,eol);
39173920
}
39183921
/* let's not call the timing for each row, but only each 100 rows */
39193922
elseif (use_quiet&& (j %100==0))
@@ -3927,16 +3930,19 @@ initGenerateDataClientSide(PGconn *con)
39273930
/* have we reached the next interval (or end)? */
39283931
if ((j==scale*naccounts)|| (elapsed_sec >=log_interval*LOG_STEP_SECONDS))
39293932
{
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",
39313934
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);
39333936

39343937
/* skip to the next interval */
39353938
log_interval= (int)ceil(elapsed_sec /LOG_STEP_SECONDS);
39363939
}
39373940
}
3938-
39393941
}
3942+
3943+
if (eol!='\n')
3944+
fputc('\n',stderr);/* Need to move to next line */
3945+
39403946
if (PQputline(con,"\\.\n"))
39413947
{
39423948
fprintf(stderr,"very last PQputline failed\n");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp