aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2024-07-17 10:51:00 -0500
committerNathan Bossart <nathan@postgresql.org>2024-07-17 10:51:00 -0500
commita99cc6c6b4bf083d72fb1e8adfb665a449b7a37f (patch)
tree65d23b9e0ed431f8ad963027dd038afe40be40cf
parentf2a0d5808c246e556efbe3df0fb2be7841e3c988 (diff)
downloadpostgresql-a99cc6c6b4bf083d72fb1e8adfb665a449b7a37f.tar.gz
postgresql-a99cc6c6b4bf083d72fb1e8adfb665a449b7a37f.zip
Use PqMsg_* macros in more places.
Commit f4b54e1ed9, which introduced macros for protocol characters, missed updating a few places. It also did not introduce macros for messages sent from parallel workers to their leader processes. This commit adds a new section in protocol.h for those. Author: Aleksander Alekseev Discussion: https://postgr.es/m/CAJ7c6TNTd09AZq8tGaHS3LDyH_CCnpv0oOz2wN1dGe8zekxrdQ%40mail.gmail.com Backpatch-through: 17
-rw-r--r--src/backend/access/common/printtup.c5
-rw-r--r--src/backend/commands/explain.c3
-rw-r--r--src/backend/replication/walsender.c2
-rw-r--r--src/backend/tcop/postgres.c3
-rw-r--r--src/backend/utils/activity/backend_progress.c4
-rw-r--r--src/include/libpq/protocol.h4
6 files changed, 13 insertions, 8 deletions
diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index f2d5ca14fee..c78cc393087 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -17,6 +17,7 @@
#include "access/printtup.h"
#include "libpq/pqformat.h"
+#include "libpq/protocol.h"
#include "tcop/pquery.h"
#include "utils/lsyscache.h"
#include "utils/memdebug.h"
@@ -170,7 +171,7 @@ SendRowDescriptionMessage(StringInfo buf, TupleDesc typeinfo,
ListCell *tlist_item = list_head(targetlist);
/* tuple descriptor message type */
- pq_beginmessage_reuse(buf, 'T');
+ pq_beginmessage_reuse(buf, PqMsg_RowDescription);
/* # of attrs in tuples */
pq_sendint16(buf, natts);
@@ -322,7 +323,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
/*
* Prepare a DataRow message (note buffer is in per-query context)
*/
- pq_beginmessage_reuse(buf, 'D');
+ pq_beginmessage_reuse(buf, PqMsg_DataRow);
pq_sendint16(buf, natts);
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 118db12903c..5771aabf40a 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -21,6 +21,7 @@
#include "foreign/fdwapi.h"
#include "jit/jit.h"
#include "libpq/pqformat.h"
+#include "libpq/protocol.h"
#include "nodes/extensible.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
@@ -5497,7 +5498,7 @@ serializeAnalyzeReceive(TupleTableSlot *slot, DestReceiver *self)
* Note that we fill a StringInfo buffer the same as printtup() does, so
* as to capture the costs of manipulating the strings accurately.
*/
- pq_beginmessage_reuse(buf, 'D');
+ pq_beginmessage_reuse(buf, PqMsg_DataRow);
pq_sendint16(buf, natts);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d1a9ec900f..ca205594bd0 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -695,7 +695,7 @@ UploadManifest(void)
ib = CreateIncrementalBackupInfo(mcxt);
/* Send a CopyInResponse message */
- pq_beginmessage(&buf, 'G');
+ pq_beginmessage(&buf, PqMsg_CopyInResponse);
pq_sendbyte(&buf, 0);
pq_sendint16(&buf, 0);
pq_endmessage_reuse(&buf);
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index e39c6804a73..ea517f4b9bb 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2651,8 +2651,7 @@ exec_describe_statement_message(const char *stmt_name)
/*
* First describe the parameters...
*/
- pq_beginmessage_reuse(&row_description_buf, 't'); /* parameter description
- * message type */
+ pq_beginmessage_reuse(&row_description_buf, PqMsg_ParameterDescription);
pq_sendint16(&row_description_buf, psrc->num_params);
for (int i = 0; i < psrc->num_params; i++)
diff --git a/src/backend/utils/activity/backend_progress.c b/src/backend/utils/activity/backend_progress.c
index bfb9b7704b1..c78c5eb5076 100644
--- a/src/backend/utils/activity/backend_progress.c
+++ b/src/backend/utils/activity/backend_progress.c
@@ -92,7 +92,7 @@ void
pgstat_progress_parallel_incr_param(int index, int64 incr)
{
/*
- * Parallel workers notify a leader through a 'P' protocol message to
+ * Parallel workers notify a leader through a PqMsg_Progress message to
* update progress, passing the progress index and incremented value.
* Leaders can just call pgstat_progress_incr_param directly.
*/
@@ -102,7 +102,7 @@ pgstat_progress_parallel_incr_param(int index, int64 incr)
initStringInfo(&progress_message);
- pq_beginmessage(&progress_message, 'P');
+ pq_beginmessage(&progress_message, PqMsg_Progress);
pq_sendint32(&progress_message, index);
pq_sendint64(&progress_message, incr);
pq_endmessage(&progress_message);
diff --git a/src/include/libpq/protocol.h b/src/include/libpq/protocol.h
index 4b8d4403656..b71add1ec15 100644
--- a/src/include/libpq/protocol.h
+++ b/src/include/libpq/protocol.h
@@ -65,6 +65,10 @@
#define PqMsg_CopyData 'd'
+/* These are the codes sent by parallel workers to leader processes. */
+#define PqMsg_Progress 'P'
+
+
/* These are the authentication request codes sent by the backend. */
#define AUTH_REQ_OK 0 /* User is authenticated */