From: Alvaro Herrera Date: Tue, 21 Jun 2022 19:35:26 +0200 Subject: [PATCH v7 3/6] if the queue becomes empty, reset the tail too --- src/interfaces/libpq/fe-exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 4180683194..ed26bab033 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -2988,6 +2988,10 @@ pqCommandQueueAdvance(PGconn *conn) prevquery = conn->cmd_queue_head; conn->cmd_queue_head = conn->cmd_queue_head->next; + /* If the queue is now empty, reset the tail too */ + if (conn->cmd_queue_head == NULL) + conn->cmd_queue_tail = NULL; + /* and make it recyclable */ prevquery->next = NULL; pqRecycleCmdQueueEntry(conn, prevquery); -- 2.30.2 --c6botfw447u3lelj Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v7-0004-add-some-tests-maybe-wrong.patch"