0002-Remove-dead-memmove-code-from-pq_recvbuf.patch

application/octet-stream

Filename: 0002-Remove-dead-memmove-code-from-pq_recvbuf.patch
Type: application/octet-stream
Part: 0
Message: Re: [PATCH] Better Performance for PostgreSQL with large INSERTs

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0002
Subject: Remove dead memmove code from pq_recvbuf()
File+
src/backend/libpq/pqcomm.c 0 9
From b93a253e1e10ee0b3f20d3dc89e0300b477c5555 Mon Sep 17 00:00:00 2001
From: Filip Janus <fjanus@redhat.com>
Date: Wed, 26 Nov 2025 15:00:11 +0100
Subject: [PATCH 2/2] Remove dead memmove code from pq_recvbuf()

The memmove block in pq_recvbuf() is unreachable dead code that has
never been executed in practice.

Analysis:
pq_recvbuf() is only called from pq_getbytes() when the condition
PqRecvPointer >= PqRecvLength is true (buffer is empty or exhausted).

However, the memmove is only executed when PqRecvLength > PqRecvPointer
(buffer contains unread data).

These conditions are mutually exclusive:
  - Caller requires: PqRecvPointer >= PqRecvLength
  - memmove requires: PqRecvLength > PqRecvPointer
---
 src/backend/libpq/pqcomm.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index d4bd412b68d..f1c3601be66 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -902,15 +902,6 @@ pq_recvbuf(void)
 {
 	if (PqRecvPointer > 0)
 	{
-		if (PqRecvLength > PqRecvPointer)
-		{
-			/* still some unread data, left-justify it in the buffer */
-			memmove(PqRecvBuffer, PqRecvBuffer + PqRecvPointer,
-					PqRecvLength - PqRecvPointer);
-			PqRecvLength -= PqRecvPointer;
-			PqRecvPointer = 0;
-		}
-		else
 			PqRecvLength = PqRecvPointer = 0;
 	}
 
-- 
2.39.5 (Apple Git-154)