Replace remaining uses of pq_sendint with pq_sendint{8,16,32}.
authorAndres Freund <andres@anarazel.de>
Thu, 12 Oct 2017 04:00:46 +0000 (21:00 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 12 Oct 2017 04:00:46 +0000 (21:00 -0700)
pq_sendint() remains, so extension code doesn't unnecessarily break.

Author: Andres Freund
Discussion: https://postgr.es/m/20170914063418.sckdzgjfrsbekae4@alap3.anarazel.de

30 files changed:
contrib/hstore/hstore_io.c
src/backend/access/common/printsimple.c
src/backend/access/common/printtup.c
src/backend/access/transam/parallel.c
src/backend/commands/async.c
src/backend/commands/copy.c
src/backend/libpq/auth.c
src/backend/replication/basebackup.c
src/backend/replication/logical/proto.c
src/backend/replication/walreceiver.c
src/backend/replication/walsender.c
src/backend/tcop/fastpath.c
src/backend/tcop/postgres.c
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/date.c
src/backend/utils/adt/geo_ops.c
src/backend/utils/adt/int.c
src/backend/utils/adt/jsonb.c
src/backend/utils/adt/nabstime.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/oid.c
src/backend/utils/adt/rangetypes.c
src/backend/utils/adt/rowtypes.c
src/backend/utils/adt/tid.c
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/tsquery.c
src/backend/utils/adt/tsvector.c
src/backend/utils/adt/txid.c
src/backend/utils/adt/varbit.c
src/backend/utils/adt/xid.c

index 6363c321c5d0f825287fb162c68c37c1bf68901c..d8284012d0b53e9ce7f1b5a06f504718a72dec4a 100644 (file)
@@ -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);
        }
    }
index b3e9a26b0327c69d1441ae5eb3934cffdfff0e06..872de7c3f4467388652acfbb0616b6be7bed9a2b 100644 (file)
@@ -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;
        }
 
index 02cd1beef79b774326c26fe0e62919e414205583..fc94e711b27f97c724f155cdcc17b91241360850 100644 (file)
@@ -395,7 +395,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
@@ -407,7 +407,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
 
        if (slot->tts_isnull[i])
        {
-           pq_sendint(buf, -1, 4);
+           pq_sendint32(buf, -1);
            continue;
        }
 
@@ -436,7 +436,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);
        }
@@ -494,13 +494,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
@@ -679,13 +679,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
@@ -702,7 +702,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);
    }
index c6f7b7af0e1fd21954f5f835bd8e9de2aa98d4e9..d68305073303d23bf7f647cdad5d28e4d006da50 100644 (file)
@@ -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);
 
    /*
index a93c81bca28798e64ef84be847eecf12c6c6c740..f7de742a56e7f8e11ff6df9aae02bfd0584448be 100644 (file)
@@ -2100,7 +2100,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);
index e87588040fafb418433bfd88c9f59fca506e7516..64550f9c680a17c926861ae7755420c8da85476e 100644 (file)
@@ -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();
index 480e344eb3a45510b10a7983ab3d0bdf7f2de183..3b3a932a7d8aaab24d3a1920e3cb58fc32a9f0ab 100644 (file)
@@ -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);
 
index c3b9bddc8fe7592d01f1f61883b3e577e4047baa..75029b0def9911295b523161131edf8ce6769db7 100644 (file)
@@ -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);
index f19649b113c297bb91ace4fdfc41399899882079..9b126b295705d8d7423e976958b0f91b42822998 100644 (file)
@@ -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);
index 1bf9be673b79d19e7582ef3731b2d9985fbed564..fe4e08593897d755e92e388607e8b9a04786452d 100644 (file)
@@ -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;
index 6ec4e631612f4d4228945822d084c9688b257451..fa1db748b5e54c7e84f726693b35fbb4c03f4f9e 100644 (file)
@@ -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();
 
index 8101ae74e0bfdb84b4fd029ccb6d22efeec1edf6..a434f7f857f0cbc05186b1f674809231c708b2cd 100644 (file)
@@ -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);
index 338ce81331d88657ef1d19a62bdccecbbd6dad23..2c7260e564bf246261a4e7e1ad35e9daa8a2fcd2 100644 (file)
@@ -2376,13 +2376,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);
 
@@ -3818,8 +3818,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. */
    }
index ca04b13e825abb8e6fc9bcc6a1b3fed3250e04d7..b4c31ef65c2771ae87d98c845a49ee1bb4cbbe2f 100644 (file)
@@ -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);
index 0992bb3fdd024a093374ad923e2151fc05446550..04e737d08085e4fd2c85a67af1c847156a7edf83 100644 (file)
@@ -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));
 }
 
index 0348855b11cf6b2d4e4d52fa9fb68ea01af5c25e..e13389a6cc7227d245b5898fe118ca25073878a9 100644 (file)
@@ -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);
index 96ef25b900edee55907a30cbff9ea1d5c5ebfcf6..4cd8960b3fca3223e9ee4fad6bd7576591a7ba4d 100644 (file)
@@ -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));
 }
 
index 95db89553891a6489fc1b53ac1f023367899aa55..771c05120bb56cd9a70c2fcb51d9f7474ba7b6e1 100644 (file)
@@ -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);
index 2c5948052d315f7ed6bf182a504c71d5729a0e4b..2bca39a90cc6fd9019493ceda17ed9ca596236b1 100644 (file)
@@ -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));
 }
 
index 48d95e90501dfda76643043dcdb80b99d2d5d2d7..2cd14f34012aa870970eee7bcbac20a4e6ac60d7 100644 (file)
@@ -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);
index 7baaa1dd4eed57e7a46083e28ee2231b071674a1..87e87fe54d58e8c73744114ff5c60d5f925dcd76 100644 (file)
@@ -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));
 }
 
index d0aa33c010bc31431c7181b90e18d225f8e384e5..e79f0dbfca6aa3687d733742278ae38e1f5ee262 100644 (file)
@@ -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);
    }
 
index 98fe00ff394c329dadb71e80069626dda1d8d378..9b32db5d0aedffca74a63e2dcece67fc806ea055 100644 (file)
@@ -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);
    }
index 083f7d60a7bcf9b075ea84543e15142d831d1f1b..854097dd583e62512a2ea4dac654ce9e9e00f059 100644 (file)
@@ -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));
 }
 
index b11d452fc8a024a9dcfab74e2ace6f5985637d5c..5797aaad34c0cc1fb477b0c3d147e7d67fec2354 100644 (file)
@@ -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));
 }
 
index fdb041971e5228538b5edda16339abef378a9b77..5cdfe4d732276226f2f0a4d7adb02cf93394a258 100644 (file)
@@ -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);
index 6f66c1f58ce35fe1455b9448d0d4110b50c1c221..b0a9217d1e3c97215a933d18b0b535f0befeafd0 100644 (file)
@@ -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++;
    }
index 1e38ca2aa5e68f2da5b77f0538fd5b4faa5e7a36..9d312edf04f0f932e9c812823c06453627abfe13 100644 (file)
@@ -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++)
index 0cf1c6f6d603087dacfa77376870781a21790566..478fab9bfce060b713e9226dfd8f7ff7674fc595 100644 (file)
@@ -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));
 }
index 2051709fdef2cdb1f05a0c45c256f89a3cf9e445..67c32ac61937a8193b8343052fc7d8e16d533d01 100644 (file)
@@ -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));
 }