Skip to content

Commit 37c7a7e

Browse files
Use PqMsg_* macros in walsender.c
Oversights in commits f4b54e1, dc21234, and 228c370. Author: Dave Cramer <davecramer@gmail.com> Discussion: https://postgr.es/m/CADK3HH%2BowWVdnbmWH4NHG8%3D%2BkXA_wjsyEVLoY719iJnb%3D%2BtT6A%40mail.gmail.com
1 parent 196063d commit 37c7a7e

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/backend/replication/walsender.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "funcapi.h"
6666
#include "libpq/libpq.h"
6767
#include "libpq/pqformat.h"
68+
#include "libpq/protocol.h"
6869
#include "miscadmin.h"
6970
#include "nodes/replnodes.h"
7071
#include "pgstat.h"
@@ -735,13 +736,13 @@ HandleUploadManifestPacket(StringInfo buf, off_t *offset,
735736

736737
switch (mtype)
737738
{
738-
case 'd': /* CopyData */
739+
case PqMsg_CopyData:
739740
maxmsglen = PQ_LARGE_MESSAGE_LIMIT;
740741
break;
741-
case 'c': /* CopyDone */
742-
case 'f': /* CopyFail */
743-
case 'H': /* Flush */
744-
case 'S': /* Sync */
742+
case PqMsg_CopyDone:
743+
case PqMsg_CopyFail:
744+
case PqMsg_Flush:
745+
case PqMsg_Sync:
745746
maxmsglen = PQ_SMALL_MESSAGE_LIMIT;
746747
break;
747748
default:
@@ -763,19 +764,19 @@ HandleUploadManifestPacket(StringInfo buf, off_t *offset,
763764
/* Process the message */
764765
switch (mtype)
765766
{
766-
case 'd': /* CopyData */
767+
case PqMsg_CopyData:
767768
AppendIncrementalManifestData(ib, buf->data, buf->len);
768769
return true;
769770

770-
case 'c': /* CopyDone */
771+
case PqMsg_CopyDone:
771772
return false;
772773

773-
case 'H': /* Sync */
774-
case 'S': /* Flush */
774+
case PqMsg_Sync:
775+
case PqMsg_Flush:
775776
/* Ignore these while in CopyOut mode as we do elsewhere. */
776777
return true;
777778

778-
case 'f':
779+
case PqMsg_CopyFail:
779780
ereport(ERROR,
780781
(errcode(ERRCODE_QUERY_CANCELED),
781782
errmsg("COPY from stdin failed: %s",
@@ -1569,7 +1570,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
15691570
tmpbuf.data, sizeof(int64));
15701571

15711572
/* output previously gathered data in a CopyData packet */
1572-
pq_putmessage_noblock('d', ctx->out->data, ctx->out->len);
1573+
pq_putmessage_noblock(PqMsg_CopyData, ctx->out->data, ctx->out->len);
15731574

15741575
CHECK_FOR_INTERRUPTS();
15751576

@@ -2305,7 +2306,7 @@ ProcessRepliesIfAny(void)
23052306
case PqMsg_CopyDone:
23062307
if (!streamingDoneSending)
23072308
{
2308-
pq_putmessage_noblock('c', NULL, 0);
2309+
pq_putmessage_noblock(PqMsg_CopyDone, NULL, 0);
23092310
streamingDoneSending = true;
23102311
}
23112312

@@ -2758,7 +2759,7 @@ ProcessStandbyPSRequestMessage(void)
27582759
pq_sendint64(&output_message, GetCurrentTimestamp());
27592760

27602761
/* ... and send it wrapped in CopyData */
2761-
pq_putmessage_noblock('d', output_message.data, output_message.len);
2762+
pq_putmessage_noblock(PqMsg_CopyData, output_message.data, output_message.len);
27622763
}
27632764

27642765
/*
@@ -3306,7 +3307,7 @@ XLogSendPhysical(void)
33063307
wal_segment_close(xlogreader);
33073308

33083309
/* Send CopyDone */
3309-
pq_putmessage_noblock('c', NULL, 0);
3310+
pq_putmessage_noblock(PqMsg_CopyDone, NULL, 0);
33103311
streamingDoneSending = true;
33113312

33123313
WalSndCaughtUp = true;
@@ -3434,7 +3435,7 @@ XLogSendPhysical(void)
34343435
memcpy(&output_message.data[1 + sizeof(int64) + sizeof(int64)],
34353436
tmpbuf.data, sizeof(int64));
34363437

3437-
pq_putmessage_noblock('d', output_message.data, output_message.len);
3438+
pq_putmessage_noblock(PqMsg_CopyData, output_message.data, output_message.len);
34383439

34393440
sentPtr = endptr;
34403441

@@ -4140,7 +4141,7 @@ WalSndKeepalive(bool requestReply, XLogRecPtr writePtr)
41404141
pq_sendbyte(&output_message, requestReply ? 1 : 0);
41414142

41424143
/* ... and send it wrapped in CopyData */
4143-
pq_putmessage_noblock('d', output_message.data, output_message.len);
4144+
pq_putmessage_noblock(PqMsg_CopyData, output_message.data, output_message.len);
41444145

41454146
/* Set local flag */
41464147
if (requestReply)

0 commit comments

Comments
 (0)