Skip to content

Commit a99cc6c

Browse files
Use PqMsg_* macros in more places.
Commit f4b54e1, 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
1 parent f2a0d58 commit a99cc6c

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

src/backend/access/common/printtup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "access/printtup.h"
1919
#include "libpq/pqformat.h"
20+
#include "libpq/protocol.h"
2021
#include "tcop/pquery.h"
2122
#include "utils/lsyscache.h"
2223
#include "utils/memdebug.h"
@@ -170,7 +171,7 @@ SendRowDescriptionMessage(StringInfo buf, TupleDesc typeinfo,
170171
ListCell *tlist_item = list_head(targetlist);
171172

172173
/* tuple descriptor message type */
173-
pq_beginmessage_reuse(buf, 'T');
174+
pq_beginmessage_reuse(buf, PqMsg_RowDescription);
174175
/* # of attrs in tuples */
175176
pq_sendint16(buf, natts);
176177

@@ -322,7 +323,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
322323
/*
323324
* Prepare a DataRow message (note buffer is in per-query context)
324325
*/
325-
pq_beginmessage_reuse(buf, 'D');
326+
pq_beginmessage_reuse(buf, PqMsg_DataRow);
326327

327328
pq_sendint16(buf, natts);
328329

src/backend/commands/explain.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "foreign/fdwapi.h"
2222
#include "jit/jit.h"
2323
#include "libpq/pqformat.h"
24+
#include "libpq/protocol.h"
2425
#include "nodes/extensible.h"
2526
#include "nodes/makefuncs.h"
2627
#include "nodes/nodeFuncs.h"
@@ -5497,7 +5498,7 @@ serializeAnalyzeReceive(TupleTableSlot *slot, DestReceiver *self)
54975498
* Note that we fill a StringInfo buffer the same as printtup() does, so
54985499
* as to capture the costs of manipulating the strings accurately.
54995500
*/
5500-
pq_beginmessage_reuse(buf, 'D');
5501+
pq_beginmessage_reuse(buf, PqMsg_DataRow);
55015502

55025503
pq_sendint16(buf, natts);
55035504

src/backend/replication/walsender.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ UploadManifest(void)
695695
ib = CreateIncrementalBackupInfo(mcxt);
696696

697697
/* Send a CopyInResponse message */
698-
pq_beginmessage(&buf, 'G');
698+
pq_beginmessage(&buf, PqMsg_CopyInResponse);
699699
pq_sendbyte(&buf, 0);
700700
pq_sendint16(&buf, 0);
701701
pq_endmessage_reuse(&buf);

src/backend/tcop/postgres.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,8 +2651,7 @@ exec_describe_statement_message(const char *stmt_name)
26512651
/*
26522652
* First describe the parameters...
26532653
*/
2654-
pq_beginmessage_reuse(&row_description_buf, 't'); /* parameter description
2655-
* message type */
2654+
pq_beginmessage_reuse(&row_description_buf, PqMsg_ParameterDescription);
26562655
pq_sendint16(&row_description_buf, psrc->num_params);
26572656

26582657
for (int i = 0; i < psrc->num_params; i++)

src/backend/utils/activity/backend_progress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void
9292
pgstat_progress_parallel_incr_param(int index, int64 incr)
9393
{
9494
/*
95-
* Parallel workers notify a leader through a 'P' protocol message to
95+
* Parallel workers notify a leader through a PqMsg_Progress message to
9696
* update progress, passing the progress index and incremented value.
9797
* Leaders can just call pgstat_progress_incr_param directly.
9898
*/
@@ -102,7 +102,7 @@ pgstat_progress_parallel_incr_param(int index, int64 incr)
102102

103103
initStringInfo(&progress_message);
104104

105-
pq_beginmessage(&progress_message, 'P');
105+
pq_beginmessage(&progress_message, PqMsg_Progress);
106106
pq_sendint32(&progress_message, index);
107107
pq_sendint64(&progress_message, incr);
108108
pq_endmessage(&progress_message);

src/include/libpq/protocol.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
#define PqMsg_CopyData 'd'
6666

6767

68+
/* These are the codes sent by parallel workers to leader processes. */
69+
#define PqMsg_Progress 'P'
70+
71+
6872
/* These are the authentication request codes sent by the backend. */
6973

7074
#define AUTH_REQ_OK 0 /* User is authenticated */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy