From 6a569ceade530fcbc3f4f18bae003d118239e169 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Tue, 2 Jun 2020 17:48:04 -0700
Subject: [PATCH v2 8/9] inline pq_sendbytes, stop maintaining trailing null
 byte.

Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:
---
 src/include/libpq/pqformat.h | 13 ++++++++++++-
 src/backend/libpq/pqformat.c | 11 -----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/include/libpq/pqformat.h b/src/include/libpq/pqformat.h
index e0dbb783c6a..6af153b7f77 100644
--- a/src/include/libpq/pqformat.h
+++ b/src/include/libpq/pqformat.h
@@ -22,7 +22,6 @@ extern void pq_beginmessage_reuse(StringInfo buf, char msgtype);
 extern void pq_endmessage(StringInfo buf);
 extern void pq_endmessage_reuse(StringInfo buf);
 
-extern void pq_sendbytes(StringInfo buf, const char *data, int datalen);
 extern void pq_sendcountedtext(StringInfo buf, const char *str, int slen,
 							   bool countincludesself);
 extern void pq_sendtext(StringInfo buf, const char *str, int slen);
@@ -215,6 +214,18 @@ pq_sendbyte(StringInfo buf, uint8 byt)
 	pq_sendint8(buf, byt);
 }
 
+static inline void
+pq_sendbytes(StringInfo buf, const char *data, int datalen)
+{
+	/*
+	 * FIXME: used to say:
+	 * use variant that maintains a trailing null-byte, out of caution but
+	 * that doesn't make much sense to me, and proves to be a performance
+	 * issue.
+	 */
+	appendBinaryStringInfoNT(buf, data, datalen);
+}
+
 /*
  * Append a binary integer to a StringInfo buffer
  *
diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c
index 347a0aa697a..377335a94ae 100644
--- a/src/backend/libpq/pqformat.c
+++ b/src/backend/libpq/pqformat.c
@@ -117,17 +117,6 @@ pq_beginmessage_reuse(StringInfo buf, char msgtype)
 	buf->cursor = msgtype;
 }
 
-/* --------------------------------
- *		pq_sendbytes	- append raw data to a StringInfo buffer
- * --------------------------------
- */
-void
-pq_sendbytes(StringInfo buf, const char *data, int datalen)
-{
-	/* use variant that maintains a trailing null-byte, out of caution */
-	appendBinaryStringInfo(buf, data, datalen);
-}
-
 /* --------------------------------
  *		pq_sendcountedtext - append a counted text string (with character set conversion)
  *
-- 
2.25.0.114.g5b0ca878e0

