From d14edffd894ebb8066dcd4e2ccd7db5a4c4541ae Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <jelte.fennema@microsoft.com>
Date: Tue, 7 Nov 2023 10:26:10 +0100
Subject: [PATCH v1] Call pqPipelineFlush from PQsendFlushRequest

In pipeline mode after queuing a message to be sent we would flush the
buffer if the size of the buffer passed some treshold. The only message
type that we didn't do that for was the Flush message. This addresses
that oversight.
---
 src/interfaces/libpq/fe-exec.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index c6d80ec3968..04610ccf5e8 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -3316,6 +3316,14 @@ PQsendFlushRequest(PGconn *conn)
 		return 0;
 	}
 
+	/*
+	 * Give the data a push (in pipeline mode, only if we're past the size
+	 * threshold).  In nonblock mode, don't complain if we're unable to send
+	 * it all; PQgetResult() will do any additional flushing needed.
+	 */
+	if (pqPipelineFlush(conn) < 0)
+		return 0;
+
 	return 1;
 }
 

base-commit: 3c551ebede46194237f82062b54b92e474b5c743
-- 
2.34.1

