aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pgbench/pgbench.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pgbench/pgbench.c')
-rw-r--r--src/bin/pgbench/pgbench.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 42a4e6babc1..596d112d5ba 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -3706,7 +3706,7 @@ threadRun(void *arg)
sock = PQsocket(st->con);
if (sock < 0)
{
- fprintf(stderr, "bad socket: %s\n", strerror(errno));
+ fprintf(stderr, "bad socket: %s", PQerrorMessage(st->con));
goto done;
}
@@ -3770,11 +3770,21 @@ threadRun(void *arg)
Command **commands = sql_script[st->use_file].commands;
int prev_ecnt = st->ecnt;
- if (st->con && (FD_ISSET(PQsocket(st->con), &input_mask)
- || commands[st->state]->type == META_COMMAND))
+ if (st->con)
{
- if (!doCustom(thread, st, &aggs))
- remains--; /* I've aborted */
+ int sock = PQsocket(st->con);
+
+ if (sock < 0)
+ {
+ fprintf(stderr, "bad socket: %s", PQerrorMessage(st->con));
+ goto done;
+ }
+ if (FD_ISSET(sock, &input_mask) ||
+ commands[st->state]->type == META_COMMAND)
+ {
+ if (!doCustom(thread, st, &aggs))
+ remains--; /* I've aborted */
+ }
}
if (st->ecnt > prev_ecnt && commands[st->state]->type == META_COMMAND)