Adjust pgbench so it won't spit up on non-select queries returning
tuples, which is entirely possible with custom scripts (consider RETURNING, EXPLAIN, etc).
This commit is contained in:
parent
5a7471c307
commit
686f15e39e
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.60 2007/01/10 01:18:40 ishii Exp $
|
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.61 2007/01/22 02:17:30 tgl Exp $
|
||||||
*
|
*
|
||||||
* pgbench: a simple benchmark program for PostgreSQL
|
* pgbench: a simple benchmark program for PostgreSQL
|
||||||
* written by Tatsuo Ishii
|
* written by Tatsuo Ishii
|
||||||
@ -243,13 +243,19 @@ discard_response(CState * state)
|
|||||||
|
|
||||||
/* check to see if the SQL result was good */
|
/* check to see if the SQL result was good */
|
||||||
static int
|
static int
|
||||||
check(CState * state, PGresult *res, int n, int good)
|
check(CState *state, PGresult *res, int n)
|
||||||
{
|
{
|
||||||
CState *st = &state[n];
|
CState *st = &state[n];
|
||||||
|
|
||||||
if (res && PQresultStatus(res) != good)
|
switch (PQresultStatus(res))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Client %d aborted in state %d: %s", n, st->state, PQerrorMessage(st->con));
|
case PGRES_COMMAND_OK:
|
||||||
|
case PGRES_TUPLES_OK:
|
||||||
|
/* OK */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Client %d aborted in state %d: %s",
|
||||||
|
n, st->state, PQerrorMessage(st->con));
|
||||||
remains--; /* I've aborted */
|
remains--; /* I've aborted */
|
||||||
PQfinish(st->con);
|
PQfinish(st->con);
|
||||||
st->con = NULL;
|
st->con = NULL;
|
||||||
@ -461,14 +467,9 @@ top:
|
|||||||
if (commands[st->state]->type == SQL_COMMAND)
|
if (commands[st->state]->type == SQL_COMMAND)
|
||||||
{
|
{
|
||||||
res = PQgetResult(st->con);
|
res = PQgetResult(st->con);
|
||||||
if (pg_strncasecmp(commands[st->state]->argv[0], "select", 6) != 0)
|
if (check(state, res, n))
|
||||||
{
|
{
|
||||||
if (check(state, res, n, PGRES_COMMAND_OK))
|
PQclear(res);
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (check(state, res, n, PGRES_TUPLES_OK))
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user