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

Commit686f15e

Browse files
committed
Adjust pgbench so it won't spit up on non-select queries returning
tuples, which is entirely possible with custom scripts (considerRETURNING, EXPLAIN, etc).
1 parent5a7471c commit686f15e

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

‎contrib/pgbench/pgbench.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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 $
33
*
44
* pgbench: a simple benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -243,17 +243,23 @@ discard_response(CState * state)
243243

244244
/* check to see if the SQL result was good */
245245
staticint
246-
check(CState*state,PGresult*res,intn,intgood)
246+
check(CState*state,PGresult*res,intn)
247247
{
248248
CState*st=&state[n];
249249

250-
if (res&&PQresultStatus(res)!=good)
250+
switch (PQresultStatus(res))
251251
{
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);
257263
}
258264
return (0);/* OK */
259265
}
@@ -461,15 +467,10 @@ doCustom(CState * state, int n, int debug)
461467
if (commands[st->state]->type==SQL_COMMAND)
462468
{
463469
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))
470471
{
471-
if (check(state,res,n,PGRES_TUPLES_OK))
472-
return;
472+
PQclear(res);
473+
return;
473474
}
474475
PQclear(res);
475476
discard_response(st);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp