Replace remaining uses of pq_sendint with pq_sendint{8,16,32}.

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

Author: Andres Freund
Discussion: https://postgr.es/m/20170914063418.sckdzgjfrsbekae4@alap3.anarazel.de
This commit is contained in:
Andres Freund 2017-10-11 21:00:46 -07:00
parent 52328727be
commit 31079a4a8e
30 changed files with 160 additions and 163 deletions

View 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);
}
}

View 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;
}

View 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);
}

View 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);
/*

View 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);

View 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();

View 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);

View 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);

View 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);

View 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;

View 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();

View 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);

View 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. */
}

View 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);

View 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));
}

View 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);

View 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));
}

View 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);

View 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));
}

View 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);

View 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));
}

View 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);
}

View 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);
}

View 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));
}

View 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));
}

View 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);

View 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++;
}

View 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++)

View 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));
}

View 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));
}