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

Commit 9390959

Browse files
committed
libpq: drop pending pipelined commands in pqDropConnection().
The original coding did this in pqDropServerData(), which seems fairly backwards. Pending commands are more like already-queued output data, which is dropped in pqDropConnection(). Moving the operation means that we clear the command queue immediately upon detecting connection drop, which improves the sanity of subsequent behavior. In particular this eliminates duplicated error message text as a consequence of code added in b15f254, which supposed that a nonempty command queue must mean the prior operation is still active. There might be an argument for backpatching this to v14; but as with b15f254, I'm unsure about interactions with 618c167. For now, given the lack of complaints about v14's behavior, leave it alone. Per report from Peter Eisentraut. Discussion: https://postgr.es/m/de57761c-b99b-3435-b0a6-474c72b1149a@enterprisedb.com
1 parent b5f4422 commit 9390959

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/interfaces/libpq/fe-connect.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ static int connectDBStart(PGconn *conn);
377377
static int connectDBComplete(PGconn *conn);
378378
static PGPing internal_ping(PGconn *conn);
379379
static PGconn *makeEmptyPGconn(void);
380+
static void pqFreeCommandQueue(PGcmdQueueEntry *queue);
380381
static bool fillPGconn(PGconn *conn, PQconninfoOption *connOptions);
381382
static void freePGconn(PGconn *conn);
382383
static void closePGconn(PGconn *conn);
@@ -462,6 +463,12 @@ pqDropConnection(PGconn *conn, bool flushInput)
462463
/* Always discard any unsent data */
463464
conn->outCount = 0;
464465

466+
/* Likewise, discard any pending pipelined commands */
467+
pqFreeCommandQueue(conn->cmd_queue_head);
468+
conn->cmd_queue_head = conn->cmd_queue_tail = NULL;
469+
pqFreeCommandQueue(conn->cmd_queue_recycle);
470+
conn->cmd_queue_recycle = NULL;
471+
465472
/* Free authentication/encryption state */
466473
#ifdef ENABLE_GSS
467474
{
@@ -569,12 +576,6 @@ pqDropServerData(PGconn *conn)
569576
}
570577
conn->notifyHead = conn->notifyTail = NULL;
571578

572-
pqFreeCommandQueue(conn->cmd_queue_head);
573-
conn->cmd_queue_head = conn->cmd_queue_tail = NULL;
574-
575-
pqFreeCommandQueue(conn->cmd_queue_recycle);
576-
conn->cmd_queue_recycle = NULL;
577-
578579
/* Reset ParameterStatus data, as well as variables deduced from it */
579580
pstatus = conn->pstatus;
580581
while (pstatus != NULL)

0 commit comments

Comments
 (0)