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

Commit337be37

Browse files
committed
pgbench: consolidate a few PQfinish calls.
Author: Doug RadyDiscussion:https://postgr.es/m/6323D83C-9FDA-4EE1-B0ED-6971E585066A@amazon.com
1 parentd79e7e9 commit337be37

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ static void pgbench_error(const char *fmt,...) pg_attribute_printf(1, 2);
502502
staticvoidaddScript(ParsedScriptscript);
503503
staticvoid*threadRun(void*arg);
504504
staticvoidsetalarm(intseconds);
505+
staticvoidfinishCon(CState*st);
505506

506507

507508
/* callback functions for our flex lexer */
@@ -2982,8 +2983,7 @@ doCustom(TState *thread, CState *st, StatsData *agg)
29822983

29832984
if (is_connect)
29842985
{
2985-
PQfinish(st->con);
2986-
st->con=NULL;
2986+
finishCon(st);
29872987
INSTR_TIME_SET_ZERO(now);
29882988
}
29892989

@@ -3020,11 +3020,7 @@ doCustom(TState *thread, CState *st, StatsData *agg)
30203020
*/
30213021
caseCSTATE_ABORTED:
30223022
caseCSTATE_FINISHED:
3023-
if (st->con!=NULL)
3024-
{
3025-
PQfinish(st->con);
3026-
st->con=NULL;
3027-
}
3023+
finishCon(st);
30283024
return;
30293025
}
30303026
}
@@ -3172,13 +3168,7 @@ disconnect_all(CState *state, int length)
31723168
inti;
31733169

31743170
for (i=0;i<length;i++)
3175-
{
3176-
if (state[i].con)
3177-
{
3178-
PQfinish(state[i].con);
3179-
state[i].con=NULL;
3180-
}
3181-
}
3171+
finishCon(&state[i]);
31823172
}
31833173

31843174
/*
@@ -5266,8 +5256,7 @@ threadRun(void *arg)
52665256
{
52675257
/* interrupt client that has not started a transaction */
52685258
st->state=CSTATE_FINISHED;
5269-
PQfinish(st->con);
5270-
st->con=NULL;
5259+
finishCon(st);
52715260
remains--;
52725261
}
52735262
elseif (st->state==CSTATE_SLEEP||st->state==CSTATE_THROTTLE)
@@ -5547,6 +5536,16 @@ threadRun(void *arg)
55475536
returnNULL;
55485537
}
55495538

5539+
staticvoid
5540+
finishCon(CState*st)
5541+
{
5542+
if (st->con!=NULL)
5543+
{
5544+
PQfinish(st->con);
5545+
st->con=NULL;
5546+
}
5547+
}
5548+
55505549
/*
55515550
* Support for duration option: set timer_exceeded after so many seconds.
55525551
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp