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

Commitaa4a0b9

Browse files
committed
pgbench: Don't fail during startup
In pgbench, report, but ignore, any errors returned when attempting tovacuum/truncate the default tables during startup. If the tables areneeded, we'll error out soon enough anyway.Per discussion with Tatsuo, David Rowley, Jim Nasby, Robert, Andres,Fujii, Fabrízio de Royes Mello, Tomas Vondra, Michael Paquier, Peter,based on a suggestion from Jeff Janes, patch from Robert, additionalmessage wording from Tom.
1 parent97e0aa6 commitaa4a0b9

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,21 @@ executeStatement(PGconn *con, const char *sql)
605605
PQclear(res);
606606
}
607607

608+
/* call PQexec() and complain, but without exiting, on failure */
609+
staticvoid
610+
tryExecuteStatement(PGconn*con,constchar*sql)
611+
{
612+
PGresult*res;
613+
614+
res=PQexec(con,sql);
615+
if (PQresultStatus(res)!=PGRES_COMMAND_OK)
616+
{
617+
fprintf(stderr,"%s",PQerrorMessage(con));
618+
fprintf(stderr,"(ignoring this error and continuing anyway)\n");
619+
}
620+
PQclear(res);
621+
}
622+
608623
/* set up a connection to the backend */
609624
staticPGconn*
610625
doConnect(void)
@@ -3283,15 +3298,15 @@ main(int argc, char **argv)
32833298
if (!is_no_vacuum)
32843299
{
32853300
fprintf(stderr,"starting vacuum...");
3286-
executeStatement(con,"vacuum pgbench_branches");
3287-
executeStatement(con,"vacuum pgbench_tellers");
3288-
executeStatement(con,"truncate pgbench_history");
3301+
tryExecuteStatement(con,"vacuum pgbench_branches");
3302+
tryExecuteStatement(con,"vacuum pgbench_tellers");
3303+
tryExecuteStatement(con,"truncate pgbench_history");
32893304
fprintf(stderr,"end.\n");
32903305

32913306
if (do_vacuum_accounts)
32923307
{
32933308
fprintf(stderr,"starting vacuum pgbench_accounts...");
3294-
executeStatement(con,"vacuum analyze pgbench_accounts");
3309+
tryExecuteStatement(con,"vacuum analyze pgbench_accounts");
32953310
fprintf(stderr,"end.\n");
32963311
}
32973312
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp