diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 2e1650d..a1d6aed 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3080,14 +3080,14 @@ allocCStatePrepared(CState *st) /* * Prepare the SQL command from st->use_file at command_num. */ -static void +static bool prepareCommand(CState *st, int command_num) { Command *command = sql_script[st->use_file].commands[command_num]; /* No prepare for non-SQL commands */ if (command->type != SQL_COMMAND) - return; + return true; if (!st->prepared) allocCStatePrepared(st); @@ -3099,11 +3099,15 @@ prepareCommand(CState *st, int command_num) pg_log_debug("client %d preparing %s", st->id, command->prepname); res = PQprepare(st->con, command->prepname, command->argv[0], command->argc - 1, NULL); - if (PQresultStatus(res) != PGRES_COMMAND_OK) + if (PQresultStatus(res) != PGRES_COMMAND_OK) { pg_log_error("%s", PQerrorMessage(st->con)); + return false; + } PQclear(res); st->prepared[st->use_file][command_num] = true; } + + return true; } /* @@ -3177,7 +3181,8 @@ sendCommand(CState *st, Command *command) { const char *params[MAX_ARGS]; - prepareCommand(st, st->command); + if (!prepareCommand(st, st->command)) + return false; getQueryParams(&st->variables, command, params); pg_log_debug("client %d sending %s", st->id, command->prepname);