Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 47211af

Browse files
committed
Fix "pg_bench -C -M prepared".
This didn't work because when we dropped and re-established a database connection, we did not bother to reset session-specific state such as the statements-are-prepared flags. The st->prepared[] array certainly needs to be flushed, and I cleared a couple of other fields as well that couldn't possibly retain meaningful state for a new connection. In passing, fix some bogus comments and strange field order choices. Per report from Robins Tharakan.
1 parent 5db5146 commit 47211af

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/pgbench/pgbench.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ typedef struct
230230
int id; /* client No. */
231231
int state; /* state No. */
232232
bool listen; /* whether an async query has been sent */
233-
bool is_throttled; /* whether transaction throttling is done */
234233
bool sleeping; /* whether the client is napping */
235234
bool throttling; /* whether nap is for throttling */
235+
bool is_throttled; /* whether transaction throttling is done */
236236
Variable *variables; /* array of variable definitions */
237237
int nvariables;
238238
int64 txn_scheduled; /* scheduled start time of transaction (usec) */
@@ -1522,6 +1522,13 @@ doCustom(TState *thread, CState *st, StatsData *agg)
15221522
}
15231523
INSTR_TIME_SET_CURRENT(end);
15241524
INSTR_TIME_ACCUM_DIFF(thread->conn_time, end, start);
1525+
1526+
/* Reset session-local state */
1527+
st->listen = false;
1528+
st->sleeping = false;
1529+
st->throttling = false;
1530+
st->is_throttled = false;
1531+
memset(st->prepared, 0, sizeof(st->prepared));
15251532
}
15261533

15271534
/*

0 commit comments

Comments
 (0)