From e344f61f7706c5342c1533559e38c41e0041ffb7 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Tue, 10 Oct 2017 17:26:40 -0700
Subject: [PATCH 6/6] Replace remaining uses of pq_sendint with pq_sendintXX.

pq_sendint() remains, so extension code doesn't unnecessarily break.

Author: Andres Freund
Discussion: https://postgr.es/m/20170914063418.sckdzgjfrsbekae4@alap3.anarazel.de
---
 contrib/hstore/hstore_io.c              |  8 +--
 src/backend/access/common/printsimple.c | 18 +++----
 src/backend/access/common/printtup.c    | 16 +++---
 src/backend/access/transam/parallel.c   |  4 +-
 src/backend/commands/async.c            |  2 +-
 src/backend/commands/copy.c             |  8 +--
 src/backend/libpq/auth.c                |  2 +-
 src/backend/replication/basebackup.c    | 86 ++++++++++++++++-----------------
 src/backend/replication/logical/proto.c | 20 ++++----
 src/backend/replication/walreceiver.c   |  8 +--
 src/backend/replication/walsender.c     | 36 +++++++-------
 src/backend/tcop/fastpath.c             |  4 +-
 src/backend/tcop/postgres.c             |  8 +--
 src/backend/utils/adt/arrayfuncs.c      | 14 +++---
 src/backend/utils/adt/date.c            |  4 +-
 src/backend/utils/adt/geo_ops.c         |  4 +-
 src/backend/utils/adt/int.c             |  4 +-
 src/backend/utils/adt/jsonb.c           |  2 +-
 src/backend/utils/adt/nabstime.c        | 10 ++--
 src/backend/utils/adt/numeric.c         | 14 +++---
 src/backend/utils/adt/oid.c             |  2 +-
 src/backend/utils/adt/rangetypes.c      |  4 +-
 src/backend/utils/adt/rowtypes.c        |  8 +--
 src/backend/utils/adt/tid.c             |  6 +--
 src/backend/utils/adt/timestamp.c       |  4 +-
 src/backend/utils/adt/tsquery.c         | 13 +++--
 src/backend/utils/adt/tsvector.c        |  6 +--
 src/backend/utils/adt/txid.c            |  2 +-
 src/backend/utils/adt/varbit.c          |  2 +-
 src/backend/utils/adt/xid.c             |  4 +-
 30 files changed, 160 insertions(+), 163 deletions(-)

diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
index 6363c321c5d..d8284012d0b 100644
--- a/contrib/hstore/hstore_io.c
+++ b/contrib/hstore/hstore_io.c
@@ -1207,23 +1207,23 @@ hstore_send(PG_FUNCTION_ARGS)
 
 	pq_begintypsend(&buf);
 
-	pq_sendint(&buf, count, 4);
+	pq_sendint32(&buf, count);
 
 	for (i = 0; i < count; i++)
 	{
 		int32		keylen = HSTORE_KEYLEN(entries, i);
 
-		pq_sendint(&buf, keylen, 4);
+		pq_sendint32(&buf, keylen);
 		pq_sendtext(&buf, HSTORE_KEY(entries, base, i), keylen);
 		if (HSTORE_VALISNULL(entries, i))
 		{
-			pq_sendint(&buf, -1, 4);
+			pq_sendint32(&buf, -1);
 		}
 		else
 		{
 			int32		vallen = HSTORE_VALLEN(entries, i);
 
-			pq_sendint(&buf, vallen, 4);
+			pq_sendint32(&buf, vallen);
 			pq_sendtext(&buf, HSTORE_VAL(entries, base, i), vallen);
 		}
 	}
diff --git a/src/backend/access/common/printsimple.c b/src/backend/access/common/printsimple.c
index b3e9a26b032..872de7c3f44 100644
--- a/src/backend/access/common/printsimple.c
+++ b/src/backend/access/common/printsimple.c
@@ -34,19 +34,19 @@ printsimple_startup(DestReceiver *self, int operation, TupleDesc tupdesc)
 	int			i;
 
 	pq_beginmessage(&buf, 'T'); /* RowDescription */
-	pq_sendint(&buf, tupdesc->natts, 2);
+	pq_sendint16(&buf, tupdesc->natts);
 
 	for (i = 0; i < tupdesc->natts; ++i)
 	{
 		Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
 
 		pq_sendstring(&buf, NameStr(attr->attname));
-		pq_sendint(&buf, 0, 4); /* table oid */
-		pq_sendint(&buf, 0, 2); /* attnum */
-		pq_sendint(&buf, (int) attr->atttypid, 4);
-		pq_sendint(&buf, attr->attlen, 2);
-		pq_sendint(&buf, attr->atttypmod, 4);
-		pq_sendint(&buf, 0, 2); /* format code */
+		pq_sendint32(&buf, 0); /* table oid */
+		pq_sendint16(&buf, 0); /* attnum */
+		pq_sendint32(&buf, (int) attr->atttypid);
+		pq_sendint16(&buf, attr->attlen);
+		pq_sendint32(&buf, attr->atttypmod);
+		pq_sendint16(&buf, 0); /* format code */
 	}
 
 	pq_endmessage(&buf);
@@ -67,7 +67,7 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
 
 	/* Prepare and send message */
 	pq_beginmessage(&buf, 'D');
-	pq_sendint(&buf, tupdesc->natts, 2);
+	pq_sendint16(&buf, tupdesc->natts);
 
 	for (i = 0; i < tupdesc->natts; ++i)
 	{
@@ -76,7 +76,7 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
 
 		if (slot->tts_isnull[i])
 		{
-			pq_sendint(&buf, -1, 4);
+			pq_sendint32(&buf, -1);
 			continue;
 		}
 
diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index abe0426a23b..e8f98016036 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -393,7 +393,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
 	 */
 	pq_beginmessage_reuse(buf, 'D');
 
-	pq_sendint(buf, natts, 2);
+	pq_sendint16(buf, natts);
 
 	/*
 	 * send the attributes of this tuple
@@ -405,7 +405,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
 
 		if (slot->tts_isnull[i])
 		{
-			pq_sendint(buf, -1, 4);
+			pq_sendint32(buf, -1);
 			continue;
 		}
 
@@ -434,7 +434,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
 			bytea	   *outputbytes;
 
 			outputbytes = SendFunctionCall(&thisState->finfo, attr);
-			pq_sendint(buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
+			pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ);
 			pq_sendbytes(buf, VARDATA(outputbytes),
 						 VARSIZE(outputbytes) - VARHDRSZ);
 		}
@@ -492,13 +492,13 @@ printtup_20(TupleTableSlot *slot, DestReceiver *self)
 		k >>= 1;
 		if (k == 0)				/* end of byte? */
 		{
-			pq_sendint(buf, j, 1);
+			pq_sendint8(buf, j);
 			j = 0;
 			k = 1 << 7;
 		}
 	}
 	if (k != (1 << 7))			/* flush last partial byte */
-		pq_sendint(buf, j, 1);
+		pq_sendint8(buf, j);
 
 	/*
 	 * send the attributes of this tuple
@@ -677,13 +677,13 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self)
 		k >>= 1;
 		if (k == 0)				/* end of byte? */
 		{
-			pq_sendint(buf, j, 1);
+			pq_sendint8(buf, j);
 			j = 0;
 			k = 1 << 7;
 		}
 	}
 	if (k != (1 << 7))			/* flush last partial byte */
-		pq_sendint(buf, j, 1);
+		pq_sendint8(buf, j);
 
 	/*
 	 * send the attributes of this tuple
@@ -700,7 +700,7 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self)
 		Assert(thisState->format == 1);
 
 		outputbytes = SendFunctionCall(&thisState->finfo, attr);
-		pq_sendint(buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
+		pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ);
 		pq_sendbytes(buf, VARDATA(outputbytes),
 					 VARSIZE(outputbytes) - VARHDRSZ);
 	}
diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index c6f7b7af0e1..d6830507330 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -1030,8 +1030,8 @@ ParallelWorkerMain(Datum main_arg)
 	 * in this case.
 	 */
 	pq_beginmessage(&msgbuf, 'K');
-	pq_sendint(&msgbuf, (int32) MyProcPid, sizeof(int32));
-	pq_sendint(&msgbuf, (int32) MyCancelKey, sizeof(int32));
+	pq_sendint32(&msgbuf, (int32) MyProcPid);
+	pq_sendint32(&msgbuf, (int32) MyCancelKey);
 	pq_endmessage(&msgbuf);
 
 	/*
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index bacc08eb84f..cbc1dd6db48 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2081,7 +2081,7 @@ NotifyMyFrontEnd(const char *channel, const char *payload, int32 srcPid)
 		StringInfoData buf;
 
 		pq_beginmessage(&buf, 'A');
-		pq_sendint(&buf, srcPid, sizeof(int32));
+		pq_sendint32(&buf, srcPid);
 		pq_sendstring(&buf, channel);
 		if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
 			pq_sendstring(&buf, payload);
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index e87588040fa..64550f9c680 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -357,9 +357,9 @@ SendCopyBegin(CopyState cstate)
 
 		pq_beginmessage(&buf, 'H');
 		pq_sendbyte(&buf, format);	/* overall format */
-		pq_sendint(&buf, natts, 2);
+		pq_sendint16(&buf, natts);
 		for (i = 0; i < natts; i++)
-			pq_sendint(&buf, format, 2);	/* per-column formats */
+			pq_sendint16(&buf, format);	/* per-column formats */
 		pq_endmessage(&buf);
 		cstate->copy_dest = COPY_NEW_FE;
 	}
@@ -390,9 +390,9 @@ ReceiveCopyBegin(CopyState cstate)
 
 		pq_beginmessage(&buf, 'G');
 		pq_sendbyte(&buf, format);	/* overall format */
-		pq_sendint(&buf, natts, 2);
+		pq_sendint16(&buf, natts);
 		for (i = 0; i < natts; i++)
-			pq_sendint(&buf, format, 2);	/* per-column formats */
+			pq_sendint16(&buf, format);	/* per-column formats */
 		pq_endmessage(&buf);
 		cstate->copy_dest = COPY_NEW_FE;
 		cstate->fe_msgbuf = makeStringInfo();
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index 480e344eb3a..3b3a932a7d8 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -613,7 +613,7 @@ sendAuthRequest(Port *port, AuthRequest areq, char *extradata, int extralen)
 	CHECK_FOR_INTERRUPTS();
 
 	pq_beginmessage(&buf, 'R');
-	pq_sendint(&buf, (int32) areq, sizeof(int32));
+	pq_sendint32(&buf, (int32) areq);
 	if (extralen > 0)
 		pq_sendbytes(&buf, extradata, extralen);
 
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index c3b9bddc8fe..75029b0def9 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -274,7 +274,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
 			/* Send CopyOutResponse message */
 			pq_beginmessage(&buf, 'H');
 			pq_sendbyte(&buf, 0);	/* overall format */
-			pq_sendint(&buf, 0, 2); /* natts */
+			pq_sendint16(&buf, 0); /* natts */
 			pq_endmessage(&buf);
 
 			if (ti->path == NULL)
@@ -722,7 +722,7 @@ send_int8_string(StringInfoData *buf, int64 intval)
 	char		is[32];
 
 	sprintf(is, INT64_FORMAT, intval);
-	pq_sendint(buf, strlen(is), 4);
+	pq_sendint32(buf, strlen(is));
 	pq_sendbytes(buf, is, strlen(is));
 }
 
@@ -734,34 +734,34 @@ SendBackupHeader(List *tablespaces)
 
 	/* Construct and send the directory information */
 	pq_beginmessage(&buf, 'T'); /* RowDescription */
-	pq_sendint(&buf, 3, 2);		/* 3 fields */
+	pq_sendint16(&buf, 3);		/* 3 fields */
 
 	/* First field - spcoid */
 	pq_sendstring(&buf, "spcoid");
-	pq_sendint(&buf, 0, 4);		/* table oid */
-	pq_sendint(&buf, 0, 2);		/* attnum */
-	pq_sendint(&buf, OIDOID, 4);	/* type oid */
-	pq_sendint(&buf, 4, 2);		/* typlen */
-	pq_sendint(&buf, 0, 4);		/* typmod */
-	pq_sendint(&buf, 0, 2);		/* format code */
+	pq_sendint32(&buf, 0);		/* table oid */
+	pq_sendint16(&buf, 0);		/* attnum */
+	pq_sendint32(&buf, OIDOID);	/* type oid */
+	pq_sendint16(&buf, 4);		/* typlen */
+	pq_sendint32(&buf, 0);		/* typmod */
+	pq_sendint16(&buf, 0);		/* format code */
 
 	/* Second field - spcpath */
 	pq_sendstring(&buf, "spclocation");
-	pq_sendint(&buf, 0, 4);
-	pq_sendint(&buf, 0, 2);
-	pq_sendint(&buf, TEXTOID, 4);
-	pq_sendint(&buf, -1, 2);
-	pq_sendint(&buf, 0, 4);
-	pq_sendint(&buf, 0, 2);
+	pq_sendint32(&buf, 0);
+	pq_sendint16(&buf, 0);
+	pq_sendint32(&buf, TEXTOID);
+	pq_sendint16(&buf, -1);
+	pq_sendint32(&buf, 0);
+	pq_sendint16(&buf, 0);
 
 	/* Third field - size */
 	pq_sendstring(&buf, "size");
-	pq_sendint(&buf, 0, 4);
-	pq_sendint(&buf, 0, 2);
-	pq_sendint(&buf, INT8OID, 4);
-	pq_sendint(&buf, 8, 2);
-	pq_sendint(&buf, 0, 4);
-	pq_sendint(&buf, 0, 2);
+	pq_sendint32(&buf, 0);
+	pq_sendint16(&buf, 0);
+	pq_sendint32(&buf, INT8OID);
+	pq_sendint16(&buf, 8);
+	pq_sendint32(&buf, 0);
+	pq_sendint16(&buf, 0);
 	pq_endmessage(&buf);
 
 	foreach(lc, tablespaces)
@@ -770,28 +770,28 @@ SendBackupHeader(List *tablespaces)
 
 		/* Send one datarow message */
 		pq_beginmessage(&buf, 'D');
-		pq_sendint(&buf, 3, 2); /* number of columns */
+		pq_sendint16(&buf, 3); /* number of columns */
 		if (ti->path == NULL)
 		{
-			pq_sendint(&buf, -1, 4);	/* Length = -1 ==> NULL */
-			pq_sendint(&buf, -1, 4);
+			pq_sendint32(&buf, -1);	/* Length = -1 ==> NULL */
+			pq_sendint32(&buf, -1);
 		}
 		else
 		{
 			Size		len;
 
 			len = strlen(ti->oid);
-			pq_sendint(&buf, len, 4);
+			pq_sendint32(&buf, len);
 			pq_sendbytes(&buf, ti->oid, len);
 
 			len = strlen(ti->path);
-			pq_sendint(&buf, len, 4);
+			pq_sendint32(&buf, len);
 			pq_sendbytes(&buf, ti->path, len);
 		}
 		if (ti->size >= 0)
 			send_int8_string(&buf, ti->size / 1024);
 		else
-			pq_sendint(&buf, -1, 4);	/* NULL */
+			pq_sendint32(&buf, -1);	/* NULL */
 
 		pq_endmessage(&buf);
 	}
@@ -812,42 +812,42 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
 	Size		len;
 
 	pq_beginmessage(&buf, 'T'); /* RowDescription */
-	pq_sendint(&buf, 2, 2);		/* 2 fields */
+	pq_sendint16(&buf, 2);		/* 2 fields */
 
 	/* Field headers */
 	pq_sendstring(&buf, "recptr");
-	pq_sendint(&buf, 0, 4);		/* table oid */
-	pq_sendint(&buf, 0, 2);		/* attnum */
-	pq_sendint(&buf, TEXTOID, 4);	/* type oid */
-	pq_sendint(&buf, -1, 2);
-	pq_sendint(&buf, 0, 4);
-	pq_sendint(&buf, 0, 2);
+	pq_sendint32(&buf, 0);		/* table oid */
+	pq_sendint16(&buf, 0);		/* attnum */
+	pq_sendint32(&buf, TEXTOID);	/* type oid */
+	pq_sendint16(&buf, -1);
+	pq_sendint32(&buf, 0);
+	pq_sendint16(&buf, 0);
 
 	pq_sendstring(&buf, "tli");
-	pq_sendint(&buf, 0, 4);		/* table oid */
-	pq_sendint(&buf, 0, 2);		/* attnum */
+	pq_sendint32(&buf, 0);		/* table oid */
+	pq_sendint16(&buf, 0);		/* attnum */
 
 	/*
 	 * int8 may seem like a surprising data type for this, but in theory int4
 	 * would not be wide enough for this, as TimeLineID is unsigned.
 	 */
-	pq_sendint(&buf, INT8OID, 4);	/* type oid */
-	pq_sendint(&buf, -1, 2);
-	pq_sendint(&buf, 0, 4);
-	pq_sendint(&buf, 0, 2);
+	pq_sendint32(&buf, INT8OID);	/* type oid */
+	pq_sendint16(&buf, -1);
+	pq_sendint32(&buf, 0);
+	pq_sendint16(&buf, 0);
 	pq_endmessage(&buf);
 
 	/* Data row */
 	pq_beginmessage(&buf, 'D');
-	pq_sendint(&buf, 2, 2);		/* number of columns */
+	pq_sendint16(&buf, 2);		/* number of columns */
 
 	len = snprintf(str, sizeof(str),
 				   "%X/%X", (uint32) (ptr >> 32), (uint32) ptr);
-	pq_sendint(&buf, len, 4);
+	pq_sendint32(&buf, len);
 	pq_sendbytes(&buf, str, len);
 
 	len = snprintf(str, sizeof(str), "%u", tli);
-	pq_sendint(&buf, len, 4);
+	pq_sendint32(&buf, len);
 	pq_sendbytes(&buf, str, len);
 
 	pq_endmessage(&buf);
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c
index f19649b113c..9b126b29570 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -47,7 +47,7 @@ logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn)
 	/* fixed fields */
 	pq_sendint64(out, txn->final_lsn);
 	pq_sendint64(out, txn->commit_time);
-	pq_sendint(out, txn->xid, 4);
+	pq_sendint32(out, txn->xid);
 }
 
 /*
@@ -145,7 +145,7 @@ logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple)
 		   rel->rd_rel->relreplident == REPLICA_IDENTITY_INDEX);
 
 	/* use Oid as relation identifier */
-	pq_sendint(out, RelationGetRelid(rel), 4);
+	pq_sendint32(out, RelationGetRelid(rel));
 
 	pq_sendbyte(out, 'N');		/* new tuple follows */
 	logicalrep_write_tuple(out, rel, newtuple);
@@ -189,7 +189,7 @@ logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
 		   rel->rd_rel->relreplident == REPLICA_IDENTITY_INDEX);
 
 	/* use Oid as relation identifier */
-	pq_sendint(out, RelationGetRelid(rel), 4);
+	pq_sendint32(out, RelationGetRelid(rel));
 
 	if (oldtuple != NULL)
 	{
@@ -258,7 +258,7 @@ logicalrep_write_delete(StringInfo out, Relation rel, HeapTuple oldtuple)
 	pq_sendbyte(out, 'D');		/* action DELETE */
 
 	/* use Oid as relation identifier */
-	pq_sendint(out, RelationGetRelid(rel), 4);
+	pq_sendint32(out, RelationGetRelid(rel));
 
 	if (rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL)
 		pq_sendbyte(out, 'O');	/* old tuple follows */
@@ -303,7 +303,7 @@ logicalrep_write_rel(StringInfo out, Relation rel)
 	pq_sendbyte(out, 'R');		/* sending RELATION */
 
 	/* use Oid as relation identifier */
-	pq_sendint(out, RelationGetRelid(rel), 4);
+	pq_sendint32(out, RelationGetRelid(rel));
 
 	/* send qualified relation name */
 	logicalrep_write_namespace(out, RelationGetNamespace(rel));
@@ -360,7 +360,7 @@ logicalrep_write_typ(StringInfo out, Oid typoid)
 	typtup = (Form_pg_type) GETSTRUCT(tup);
 
 	/* use Oid as relation identifier */
-	pq_sendint(out, typoid, 4);
+	pq_sendint32(out, typoid);
 
 	/* send qualified type name */
 	logicalrep_write_namespace(out, typtup->typnamespace);
@@ -402,7 +402,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple)
 			continue;
 		nliveatts++;
 	}
-	pq_sendint(out, nliveatts, 2);
+	pq_sendint16(out, nliveatts);
 
 	/* try to allocate enough memory from the get-go */
 	enlargeStringInfo(out, tuple->t_len +
@@ -522,7 +522,7 @@ logicalrep_write_attrs(StringInfo out, Relation rel)
 			continue;
 		nliveatts++;
 	}
-	pq_sendint(out, nliveatts, 2);
+	pq_sendint16(out, nliveatts);
 
 	/* fetch bitmap of REPLICATION IDENTITY attributes */
 	replidentfull = (rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL);
@@ -551,10 +551,10 @@ logicalrep_write_attrs(StringInfo out, Relation rel)
 		pq_sendstring(out, NameStr(att->attname));
 
 		/* attribute type id */
-		pq_sendint(out, (int) att->atttypid, sizeof(att->atttypid));
+		pq_sendint32(out, (int) att->atttypid);
 
 		/* attribute mode */
-		pq_sendint(out, att->atttypmod, sizeof(att->atttypmod));
+		pq_sendint32(out, att->atttypmod);
 	}
 
 	bms_free(idattrs);
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 1bf9be673b7..fe4e0859389 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1272,10 +1272,10 @@ XLogWalRcvSendHSFeedback(bool immed)
 	resetStringInfo(&reply_message);
 	pq_sendbyte(&reply_message, 'h');
 	pq_sendint64(&reply_message, GetCurrentTimestamp());
-	pq_sendint(&reply_message, xmin, 4);
-	pq_sendint(&reply_message, xmin_epoch, 4);
-	pq_sendint(&reply_message, catalog_xmin, 4);
-	pq_sendint(&reply_message, catalog_xmin_epoch, 4);
+	pq_sendint32(&reply_message, xmin);
+	pq_sendint32(&reply_message, xmin_epoch);
+	pq_sendint32(&reply_message, catalog_xmin);
+	pq_sendint32(&reply_message, catalog_xmin_epoch);
 	walrcv_send(wrconn, reply_message.data, reply_message.len);
 	if (TransactionIdIsValid(xmin) || TransactionIdIsValid(catalog_xmin))
 		master_has_standby_xmin = true;
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 6ec4e631612..fa1db748b5e 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -444,32 +444,32 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
 
 	/* Send a RowDescription message */
 	pq_beginmessage(&buf, 'T');
-	pq_sendint(&buf, 2, 2);		/* 2 fields */
+	pq_sendint16(&buf, 2);		/* 2 fields */
 
 	/* first field */
 	pq_sendstring(&buf, "filename");	/* col name */
-	pq_sendint(&buf, 0, 4);		/* table oid */
-	pq_sendint(&buf, 0, 2);		/* attnum */
-	pq_sendint(&buf, TEXTOID, 4);	/* type oid */
-	pq_sendint(&buf, -1, 2);	/* typlen */
-	pq_sendint(&buf, 0, 4);		/* typmod */
-	pq_sendint(&buf, 0, 2);		/* format code */
+	pq_sendint32(&buf, 0);		/* table oid */
+	pq_sendint16(&buf, 0);		/* attnum */
+	pq_sendint32(&buf, TEXTOID);	/* type oid */
+	pq_sendint16(&buf, -1);		/* typlen */
+	pq_sendint32(&buf, 0);		/* typmod */
+	pq_sendint16(&buf, 0);		/* format code */
 
 	/* second field */
 	pq_sendstring(&buf, "content"); /* col name */
-	pq_sendint(&buf, 0, 4);		/* table oid */
-	pq_sendint(&buf, 0, 2);		/* attnum */
-	pq_sendint(&buf, BYTEAOID, 4);	/* type oid */
-	pq_sendint(&buf, -1, 2);	/* typlen */
-	pq_sendint(&buf, 0, 4);		/* typmod */
-	pq_sendint(&buf, 0, 2);		/* format code */
+	pq_sendint32(&buf, 0);		/* table oid */
+	pq_sendint16(&buf, 0);		/* attnum */
+	pq_sendint32(&buf, BYTEAOID);	/* type oid */
+	pq_sendint16(&buf, -1);		/* typlen */
+	pq_sendint32(&buf, 0);		/* typmod */
+	pq_sendint16(&buf, 0);		/* format code */
 	pq_endmessage(&buf);
 
 	/* Send a DataRow message */
 	pq_beginmessage(&buf, 'D');
-	pq_sendint(&buf, 2, 2);		/* # of columns */
+	pq_sendint16(&buf, 2);		/* # of columns */
 	len = strlen(histfname);
-	pq_sendint(&buf, len, 4);	/* col1 len */
+	pq_sendint32(&buf, len);	/* col1 len */
 	pq_sendbytes(&buf, histfname, len);
 
 	fd = OpenTransientFile(path, O_RDONLY | PG_BINARY);
@@ -489,7 +489,7 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
 				(errcode_for_file_access(),
 				 errmsg("could not seek to beginning of file \"%s\": %m", path)));
 
-	pq_sendint(&buf, histfilelen, 4);	/* col2 len */
+	pq_sendint32(&buf, histfilelen);	/* col2 len */
 
 	bytesleft = histfilelen;
 	while (bytesleft > 0)
@@ -646,7 +646,7 @@ StartReplication(StartReplicationCmd *cmd)
 		/* Send a CopyBothResponse message, and start streaming */
 		pq_beginmessage(&buf, 'W');
 		pq_sendbyte(&buf, 0);
-		pq_sendint(&buf, 0, 2);
+		pq_sendint16(&buf, 0);
 		pq_endmessage(&buf);
 		pq_flush();
 
@@ -1065,7 +1065,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
 	/* Send a CopyBothResponse message, and start streaming */
 	pq_beginmessage(&buf, 'W');
 	pq_sendbyte(&buf, 0);
-	pq_sendint(&buf, 0, 2);
+	pq_sendint16(&buf, 0);
 	pq_endmessage(&buf);
 	pq_flush();
 
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 8101ae74e0b..a434f7f857f 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -143,7 +143,7 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
 	if (isnull)
 	{
 		if (newstyle)
-			pq_sendint(&buf, -1, 4);
+			pq_sendint32(&buf, -1);
 	}
 	else
 	{
@@ -169,7 +169,7 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
 
 			getTypeBinaryOutputInfo(rettype, &typsend, &typisvarlena);
 			outputbytes = OidSendFunctionCall(typsend, retval);
-			pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
+			pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ);
 			pq_sendbytes(&buf, VARDATA(outputbytes),
 						 VARSIZE(outputbytes) - VARHDRSZ);
 			pfree(outputbytes);
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 36bb8c24fb4..92442a80349 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2377,13 +2377,13 @@ exec_describe_statement_message(const char *stmt_name)
 	 */
 	pq_beginmessage_reuse(&row_description_buf, 't'); /* parameter description
 													   * message type */
-	pq_sendint(&row_description_buf, psrc->num_params, 2);
+	pq_sendint16(&row_description_buf, psrc->num_params);
 
 	for (i = 0; i < psrc->num_params; i++)
 	{
 		Oid			ptype = psrc->param_types[i];
 
-		pq_sendint(&row_description_buf, (int) ptype, 4);
+		pq_sendint32(&row_description_buf, (int) ptype);
 	}
 	pq_endmessage_reuse(&row_description_buf);
 
@@ -3821,8 +3821,8 @@ PostgresMain(int argc, char *argv[],
 		StringInfoData buf;
 
 		pq_beginmessage(&buf, 'K');
-		pq_sendint(&buf, (int32) MyProcPid, sizeof(int32));
-		pq_sendint(&buf, (int32) MyCancelKey, sizeof(int32));
+		pq_sendint32(&buf, (int32) MyProcPid);
+		pq_sendint32(&buf, (int32) MyCancelKey);
 		pq_endmessage(&buf);
 		/* Need not flush since ReadyForQuery will do it. */
 	}
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index ca04b13e825..b4c31ef65c2 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -1590,13 +1590,13 @@ array_send(PG_FUNCTION_ARGS)
 	pq_begintypsend(&buf);
 
 	/* Send the array header information */
-	pq_sendint(&buf, ndim, 4);
-	pq_sendint(&buf, AARR_HASNULL(v) ? 1 : 0, 4);
-	pq_sendint(&buf, element_type, sizeof(Oid));
+	pq_sendint32(&buf, ndim);
+	pq_sendint32(&buf, AARR_HASNULL(v) ? 1 : 0);
+	pq_sendint32(&buf, element_type);
 	for (i = 0; i < ndim; i++)
 	{
-		pq_sendint(&buf, dim[i], 4);
-		pq_sendint(&buf, lb[i], 4);
+		pq_sendint32(&buf, dim[i]);
+		pq_sendint32(&buf, lb[i]);
 	}
 
 	/* Send the array elements using the element's own sendproc */
@@ -1614,14 +1614,14 @@ array_send(PG_FUNCTION_ARGS)
 		if (isnull)
 		{
 			/* -1 length means a NULL */
-			pq_sendint(&buf, -1, 4);
+			pq_sendint32(&buf, -1);
 		}
 		else
 		{
 			bytea	   *outputbytes;
 
 			outputbytes = SendFunctionCall(&my_extra->proc, itemvalue);
-			pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
+			pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ);
 			pq_sendbytes(&buf, VARDATA(outputbytes),
 						 VARSIZE(outputbytes) - VARHDRSZ);
 			pfree(outputbytes);
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 0992bb3fdd0..04e737d0808 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -239,7 +239,7 @@ date_send(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, date, sizeof(date));
+	pq_sendint32(&buf, date);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
@@ -2049,7 +2049,7 @@ timetz_send(PG_FUNCTION_ARGS)
 
 	pq_begintypsend(&buf);
 	pq_sendint64(&buf, time->time);
-	pq_sendint(&buf, time->zone, sizeof(time->zone));
+	pq_sendint32(&buf, time->zone);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index 0348855b11c..e13389a6cc7 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -1433,7 +1433,7 @@ path_send(PG_FUNCTION_ARGS)
 
 	pq_begintypsend(&buf);
 	pq_sendbyte(&buf, path->closed ? 1 : 0);
-	pq_sendint(&buf, path->npts, sizeof(int32));
+	pq_sendint32(&buf, path->npts);
 	for (i = 0; i < path->npts; i++)
 	{
 		pq_sendfloat8(&buf, path->p[i].x);
@@ -3514,7 +3514,7 @@ poly_send(PG_FUNCTION_ARGS)
 	int32		i;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, poly->npts, sizeof(int32));
+	pq_sendint32(&buf, poly->npts);
 	for (i = 0; i < poly->npts; i++)
 	{
 		pq_sendfloat8(&buf, poly->p[i].x);
diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c
index 96ef25b900e..4cd8960b3fc 100644
--- a/src/backend/utils/adt/int.c
+++ b/src/backend/utils/adt/int.c
@@ -99,7 +99,7 @@ int2send(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, arg1, sizeof(int16));
+	pq_sendint16(&buf, arg1);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
@@ -304,7 +304,7 @@ int4send(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, arg1, sizeof(int32));
+	pq_sendint32(&buf, arg1);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c
index 95db8955389..771c05120bb 100644
--- a/src/backend/utils/adt/jsonb.c
+++ b/src/backend/utils/adt/jsonb.c
@@ -154,7 +154,7 @@ jsonb_send(PG_FUNCTION_ARGS)
 	(void) JsonbToCString(jtext, &jb->root, VARSIZE(jb));
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, version, 1);
+	pq_sendint8(&buf, version);
 	pq_sendtext(&buf, jtext->data, jtext->len);
 	pfree(jtext->data);
 	pfree(jtext);
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index 2c5948052d3..2bca39a90cc 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -315,7 +315,7 @@ abstimesend(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, time, sizeof(time));
+	pq_sendint32(&buf, time);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
@@ -674,7 +674,7 @@ reltimesend(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, time, sizeof(time));
+	pq_sendint32(&buf, time);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
@@ -794,9 +794,9 @@ tintervalsend(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, tinterval->status, sizeof(tinterval->status));
-	pq_sendint(&buf, tinterval->data[0], sizeof(tinterval->data[0]));
-	pq_sendint(&buf, tinterval->data[1], sizeof(tinterval->data[1]));
+	pq_sendint32(&buf, tinterval->status);
+	pq_sendint32(&buf, tinterval->data[0]);
+	pq_sendint32(&buf, tinterval->data[1]);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 48d95e90501..2cd14f34012 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -876,12 +876,12 @@ numeric_send(PG_FUNCTION_ARGS)
 
 	pq_begintypsend(&buf);
 
-	pq_sendint(&buf, x.ndigits, sizeof(int16));
-	pq_sendint(&buf, x.weight, sizeof(int16));
-	pq_sendint(&buf, x.sign, sizeof(int16));
-	pq_sendint(&buf, x.dscale, sizeof(int16));
+	pq_sendint16(&buf, x.ndigits);
+	pq_sendint16(&buf, x.weight);
+	pq_sendint16(&buf, x.sign);
+	pq_sendint16(&buf, x.dscale);
 	for (i = 0; i < x.ndigits; i++)
-		pq_sendint(&buf, x.digits[i], sizeof(NumericDigit));
+		pq_sendint16(&buf, x.digits[i]);
 
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
@@ -3693,7 +3693,7 @@ numeric_avg_serialize(PG_FUNCTION_ARGS)
 	pq_sendbytes(&buf, VARDATA_ANY(sumX), VARSIZE_ANY_EXHDR(sumX));
 
 	/* maxScale */
-	pq_sendint(&buf, state->maxScale, 4);
+	pq_sendint32(&buf, state->maxScale);
 
 	/* maxScaleCount */
 	pq_sendint64(&buf, state->maxScaleCount);
@@ -3815,7 +3815,7 @@ numeric_serialize(PG_FUNCTION_ARGS)
 	pq_sendbytes(&buf, VARDATA_ANY(sumX2), VARSIZE_ANY_EXHDR(sumX2));
 
 	/* maxScale */
-	pq_sendint(&buf, state->maxScale, 4);
+	pq_sendint32(&buf, state->maxScale);
 
 	/* maxScaleCount */
 	pq_sendint64(&buf, state->maxScaleCount);
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index 7baaa1dd4ee..87e87fe54d5 100644
--- a/src/backend/utils/adt/oid.c
+++ b/src/backend/utils/adt/oid.c
@@ -154,7 +154,7 @@ oidsend(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, arg1, sizeof(Oid));
+	pq_sendint32(&buf, arg1);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index d0aa33c010b..e79f0dbfca6 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -272,7 +272,7 @@ range_send(PG_FUNCTION_ARGS)
 		uint32		bound_len = VARSIZE(bound) - VARHDRSZ;
 		char	   *bound_data = VARDATA(bound);
 
-		pq_sendint(buf, bound_len, 4);
+		pq_sendint32(buf, bound_len);
 		pq_sendbytes(buf, bound_data, bound_len);
 	}
 
@@ -283,7 +283,7 @@ range_send(PG_FUNCTION_ARGS)
 		uint32		bound_len = VARSIZE(bound) - VARHDRSZ;
 		char	   *bound_data = VARDATA(bound);
 
-		pq_sendint(buf, bound_len, 4);
+		pq_sendint32(buf, bound_len);
 		pq_sendbytes(buf, bound_data, bound_len);
 	}
 
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index 98fe00ff394..9b32db5d0ae 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -718,7 +718,7 @@ record_send(PG_FUNCTION_ARGS)
 		if (!TupleDescAttr(tupdesc, i)->attisdropped)
 			validcols++;
 	}
-	pq_sendint(&buf, validcols, 4);
+	pq_sendint32(&buf, validcols);
 
 	for (i = 0; i < ncolumns; i++)
 	{
@@ -732,12 +732,12 @@ record_send(PG_FUNCTION_ARGS)
 		if (att->attisdropped)
 			continue;
 
-		pq_sendint(&buf, column_type, sizeof(Oid));
+		pq_sendint32(&buf, column_type);
 
 		if (nulls[i])
 		{
 			/* emit -1 data length to signify a NULL */
-			pq_sendint(&buf, -1, 4);
+			pq_sendint32(&buf, -1);
 			continue;
 		}
 
@@ -756,7 +756,7 @@ record_send(PG_FUNCTION_ARGS)
 
 		attr = values[i];
 		outputbytes = SendFunctionCall(&column_info->proc, attr);
-		pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
+		pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ);
 		pq_sendbytes(&buf, VARDATA(outputbytes),
 					 VARSIZE(outputbytes) - VARHDRSZ);
 	}
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 083f7d60a7b..854097dd583 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -149,10 +149,8 @@ tidsend(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, ItemPointerGetBlockNumberNoCheck(itemPtr),
-			   sizeof(BlockNumber));
-	pq_sendint(&buf, ItemPointerGetOffsetNumberNoCheck(itemPtr),
-			   sizeof(OffsetNumber));
+	pq_sendint32(&buf, ItemPointerGetBlockNumberNoCheck(itemPtr));
+	pq_sendint16(&buf, ItemPointerGetOffsetNumberNoCheck(itemPtr));
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index b11d452fc8a..5797aaad34c 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -1009,8 +1009,8 @@ interval_send(PG_FUNCTION_ARGS)
 
 	pq_begintypsend(&buf);
 	pq_sendint64(&buf, interval->time);
-	pq_sendint(&buf, interval->day, sizeof(interval->day));
-	pq_sendint(&buf, interval->month, sizeof(interval->month));
+	pq_sendint32(&buf, interval->day);
+	pq_sendint32(&buf, interval->month);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c
index fdb041971e5..5cdfe4d7322 100644
--- a/src/backend/utils/adt/tsquery.c
+++ b/src/backend/utils/adt/tsquery.c
@@ -952,23 +952,22 @@ tsquerysend(PG_FUNCTION_ARGS)
 
 	pq_begintypsend(&buf);
 
-	pq_sendint(&buf, query->size, sizeof(uint32));
+	pq_sendint32(&buf, query->size);
 	for (i = 0; i < query->size; i++)
 	{
-		pq_sendint(&buf, item->type, sizeof(item->type));
+		pq_sendint8(&buf, item->type);
 
 		switch (item->type)
 		{
 			case QI_VAL:
-				pq_sendint(&buf, item->qoperand.weight, sizeof(uint8));
-				pq_sendint(&buf, item->qoperand.prefix, sizeof(uint8));
+				pq_sendint8(&buf, item->qoperand.weight);
+				pq_sendint8(&buf, item->qoperand.prefix);
 				pq_sendstring(&buf, GETOPERAND(query) + item->qoperand.distance);
 				break;
 			case QI_OPR:
-				pq_sendint(&buf, item->qoperator.oper, sizeof(item->qoperator.oper));
+				pq_sendint8(&buf, item->qoperator.oper);
 				if (item->qoperator.oper == OP_PHRASE)
-					pq_sendint(&buf, item->qoperator.distance,
-							   sizeof(item->qoperator.distance));
+					pq_sendint16(&buf, item->qoperator.distance);
 				break;
 			default:
 				elog(ERROR, "unrecognized tsquery node type: %d", item->type);
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c
index 6f66c1f58ce..b0a9217d1e3 100644
--- a/src/backend/utils/adt/tsvector.c
+++ b/src/backend/utils/adt/tsvector.c
@@ -410,7 +410,7 @@ tsvectorsend(PG_FUNCTION_ARGS)
 
 	pq_begintypsend(&buf);
 
-	pq_sendint(&buf, vec->size, sizeof(int32));
+	pq_sendint32(&buf, vec->size);
 	for (i = 0; i < vec->size; i++)
 	{
 		uint16		npos;
@@ -423,14 +423,14 @@ tsvectorsend(PG_FUNCTION_ARGS)
 		pq_sendbyte(&buf, '\0');
 
 		npos = POSDATALEN(vec, weptr);
-		pq_sendint(&buf, npos, sizeof(uint16));
+		pq_sendint16(&buf, npos);
 
 		if (npos > 0)
 		{
 			WordEntryPos *wepptr = POSDATAPTR(vec, weptr);
 
 			for (j = 0; j < npos; j++)
-				pq_sendint(&buf, wepptr[j], sizeof(WordEntryPos));
+				pq_sendint16(&buf, wepptr[j]);
 		}
 		weptr++;
 	}
diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c
index 1e38ca2aa5e..9d312edf04f 100644
--- a/src/backend/utils/adt/txid.c
+++ b/src/backend/utils/adt/txid.c
@@ -640,7 +640,7 @@ txid_snapshot_send(PG_FUNCTION_ARGS)
 	uint32		i;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, snap->nxip, 4);
+	pq_sendint32(&buf, snap->nxip);
 	pq_sendint64(&buf, snap->xmin);
 	pq_sendint64(&buf, snap->xmax);
 	for (i = 0; i < snap->nxip; i++)
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index 0cf1c6f6d60..478fab9bfce 100644
--- a/src/backend/utils/adt/varbit.c
+++ b/src/backend/utils/adt/varbit.c
@@ -665,7 +665,7 @@ varbit_send(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, VARBITLEN(s), sizeof(int32));
+	pq_sendint32(&buf, VARBITLEN(s));
 	pq_sendbytes(&buf, (char *) VARBITS(s), VARBITBYTES(s));
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c
index 2051709fdef..67c32ac6193 100644
--- a/src/backend/utils/adt/xid.c
+++ b/src/backend/utils/adt/xid.c
@@ -68,7 +68,7 @@ xidsend(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, arg1, sizeof(arg1));
+	pq_sendint32(&buf, arg1);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
@@ -196,7 +196,7 @@ cidsend(PG_FUNCTION_ARGS)
 	StringInfoData buf;
 
 	pq_begintypsend(&buf);
-	pq_sendint(&buf, arg1, sizeof(arg1));
+	pq_sendint32(&buf, arg1);
 	PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
-- 
2.14.1.536.g6867272d5b.dirty

