Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit aa4a0b9

Browse files
committed
pgbench: Don't fail during startup
In pgbench, report, but ignore, any errors returned when attempting to vacuum/truncate the default tables during startup. If the tables are needed, 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, additional message wording from Tom.
1 parent 97e0aa6 commit aa4a0b9

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/bin/pgbench/pgbench.c

+19-4
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+
static void
610+
tryExecuteStatement(PGconn *con, const char *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
static PGconn *
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)