Small patch to use pqMsg_Query instead of `Q`

Started by Dave Cramerabout 1 year ago4 messages
#1Dave Cramer
davecramer@gmail.com
1 attachment(s)

Greetings,

Previously we have replaced the use of literal characters with pqMsg*. Not
sure how this one escaped detection.

Patch attached.

Dave Cramer

Attachments:

0001-use-pqMsg_Query-instead-of-Q.patchapplication/octet-stream; name=0001-use-pqMsg_Query-instead-of-Q.patchDownload
From 5b4e68868225b668a077116c5d02d720f180b2fe Mon Sep 17 00:00:00 2001
From: Dave Cramer <davecramer@gmail.com>
Date: Thu, 26 Dec 2024 16:04:19 -0500
Subject: [PATCH] use pqMsg_Query instead of Q Use pqMsg_Terminate in
 documentation instead of X

---
 src/backend/tcop/postgres.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index c01cff9d650..88694bcb302 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -310,7 +310,7 @@ InteractiveBackend(StringInfo inBuf)
 		printf("statement: %s\n", inBuf->data);
 	fflush(stdout);
 
-	return 'Q';
+	return PqMsg_Query;
 }
 
 /*
@@ -4897,7 +4897,7 @@ PostgresMain(const char *dbname, const char *username)
 				break;
 
 				/*
-				 * 'X' means that the frontend is closing down the socket. EOF
+				 * PqMsg_Terminate('X') means that the frontend is closing down the socket. EOF
 				 * means unexpected loss of frontend connection. Either way,
 				 * perform normal shutdown.
 				 */
-- 
2.39.5 (Apple Git-154)

#2Fabrízio de Royes Mello
fabriziomello@gmail.com
In reply to: Dave Cramer (#1)
Re: Small patch to use pqMsg_Query instead of `Q`

On Tue, Jan 7, 2025 at 12:42 PM Dave Cramer <davecramer@gmail.com> wrote:

Greetings,

Previously we have replaced the use of literal characters with pqMsg*. Not
sure how this one escaped detection.

Patch attached.

LGTM... looks like a leftover from f4b54e1e.

Regards,

--
Fabrízio de Royes Mello

#3Nathan Bossart
nathandbossart@gmail.com
In reply to: Fabrízio de Royes Mello (#2)
Re: Small patch to use pqMsg_Query instead of `Q`

On Tue, Jan 07, 2025 at 01:25:31PM -0300, Fabrízio de Royes Mello wrote:

On Tue, Jan 7, 2025 at 12:42 PM Dave Cramer <davecramer@gmail.com> wrote:

Previously we have replaced the use of literal characters with pqMsg*. Not
sure how this one escaped detection.

It's not the first to escape detection, and it probably won't be the
last...

LGTM... looks like a leftover from f4b54e1e.

I'll commit this shortly. I'd argue this falls into the category of
"low-risk fixes," so I'll also plan on back-patching it to v17 (where
protocol.h was first added).

--
nathan

#4Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#3)
Re: Small patch to use pqMsg_Query instead of `Q`

Committed.

--
nathan