|
1 | 1 | /* |
2 | | - * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.60 2007/01/10 01:18:40 ishii Exp $ |
| 2 | + * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.61 2007/01/22 02:17:30 tgl Exp $ |
3 | 3 | * |
4 | 4 | * pgbench: a simple benchmark program for PostgreSQL |
5 | 5 | * written by Tatsuo Ishii |
@@ -243,17 +243,23 @@ discard_response(CState * state) |
243 | 243 |
|
244 | 244 | /* check to see if the SQL result was good */ |
245 | 245 | staticint |
246 | | -check(CState*state,PGresult*res,intn,intgood) |
| 246 | +check(CState*state,PGresult*res,intn) |
247 | 247 | { |
248 | 248 | CState*st=&state[n]; |
249 | 249 |
|
250 | | -if (res&&PQresultStatus(res)!=good) |
| 250 | +switch (PQresultStatus(res)) |
251 | 251 | { |
252 | | -fprintf(stderr,"Client %d aborted in state %d: %s",n,st->state,PQerrorMessage(st->con)); |
253 | | -remains--;/* I've aborted */ |
254 | | -PQfinish(st->con); |
255 | | -st->con=NULL; |
256 | | -return (-1); |
| 252 | +casePGRES_COMMAND_OK: |
| 253 | +casePGRES_TUPLES_OK: |
| 254 | +/* OK */ |
| 255 | +break; |
| 256 | +default: |
| 257 | +fprintf(stderr,"Client %d aborted in state %d: %s", |
| 258 | +n,st->state,PQerrorMessage(st->con)); |
| 259 | +remains--;/* I've aborted */ |
| 260 | +PQfinish(st->con); |
| 261 | +st->con=NULL; |
| 262 | +return (-1); |
257 | 263 | } |
258 | 264 | return (0);/* OK */ |
259 | 265 | } |
@@ -461,15 +467,10 @@ doCustom(CState * state, int n, int debug) |
461 | 467 | if (commands[st->state]->type==SQL_COMMAND) |
462 | 468 | { |
463 | 469 | res=PQgetResult(st->con); |
464 | | -if (pg_strncasecmp(commands[st->state]->argv[0],"select",6)!=0) |
465 | | -{ |
466 | | -if (check(state,res,n,PGRES_COMMAND_OK)) |
467 | | -return; |
468 | | -} |
469 | | -else |
| 470 | +if (check(state,res,n)) |
470 | 471 | { |
471 | | -if (check(state,res,n,PGRES_TUPLES_OK)) |
472 | | -return; |
| 472 | +PQclear(res); |
| 473 | +return; |
473 | 474 | } |
474 | 475 | PQclear(res); |
475 | 476 | discard_response(st); |
|