On Mon, Jun 11, 2018 at 02:25:44PM +0900, Michael Paquier wrote: > On Wed, Jun 06, 2018 at 12:27:58PM -0400, Alvaro Herrera wrote: >> Do you have an answer to this question? Does anybody else? >> >> (My guts tell me it'd be better to change these routines to take >> unsigned values, without creating extra variants. But guts frequently >> misspeak.) > > My guts are telling me as well to not have more variants. On top of > that it seems to me that we'd want to rename any new routines to include > "uint" in their name instead of "int", and for compatibility with past > code pq_sendint should not be touched.
And also pq_sendint64 needs to be kept around for compatibility. I have quickly looked at how much code would be involved here and there are quite close to 240 code paths which involve the new routines. Please see attached for reference, I have not put much thoughts into it to be honest, so that's really at an early stage. -- Michael
diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
index 745497c76f..7c8da5bf22 100644
--- a/contrib/hstore/hstore_io.c
+++ b/contrib/hstore/hstore_io.c
@@ -1234,23 +1234,23 @@ hstore_send(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
- pq_sendint32(&buf, count);
+ pq_senduint32(&buf, count);
for (i = 0; i < count; i++)
{
int32 keylen = HSTORE_KEYLEN(entries, i);
- pq_sendint32(&buf, keylen);
+ pq_senduint32(&buf, keylen);
pq_sendtext(&buf, HSTORE_KEY(entries, base, i), keylen);
if (HSTORE_VALISNULL(entries, i))
{
- pq_sendint32(&buf, -1);
+ pq_senduint32(&buf, -1);
}
else
{
int32 vallen = HSTORE_VALLEN(entries, i);
- pq_sendint32(&buf, vallen);
+ pq_senduint32(&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 3c4d227712..c5aade3e44 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_sendint16(&buf, tupdesc->natts);
+ pq_senduint16(&buf, tupdesc->natts);
for (i = 0; i < tupdesc->natts; ++i)
{
Form_pg_attribute attr = TupleDescAttr(tupdesc, i);
pq_sendstring(&buf, NameStr(attr->attname));
- 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_senduint32(&buf, 0); /* table oid */
+ pq_senduint16(&buf, 0); /* attnum */
+ pq_senduint32(&buf, (uint32) attr->atttypid);
+ pq_senduint16(&buf, attr->attlen);
+ pq_senduint32(&buf, attr->atttypmod);
+ pq_senduint16(&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_sendint16(&buf, tupdesc->natts);
+ pq_senduint16(&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_sendint32(&buf, -1);
+ pq_senduint32(&buf, -1);
continue;
}
diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index a1d4415704..8b85e34baf 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -203,7 +203,7 @@ SendRowDescriptionMessage(StringInfo buf, TupleDesc typeinfo,
/* tuple descriptor message type */
pq_beginmessage_reuse(buf, 'T');
/* # of attrs in tuples */
- pq_sendint16(buf, natts);
+ pq_senduint16(buf, natts);
if (proto >= 3)
SendRowDescriptionCols_3(buf, typeinfo, targetlist, formats);
@@ -280,12 +280,12 @@ SendRowDescriptionCols_3(StringInfo buf, TupleDesc typeinfo, List *targetlist, i
format = 0;
pq_writestring(buf, NameStr(att->attname));
- pq_writeint32(buf, resorigtbl);
- pq_writeint16(buf, resorigcol);
- pq_writeint32(buf, atttypid);
- pq_writeint16(buf, att->attlen);
- pq_writeint32(buf, atttypmod);
- pq_writeint16(buf, format);
+ pq_writeuint32(buf, resorigtbl);
+ pq_writeuint16(buf, resorigcol);
+ pq_writeuint32(buf, atttypid);
+ pq_writeuint16(buf, att->attlen);
+ pq_writeuint32(buf, atttypmod);
+ pq_writeuint16(buf, format);
}
}
@@ -309,9 +309,9 @@ SendRowDescriptionCols_2(StringInfo buf, TupleDesc typeinfo, List *targetlist, i
pq_sendstring(buf, NameStr(att->attname));
/* column ID only info appears in protocol 3.0 and up */
- pq_sendint32(buf, atttypid);
- pq_sendint16(buf, att->attlen);
- pq_sendint32(buf, atttypmod);
+ pq_senduint32(buf, atttypid);
+ pq_senduint16(buf, att->attlen);
+ pq_senduint32(buf, atttypmod);
/* format info only appears in protocol 3.0 and up */
}
}
@@ -395,7 +395,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
*/
pq_beginmessage_reuse(buf, 'D');
- pq_sendint16(buf, natts);
+ pq_senduint16(buf, natts);
/*
* send the attributes of this tuple
@@ -407,7 +407,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
if (slot->tts_isnull[i])
{
- pq_sendint32(buf, -1);
+ pq_senduint32(buf, -1);
continue;
}
@@ -436,7 +436,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
bytea *outputbytes;
outputbytes = SendFunctionCall(&thisState->finfo, attr);
- pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ);
+ pq_senduint32(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_sendint8(buf, j);
+ pq_senduint8(buf, j);
j = 0;
k = 1 << 7;
}
}
if (k != (1 << 7)) /* flush last partial byte */
- pq_sendint8(buf, j);
+ pq_senduint8(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_sendint8(buf, j);
+ pq_senduint8(buf, j);
j = 0;
k = 1 << 7;
}
}
if (k != (1 << 7)) /* flush last partial byte */
- pq_sendint8(buf, j);
+ pq_senduint8(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_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ);
+ pq_senduint32(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 1d631b7275..f5168a8e50 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -1281,8 +1281,8 @@ ParallelWorkerMain(Datum main_arg)
* in this case.
*/
pq_beginmessage(&msgbuf, 'K');
- pq_sendint32(&msgbuf, (int32) MyProcPid);
- pq_sendint32(&msgbuf, (int32) MyCancelKey);
+ pq_senduint32(&msgbuf, (uint32) MyProcPid);
+ pq_senduint32(&msgbuf, (uint32) MyCancelKey);
pq_endmessage(&msgbuf);
/*
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ee7c6d41b4..3747faf89c 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2100,7 +2100,7 @@ NotifyMyFrontEnd(const char *channel, const char *payload, int32 srcPid)
StringInfoData buf;
pq_beginmessage(&buf, 'A');
- pq_sendint32(&buf, srcPid);
+ pq_senduint32(&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 3a66cb5025..abbc0f4bfa 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_sendint16(&buf, natts);
+ pq_senduint16(&buf, natts);
for (i = 0; i < natts; i++)
- pq_sendint16(&buf, format); /* per-column formats */
+ pq_senduint16(&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_sendint16(&buf, natts);
+ pq_senduint16(&buf, natts);
for (i = 0; i < natts; i++)
- pq_sendint16(&buf, format); /* per-column formats */
+ pq_senduint16(&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 63f37902e6..1727c4d692 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -621,7 +621,7 @@ sendAuthRequest(Port *port, AuthRequest areq, const char *extradata, int extrale
CHECK_FOR_INTERRUPTS();
pq_beginmessage(&buf, 'R');
- pq_sendint32(&buf, (int32) areq);
+ pq_senduint32(&buf, (uint32) areq);
if (extralen > 0)
pq_sendbytes(&buf, extradata, extralen);
diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c
index 1c7e99019d..dc15f3798a 100644
--- a/src/backend/libpq/pqformat.c
+++ b/src/backend/libpq/pqformat.c
@@ -149,13 +149,13 @@ pq_sendcountedtext(StringInfo buf, const char *str, int slen,
if (p != str) /* actual conversion has been done? */
{
slen = strlen(p);
- pq_sendint32(buf, slen + extra);
+ pq_senduint32(buf, slen + extra);
appendBinaryStringInfoNT(buf, p, slen);
pfree(p);
}
else
{
- pq_sendint32(buf, slen + extra);
+ pq_senduint32(buf, slen + extra);
appendBinaryStringInfoNT(buf, str, slen);
}
}
@@ -260,7 +260,7 @@ pq_sendfloat4(StringInfo buf, float4 f)
} swap;
swap.f = f;
- pq_sendint32(buf, swap.i);
+ pq_senduint32(buf, swap.i);
}
/* --------------------------------
@@ -284,7 +284,7 @@ pq_sendfloat8(StringInfo buf, float8 f)
} swap;
swap.f = f;
- pq_sendint64(buf, swap.i);
+ pq_senduint64(buf, swap.i);
}
/* --------------------------------
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index a4b53b33cd..46c5cf8890 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -2249,8 +2249,8 @@ SendNegotiateProtocolVersion(List *unrecognized_protocol_options)
ListCell *lc;
pq_beginmessage(&buf, 'v'); /* NegotiateProtocolVersion */
- pq_sendint32(&buf, PG_PROTOCOL_LATEST);
- pq_sendint32(&buf, list_length(unrecognized_protocol_options));
+ pq_senduint32(&buf, PG_PROTOCOL_LATEST);
+ pq_senduint32(&buf, list_length(unrecognized_protocol_options));
foreach(lc, unrecognized_protocol_options)
pq_sendstring(&buf, lfirst(lc));
pq_endmessage(&buf);
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 5688cbe2e9..44fabc862e 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -307,7 +307,7 @@ perform_base_backup(basebackup_options *opt)
/* Send CopyOutResponse message */
pq_beginmessage(&buf, 'H');
pq_sendbyte(&buf, 0); /* overall format */
- pq_sendint16(&buf, 0); /* natts */
+ pq_senduint16(&buf, 0); /* natts */
pq_endmessage(&buf);
if (ti->path == NULL)
@@ -771,7 +771,7 @@ send_int8_string(StringInfoData *buf, int64 intval)
char is[32];
sprintf(is, INT64_FORMAT, intval);
- pq_sendint32(buf, strlen(is));
+ pq_senduint32(buf, strlen(is));
pq_sendbytes(buf, is, strlen(is));
}
@@ -783,34 +783,34 @@ SendBackupHeader(List *tablespaces)
/* Construct and send the directory information */
pq_beginmessage(&buf, 'T'); /* RowDescription */
- pq_sendint16(&buf, 3); /* 3 fields */
+ pq_senduint16(&buf, 3); /* 3 fields */
/* First field - spcoid */
pq_sendstring(&buf, "spcoid");
- 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 */
+ pq_senduint32(&buf, 0); /* table oid */
+ pq_senduint16(&buf, 0); /* attnum */
+ pq_senduint32(&buf, OIDOID); /* type oid */
+ pq_senduint16(&buf, 4); /* typlen */
+ pq_senduint32(&buf, 0); /* typmod */
+ pq_senduint16(&buf, 0); /* format code */
/* Second field - spcpath */
pq_sendstring(&buf, "spclocation");
- pq_sendint32(&buf, 0);
- pq_sendint16(&buf, 0);
- pq_sendint32(&buf, TEXTOID);
- pq_sendint16(&buf, -1);
- pq_sendint32(&buf, 0);
- pq_sendint16(&buf, 0);
+ pq_senduint32(&buf, 0);
+ pq_senduint16(&buf, 0);
+ pq_senduint32(&buf, TEXTOID);
+ pq_senduint16(&buf, -1);
+ pq_senduint32(&buf, 0);
+ pq_senduint16(&buf, 0);
/* Third field - size */
pq_sendstring(&buf, "size");
- 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_senduint32(&buf, 0);
+ pq_senduint16(&buf, 0);
+ pq_senduint32(&buf, INT8OID);
+ pq_senduint16(&buf, 8);
+ pq_senduint32(&buf, 0);
+ pq_senduint16(&buf, 0);
pq_endmessage(&buf);
foreach(lc, tablespaces)
@@ -819,28 +819,28 @@ SendBackupHeader(List *tablespaces)
/* Send one datarow message */
pq_beginmessage(&buf, 'D');
- pq_sendint16(&buf, 3); /* number of columns */
+ pq_senduint16(&buf, 3); /* number of columns */
if (ti->path == NULL)
{
- pq_sendint32(&buf, -1); /* Length = -1 ==> NULL */
- pq_sendint32(&buf, -1);
+ pq_senduint32(&buf, -1); /* Length = -1 ==> NULL */
+ pq_senduint32(&buf, -1);
}
else
{
Size len;
len = strlen(ti->oid);
- pq_sendint32(&buf, len);
+ pq_senduint32(&buf, len);
pq_sendbytes(&buf, ti->oid, len);
len = strlen(ti->path);
- pq_sendint32(&buf, len);
+ pq_senduint32(&buf, len);
pq_sendbytes(&buf, ti->path, len);
}
if (ti->size >= 0)
send_int8_string(&buf, ti->size / 1024);
else
- pq_sendint32(&buf, -1); /* NULL */
+ pq_senduint32(&buf, -1); /* NULL */
pq_endmessage(&buf);
}
@@ -861,42 +861,42 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
Size len;
pq_beginmessage(&buf, 'T'); /* RowDescription */
- pq_sendint16(&buf, 2); /* 2 fields */
+ pq_senduint16(&buf, 2); /* 2 fields */
/* Field headers */
pq_sendstring(&buf, "recptr");
- 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_senduint32(&buf, 0); /* table oid */
+ pq_senduint16(&buf, 0); /* attnum */
+ pq_senduint32(&buf, TEXTOID); /* type oid */
+ pq_senduint16(&buf, -1);
+ pq_senduint32(&buf, 0);
+ pq_senduint16(&buf, 0);
pq_sendstring(&buf, "tli");
- pq_sendint32(&buf, 0); /* table oid */
- pq_sendint16(&buf, 0); /* attnum */
+ pq_senduint32(&buf, 0); /* table oid */
+ pq_senduint16(&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_sendint32(&buf, INT8OID); /* type oid */
- pq_sendint16(&buf, -1);
- pq_sendint32(&buf, 0);
- pq_sendint16(&buf, 0);
+ pq_senduint32(&buf, INT8OID); /* type oid */
+ pq_senduint16(&buf, -1);
+ pq_senduint32(&buf, 0);
+ pq_senduint16(&buf, 0);
pq_endmessage(&buf);
/* Data row */
pq_beginmessage(&buf, 'D');
- pq_sendint16(&buf, 2); /* number of columns */
+ pq_senduint16(&buf, 2); /* number of columns */
len = snprintf(str, sizeof(str),
"%X/%X", (uint32) (ptr >> 32), (uint32) ptr);
- pq_sendint32(&buf, len);
+ pq_senduint32(&buf, len);
pq_sendbytes(&buf, str, len);
len = snprintf(str, sizeof(str), "%u", tli);
- pq_sendint32(&buf, len);
+ pq_senduint32(&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 19451714da..9cf3d46f86 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -48,9 +48,9 @@ logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn)
pq_sendbyte(out, 'B'); /* BEGIN */
/* fixed fields */
- pq_sendint64(out, txn->final_lsn);
- pq_sendint64(out, txn->commit_time);
- pq_sendint32(out, txn->xid);
+ pq_senduint64(out, txn->final_lsn);
+ pq_senduint64(out, txn->commit_time);
+ pq_senduint32(out, txn->xid);
}
/*
@@ -83,9 +83,9 @@ logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn,
pq_sendbyte(out, flags);
/* send fields */
- pq_sendint64(out, commit_lsn);
- pq_sendint64(out, txn->end_lsn);
- pq_sendint64(out, txn->commit_time);
+ pq_senduint64(out, commit_lsn);
+ pq_senduint64(out, txn->end_lsn);
+ pq_senduint64(out, txn->commit_time);
}
/*
@@ -116,7 +116,7 @@ logicalrep_write_origin(StringInfo out, const char *origin,
pq_sendbyte(out, 'O'); /* ORIGIN */
/* fixed fields */
- pq_sendint64(out, origin_lsn);
+ pq_senduint64(out, origin_lsn);
/* origin string */
pq_sendstring(out, origin);
@@ -148,7 +148,7 @@ logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple)
rel->rd_rel->relreplident == REPLICA_IDENTITY_INDEX);
/* use Oid as relation identifier */
- pq_sendint32(out, RelationGetRelid(rel));
+ pq_senduint32(out, RelationGetRelid(rel));
pq_sendbyte(out, 'N'); /* new tuple follows */
logicalrep_write_tuple(out, rel, newtuple);
@@ -192,7 +192,7 @@ logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
rel->rd_rel->relreplident == REPLICA_IDENTITY_INDEX);
/* use Oid as relation identifier */
- pq_sendint32(out, RelationGetRelid(rel));
+ pq_senduint32(out, RelationGetRelid(rel));
if (oldtuple != NULL)
{
@@ -261,7 +261,7 @@ logicalrep_write_delete(StringInfo out, Relation rel, HeapTuple oldtuple)
pq_sendbyte(out, 'D'); /* action DELETE */
/* use Oid as relation identifier */
- pq_sendint32(out, RelationGetRelid(rel));
+ pq_senduint32(out, RelationGetRelid(rel));
if (rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL)
pq_sendbyte(out, 'O'); /* old tuple follows */
@@ -309,17 +309,17 @@ logicalrep_write_truncate(StringInfo out,
pq_sendbyte(out, 'T'); /* action TRUNCATE */
- pq_sendint32(out, nrelids);
+ pq_senduint32(out, nrelids);
/* encode and send truncate flags */
if (cascade)
flags |= TRUNCATE_CASCADE;
if (restart_seqs)
flags |= TRUNCATE_RESTART_SEQS;
- pq_sendint8(out, flags);
+ pq_senduint8(out, flags);
for (i = 0; i < nrelids; i++)
- pq_sendint32(out, relids[i]);
+ pq_senduint32(out, relids[i]);
}
/*
@@ -358,7 +358,7 @@ logicalrep_write_rel(StringInfo out, Relation rel)
pq_sendbyte(out, 'R'); /* sending RELATION */
/* use Oid as relation identifier */
- pq_sendint32(out, RelationGetRelid(rel));
+ pq_senduint32(out, RelationGetRelid(rel));
/* send qualified relation name */
logicalrep_write_namespace(out, RelationGetNamespace(rel));
@@ -415,7 +415,7 @@ logicalrep_write_typ(StringInfo out, Oid typoid)
typtup = (Form_pg_type) GETSTRUCT(tup);
/* use Oid as relation identifier */
- pq_sendint32(out, typoid);
+ pq_senduint32(out, typoid);
/* send qualified type name */
logicalrep_write_namespace(out, typtup->typnamespace);
@@ -457,7 +457,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple)
continue;
nliveatts++;
}
- pq_sendint16(out, nliveatts);
+ pq_senduint16(out, nliveatts);
/* try to allocate enough memory from the get-go */
enlargeStringInfo(out, tuple->t_len +
@@ -577,7 +577,7 @@ logicalrep_write_attrs(StringInfo out, Relation rel)
continue;
nliveatts++;
}
- pq_sendint16(out, nliveatts);
+ pq_senduint16(out, nliveatts);
/* fetch bitmap of REPLICATION IDENTITY attributes */
replidentfull = (rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL);
@@ -606,10 +606,10 @@ logicalrep_write_attrs(StringInfo out, Relation rel)
pq_sendstring(out, NameStr(att->attname));
/* attribute type id */
- pq_sendint32(out, (int) att->atttypid);
+ pq_senduint32(out, (int) att->atttypid);
/* attribute mode */
- pq_sendint32(out, att->atttypmod);
+ pq_senduint32(out, att->atttypmod);
}
bms_free(idattrs);
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 0d2b795e39..d05e267607 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1394,10 +1394,10 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply)
resetStringInfo(reply_message);
pq_sendbyte(reply_message, 'r');
- pq_sendint64(reply_message, recvpos); /* write */
- pq_sendint64(reply_message, flushpos); /* flush */
- pq_sendint64(reply_message, writepos); /* apply */
- pq_sendint64(reply_message, now); /* sendTime */
+ pq_senduint64(reply_message, recvpos); /* write */
+ pq_senduint64(reply_message, flushpos); /* flush */
+ pq_senduint64(reply_message, writepos); /* apply */
+ pq_senduint64(reply_message, now); /* sendTime */
pq_sendbyte(reply_message, requestReply); /* replyRequested */
elog(DEBUG2, "sending feedback (force %d) to recv %X/%X, write %X/%X, flush %X/%X",
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 987bb84683..1dec647871 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1164,10 +1164,10 @@ XLogWalRcvSendReply(bool force, bool requestReply)
resetStringInfo(&reply_message);
pq_sendbyte(&reply_message, 'r');
- pq_sendint64(&reply_message, writePtr);
- pq_sendint64(&reply_message, flushPtr);
- pq_sendint64(&reply_message, applyPtr);
- pq_sendint64(&reply_message, GetCurrentTimestamp());
+ pq_senduint64(&reply_message, writePtr);
+ pq_senduint64(&reply_message, flushPtr);
+ pq_senduint64(&reply_message, applyPtr);
+ pq_senduint64(&reply_message, GetCurrentTimestamp());
pq_sendbyte(&reply_message, requestReply ? 1 : 0);
/* Send it */
@@ -1285,11 +1285,11 @@ XLogWalRcvSendHSFeedback(bool immed)
/* Construct the message and send it. */
resetStringInfo(&reply_message);
pq_sendbyte(&reply_message, 'h');
- pq_sendint64(&reply_message, GetCurrentTimestamp());
- pq_sendint32(&reply_message, xmin);
- pq_sendint32(&reply_message, xmin_epoch);
- pq_sendint32(&reply_message, catalog_xmin);
- pq_sendint32(&reply_message, catalog_xmin_epoch);
+ pq_senduint64(&reply_message, GetCurrentTimestamp());
+ pq_senduint32(&reply_message, xmin);
+ pq_senduint32(&reply_message, xmin_epoch);
+ pq_senduint32(&reply_message, catalog_xmin);
+ pq_senduint32(&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 e47ddca6bc..0e4669dab2 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -445,32 +445,32 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
/* Send a RowDescription message */
pq_beginmessage(&buf, 'T');
- pq_sendint16(&buf, 2); /* 2 fields */
+ pq_senduint16(&buf, 2); /* 2 fields */
/* first field */
pq_sendstring(&buf, "filename"); /* col name */
- 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 */
+ pq_senduint32(&buf, 0); /* table oid */
+ pq_senduint16(&buf, 0); /* attnum */
+ pq_senduint32(&buf, TEXTOID); /* type oid */
+ pq_senduint16(&buf, -1); /* typlen */
+ pq_senduint32(&buf, 0); /* typmod */
+ pq_senduint16(&buf, 0); /* format code */
/* second field */
pq_sendstring(&buf, "content"); /* col name */
- 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_senduint32(&buf, 0); /* table oid */
+ pq_senduint16(&buf, 0); /* attnum */
+ pq_senduint32(&buf, BYTEAOID); /* type oid */
+ pq_senduint16(&buf, -1); /* typlen */
+ pq_senduint32(&buf, 0); /* typmod */
+ pq_senduint16(&buf, 0); /* format code */
pq_endmessage(&buf);
/* Send a DataRow message */
pq_beginmessage(&buf, 'D');
- pq_sendint16(&buf, 2); /* # of columns */
+ pq_senduint16(&buf, 2); /* # of columns */
len = strlen(histfname);
- pq_sendint32(&buf, len); /* col1 len */
+ pq_senduint32(&buf, len); /* col1 len */
pq_sendbytes(&buf, histfname, len);
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY);
@@ -490,7 +490,7 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
(errcode_for_file_access(),
errmsg("could not seek to beginning of file \"%s\": %m", path)));
- pq_sendint32(&buf, histfilelen); /* col2 len */
+ pq_senduint32(&buf, histfilelen); /* col2 len */
bytesleft = histfilelen;
while (bytesleft > 0)
@@ -647,7 +647,7 @@ StartReplication(StartReplicationCmd *cmd)
/* Send a CopyBothResponse message, and start streaming */
pq_beginmessage(&buf, 'W');
pq_sendbyte(&buf, 0);
- pq_sendint16(&buf, 0);
+ pq_senduint16(&buf, 0);
pq_endmessage(&buf);
pq_flush();
@@ -1066,7 +1066,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
/* Send a CopyBothResponse message, and start streaming */
pq_beginmessage(&buf, 'W');
pq_sendbyte(&buf, 0);
- pq_sendint16(&buf, 0);
+ pq_senduint16(&buf, 0);
pq_endmessage(&buf);
pq_flush();
@@ -1132,14 +1132,14 @@ WalSndPrepareWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xi
resetStringInfo(ctx->out);
pq_sendbyte(ctx->out, 'w');
- pq_sendint64(ctx->out, lsn); /* dataStart */
- pq_sendint64(ctx->out, lsn); /* walEnd */
+ pq_senduint64(ctx->out, lsn); /* dataStart */
+ pq_senduint64(ctx->out, lsn); /* walEnd */
/*
* Fill out the sendtime later, just as it's done in XLogSendPhysical, but
* reserve space here.
*/
- pq_sendint64(ctx->out, 0); /* sendtime */
+ pq_senduint64(ctx->out, 0); /* sendtime */
}
/*
@@ -1165,7 +1165,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
*/
resetStringInfo(&tmpbuf);
now = GetCurrentTimestamp();
- pq_sendint64(&tmpbuf, now);
+ pq_senduint64(&tmpbuf, now);
memcpy(&ctx->out->data[1 + sizeof(int64) + sizeof(int64)],
tmpbuf.data, sizeof(int64));
@@ -2701,9 +2701,9 @@ XLogSendPhysical(void)
resetStringInfo(&output_message);
pq_sendbyte(&output_message, 'w');
- pq_sendint64(&output_message, startptr); /* dataStart */
- pq_sendint64(&output_message, SendRqstPtr); /* walEnd */
- pq_sendint64(&output_message, 0); /* sendtime, filled in last */
+ pq_senduint64(&output_message, startptr); /* dataStart */
+ pq_senduint64(&output_message, SendRqstPtr); /* walEnd */
+ pq_senduint64(&output_message, 0); /* sendtime, filled in last */
/*
* Read the log directly into the output buffer to avoid extra memcpy
@@ -2718,7 +2718,7 @@ XLogSendPhysical(void)
* Fill the send timestamp last, so that it is taken as late as possible.
*/
resetStringInfo(&tmpbuf);
- pq_sendint64(&tmpbuf, GetCurrentTimestamp());
+ pq_senduint64(&tmpbuf, GetCurrentTimestamp());
memcpy(&output_message.data[1 + sizeof(int64) + sizeof(int64)],
tmpbuf.data, sizeof(int64));
@@ -3339,8 +3339,8 @@ WalSndKeepalive(bool requestReply)
/* construct the message... */
resetStringInfo(&output_message);
pq_sendbyte(&output_message, 'k');
- pq_sendint64(&output_message, sentPtr);
- pq_sendint64(&output_message, GetCurrentTimestamp());
+ pq_senduint64(&output_message, sentPtr);
+ pq_senduint64(&output_message, GetCurrentTimestamp());
pq_sendbyte(&output_message, requestReply ? 1 : 0);
/* ... and send it wrapped in CopyData */
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index d16ba5ec92..0be7749063 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_sendint32(&buf, -1);
+ pq_senduint32(&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_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ);
+ pq_senduint32(&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 f4133953be..ff20f5b156 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2382,13 +2382,13 @@ exec_describe_statement_message(const char *stmt_name)
*/
pq_beginmessage_reuse(&row_description_buf, 't'); /* parameter description
* message type */
- pq_sendint16(&row_description_buf, psrc->num_params);
+ pq_senduint16(&row_description_buf, psrc->num_params);
for (i = 0; i < psrc->num_params; i++)
{
Oid ptype = psrc->param_types[i];
- pq_sendint32(&row_description_buf, (int) ptype);
+ pq_senduint32(&row_description_buf, (uint32) ptype);
}
pq_endmessage_reuse(&row_description_buf);
@@ -3826,8 +3826,8 @@ PostgresMain(int argc, char *argv[],
StringInfoData buf;
pq_beginmessage(&buf, 'K');
- pq_sendint32(&buf, (int32) MyProcPid);
- pq_sendint32(&buf, (int32) MyCancelKey);
+ pq_senduint32(&buf, (uint32) MyProcPid);
+ pq_senduint32(&buf, (uint32) 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 0cbdbe5587..8209203bcd 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_sendint32(&buf, ndim);
- pq_sendint32(&buf, AARR_HASNULL(v) ? 1 : 0);
- pq_sendint32(&buf, element_type);
+ pq_senduint32(&buf, ndim);
+ pq_senduint32(&buf, AARR_HASNULL(v) ? 1 : 0);
+ pq_senduint32(&buf, element_type);
for (i = 0; i < ndim; i++)
{
- pq_sendint32(&buf, dim[i]);
- pq_sendint32(&buf, lb[i]);
+ pq_senduint32(&buf, dim[i]);
+ pq_senduint32(&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_sendint32(&buf, -1);
+ pq_senduint32(&buf, -1);
}
else
{
bytea *outputbytes;
outputbytes = SendFunctionCall(&my_extra->proc, itemvalue);
- pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ);
+ pq_senduint32(&buf, VARSIZE(outputbytes) - VARHDRSZ);
pq_sendbytes(&buf, VARDATA(outputbytes),
VARSIZE(outputbytes) - VARHDRSZ);
pfree(outputbytes);
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c
index c787dd3419..2e4d8022bb 100644
--- a/src/backend/utils/adt/cash.c
+++ b/src/backend/utils/adt/cash.c
@@ -527,7 +527,7 @@ cash_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, arg1);
+ pq_senduint64(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 87146a2161..94d878f8c4 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -237,7 +237,7 @@ date_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint32(&buf, date);
+ pq_senduint32(&buf, date);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -1341,7 +1341,7 @@ time_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, time);
+ pq_senduint64(&buf, time);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -2113,8 +2113,8 @@ timetz_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, time->time);
- pq_sendint32(&buf, time->zone);
+ pq_senduint64(&buf, time->time);
+ pq_senduint32(&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 f57380a4df..a9d59612f8 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -1432,7 +1432,7 @@ path_send(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
pq_sendbyte(&buf, path->closed ? 1 : 0);
- pq_sendint32(&buf, path->npts);
+ pq_senduint32(&buf, path->npts);
for (i = 0; i < path->npts; i++)
{
pq_sendfloat8(&buf, path->p[i].x);
@@ -3513,7 +3513,7 @@ poly_send(PG_FUNCTION_ARGS)
int32 i;
pq_begintypsend(&buf);
- pq_sendint32(&buf, poly->npts);
+ pq_senduint32(&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 02783d8d6f..5c901e961e 100644
--- a/src/backend/utils/adt/int.c
+++ b/src/backend/utils/adt/int.c
@@ -97,7 +97,7 @@ int2send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint16(&buf, arg1);
+ pq_senduint16(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -302,7 +302,7 @@ int4send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint32(&buf, arg1);
+ pq_senduint32(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 96686ccb2c..0ce9994cf3 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -175,7 +175,7 @@ int8send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, arg1);
+ pq_senduint64(&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 6940b11c29..9e4a25a73c 100644
--- a/src/backend/utils/adt/jsonb.c
+++ b/src/backend/utils/adt/jsonb.c
@@ -155,7 +155,7 @@ jsonb_send(PG_FUNCTION_ARGS)
(void) JsonbToCString(jtext, &jb->root, VARSIZE(jb));
pq_begintypsend(&buf);
- pq_sendint8(&buf, version);
+ pq_senduint8(&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 fae97135db..c45122a59a 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_sendint32(&buf, time);
+ pq_senduint32(&buf, time);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -674,7 +674,7 @@ reltimesend(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint32(&buf, time);
+ pq_senduint32(&buf, time);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -794,9 +794,9 @@ tintervalsend(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint32(&buf, tinterval->status);
- pq_sendint32(&buf, tinterval->data[0]);
- pq_sendint32(&buf, tinterval->data[1]);
+ pq_senduint32(&buf, tinterval->status);
+ pq_senduint32(&buf, tinterval->data[0]);
+ pq_senduint32(&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 074294cbcc..6a12ba8cb7 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -877,12 +877,12 @@ numeric_send(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
- pq_sendint16(&buf, x.ndigits);
- pq_sendint16(&buf, x.weight);
- pq_sendint16(&buf, x.sign);
- pq_sendint16(&buf, x.dscale);
+ pq_senduint16(&buf, x.ndigits);
+ pq_senduint16(&buf, x.weight);
+ pq_senduint16(&buf, x.sign);
+ pq_senduint16(&buf, x.dscale);
for (i = 0; i < x.ndigits; i++)
- pq_sendint16(&buf, x.digits[i]);
+ pq_senduint16(&buf, x.digits[i]);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -3781,19 +3781,19 @@ numeric_avg_serialize(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
/* N */
- pq_sendint64(&buf, state->N);
+ pq_senduint64(&buf, state->N);
/* sumX */
pq_sendbytes(&buf, VARDATA_ANY(sumX), VARSIZE_ANY_EXHDR(sumX));
/* maxScale */
- pq_sendint32(&buf, state->maxScale);
+ pq_senduint32(&buf, state->maxScale);
/* maxScaleCount */
- pq_sendint64(&buf, state->maxScaleCount);
+ pq_senduint64(&buf, state->maxScaleCount);
/* NaNcount */
- pq_sendint64(&buf, state->NaNcount);
+ pq_senduint64(&buf, state->NaNcount);
result = pq_endtypsend(&buf);
@@ -3900,7 +3900,7 @@ numeric_serialize(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
/* N */
- pq_sendint64(&buf, state->N);
+ pq_senduint64(&buf, state->N);
/* sumX */
pq_sendbytes(&buf, VARDATA_ANY(sumX), VARSIZE_ANY_EXHDR(sumX));
@@ -3909,13 +3909,13 @@ numeric_serialize(PG_FUNCTION_ARGS)
pq_sendbytes(&buf, VARDATA_ANY(sumX2), VARSIZE_ANY_EXHDR(sumX2));
/* maxScale */
- pq_sendint32(&buf, state->maxScale);
+ pq_senduint32(&buf, state->maxScale);
/* maxScaleCount */
- pq_sendint64(&buf, state->maxScaleCount);
+ pq_senduint64(&buf, state->maxScaleCount);
/* NaNcount */
- pq_sendint64(&buf, state->NaNcount);
+ pq_senduint64(&buf, state->NaNcount);
result = pq_endtypsend(&buf);
@@ -4307,7 +4307,7 @@ numeric_poly_serialize(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
/* N */
- pq_sendint64(&buf, state->N);
+ pq_senduint64(&buf, state->N);
/* sumX */
pq_sendbytes(&buf, VARDATA_ANY(sumX), VARSIZE_ANY_EXHDR(sumX));
@@ -4523,7 +4523,7 @@ int8_avg_serialize(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
/* N */
- pq_sendint64(&buf, state->N);
+ pq_senduint64(&buf, state->N);
/* sumX */
pq_sendbytes(&buf, VARDATA_ANY(sumX), VARSIZE_ANY_EXHDR(sumX));
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index b0670e0d9f..5a0a206c6a 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_sendint32(&buf, arg1);
+ pq_senduint32(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
diff --git a/src/backend/utils/adt/pg_lsn.c b/src/backend/utils/adt/pg_lsn.c
index f4eae9d83d..ea6ceb294f 100644
--- a/src/backend/utils/adt/pg_lsn.c
+++ b/src/backend/utils/adt/pg_lsn.c
@@ -93,7 +93,7 @@ pg_lsn_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, lsn);
+ pq_senduint64(&buf, lsn);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index 5a5d0a0b8f..acdbaa3ff7 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_sendint32(buf, bound_len);
+ pq_senduint32(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_sendint32(buf, bound_len);
+ pq_senduint32(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 5f729342f8..50c15a7cc5 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_sendint32(&buf, validcols);
+ pq_senduint32(&buf, validcols);
for (i = 0; i < ncolumns; i++)
{
@@ -732,12 +732,12 @@ record_send(PG_FUNCTION_ARGS)
if (att->attisdropped)
continue;
- pq_sendint32(&buf, column_type);
+ pq_senduint32(&buf, column_type);
if (nulls[i])
{
/* emit -1 data length to signify a NULL */
- pq_sendint32(&buf, -1);
+ pq_senduint32(&buf, -1);
continue;
}
@@ -756,7 +756,7 @@ record_send(PG_FUNCTION_ARGS)
attr = values[i];
outputbytes = SendFunctionCall(&column_info->proc, attr);
- pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ);
+ pq_senduint32(&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 41d540b46e..0e91944ce9 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -149,8 +149,8 @@ tidsend(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint32(&buf, ItemPointerGetBlockNumberNoCheck(itemPtr));
- pq_sendint16(&buf, ItemPointerGetOffsetNumberNoCheck(itemPtr));
+ pq_senduint32(&buf, ItemPointerGetBlockNumberNoCheck(itemPtr));
+ pq_senduint16(&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 1d75caebe1..c224cbb324 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -276,7 +276,7 @@ timestamp_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, timestamp);
+ pq_senduint64(&buf, timestamp);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -826,7 +826,7 @@ timestamptz_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, timestamp);
+ pq_senduint64(&buf, timestamp);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -1008,9 +1008,9 @@ interval_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, interval->time);
- pq_sendint32(&buf, interval->day);
- pq_sendint32(&buf, interval->month);
+ pq_senduint64(&buf, interval->time);
+ pq_senduint32(&buf, interval->day);
+ pq_senduint32(&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 7b9dbfef0c..55f92d4fc4 100644
--- a/src/backend/utils/adt/tsquery.c
+++ b/src/backend/utils/adt/tsquery.c
@@ -1180,22 +1180,22 @@ tsquerysend(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
- pq_sendint32(&buf, query->size);
+ pq_senduint32(&buf, query->size);
for (i = 0; i < query->size; i++)
{
- pq_sendint8(&buf, item->type);
+ pq_senduint8(&buf, item->type);
switch (item->type)
{
case QI_VAL:
- pq_sendint8(&buf, item->qoperand.weight);
- pq_sendint8(&buf, item->qoperand.prefix);
+ pq_senduint8(&buf, item->qoperand.weight);
+ pq_senduint8(&buf, item->qoperand.prefix);
pq_sendstring(&buf, GETOPERAND(query) + item->qoperand.distance);
break;
case QI_OPR:
- pq_sendint8(&buf, item->qoperator.oper);
+ pq_senduint8(&buf, item->qoperator.oper);
if (item->qoperator.oper == OP_PHRASE)
- pq_sendint16(&buf, item->qoperator.distance);
+ pq_senduint16(&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 7a27bd12a3..630dade232 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_sendint32(&buf, vec->size);
+ pq_senduint32(&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_sendint16(&buf, npos);
+ pq_senduint16(&buf, npos);
if (npos > 0)
{
WordEntryPos *wepptr = POSDATAPTR(vec, weptr);
for (j = 0; j < npos; j++)
- pq_sendint16(&buf, wepptr[j]);
+ pq_senduint16(&buf, wepptr[j]);
}
weptr++;
}
diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c
index 7974c0bd3d..d5210c6554 100644
--- a/src/backend/utils/adt/txid.c
+++ b/src/backend/utils/adt/txid.c
@@ -640,11 +640,11 @@ txid_snapshot_send(PG_FUNCTION_ARGS)
uint32 i;
pq_begintypsend(&buf);
- pq_sendint32(&buf, snap->nxip);
- pq_sendint64(&buf, snap->xmin);
- pq_sendint64(&buf, snap->xmax);
+ pq_senduint32(&buf, snap->nxip);
+ pq_senduint64(&buf, snap->xmin);
+ pq_senduint64(&buf, snap->xmax);
for (i = 0; i < snap->nxip; i++)
- pq_sendint64(&buf, snap->xip[i]);
+ pq_senduint64(&buf, snap->xip[i]);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index 6ba400b699..739c248f72 100644
--- a/src/backend/utils/adt/varbit.c
+++ b/src/backend/utils/adt/varbit.c
@@ -666,7 +666,7 @@ varbit_send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint32(&buf, VARBITLEN(s));
+ pq_senduint32(&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 1e811faa9c..9ec288d86e 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_sendint32(&buf, arg1);
+ pq_senduint32(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -196,7 +196,7 @@ cidsend(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint32(&buf, arg1);
+ pq_senduint32(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
diff --git a/src/include/libpq/pqformat.h b/src/include/libpq/pqformat.h
index 57bde691e8..cb2570569e 100644
--- a/src/include/libpq/pqformat.h
+++ b/src/include/libpq/pqformat.h
@@ -47,41 +47,41 @@ extern void pq_sendfloat8(StringInfo buf, float8 f);
* overly picky and demanding a * before a restrict.
*/
static inline void
-pq_writeint8(StringInfoData *pg_restrict buf, int8 i)
+pq_writeuint8(StringInfoData *pg_restrict buf, uint8 i)
{
int8 ni = i;
- Assert(buf->len + (int) sizeof(int8) <= buf->maxlen);
- memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int8));
- buf->len += sizeof(int8);
+ Assert(buf->len + (int) sizeof(uint8) <= buf->maxlen);
+ memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint8));
+ buf->len += sizeof(uint8);
}
/*
- * Append an int16 to a StringInfo buffer, which already has enough space
+ * Append an uint16 to a StringInfo buffer, which already has enough space
* preallocated.
*/
static inline void
-pq_writeint16(StringInfoData *pg_restrict buf, int16 i)
+pq_writeuint16(StringInfoData *pg_restrict buf, uint16 i)
{
- int16 ni = pg_hton16(i);
+ uint16 ni = pg_hton16(i);
- Assert(buf->len + (int) sizeof(int16) <= buf->maxlen);
- memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int16));
- buf->len += sizeof(int16);
+ Assert(buf->len + (int) sizeof(uint16) <= buf->maxlen);
+ memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint16));
+ buf->len += sizeof(uint16);
}
/*
- * Append an int32 to a StringInfo buffer, which already has enough space
+ * Append an uint32 to a StringInfo buffer, which already has enough space
* preallocated.
*/
static inline void
-pq_writeint32(StringInfoData *pg_restrict buf, int32 i)
+pq_writeuint32(StringInfoData *pg_restrict buf, uint32 i)
{
- int32 ni = pg_hton32(i);
+ uint32 ni = pg_hton32(i);
- Assert(buf->len + (int) sizeof(int32) <= buf->maxlen);
- memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int32));
- buf->len += sizeof(int32);
+ Assert(buf->len + (int) sizeof(uint32) <= buf->maxlen);
+ memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint32));
+ buf->len += sizeof(uint32);
}
/*
@@ -89,13 +89,13 @@ pq_writeint32(StringInfoData *pg_restrict buf, int32 i)
* preallocated.
*/
static inline void
-pq_writeint64(StringInfoData *pg_restrict buf, int64 i)
+pq_writeuint64(StringInfoData *pg_restrict buf, uint64 i)
{
- int64 ni = pg_hton64(i);
+ uint64 ni = pg_hton64(i);
- Assert(buf->len + (int) sizeof(int64) <= buf->maxlen);
- memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int64));
- buf->len += sizeof(int64);
+ Assert(buf->len + (int) sizeof(uint64) <= buf->maxlen);
+ memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint64));
+ buf->len += sizeof(uint64);
}
/*
@@ -127,43 +127,51 @@ pq_writestring(StringInfoData *pg_restrict buf, const char *pg_restrict str)
pfree(p);
}
-/* append a binary int8 to a StringInfo buffer */
+/* append a binary uint8 to a StringInfo buffer */
static inline void
-pq_sendint8(StringInfo buf, int8 i)
+pq_senduint8(StringInfo buf, uint8 i)
{
- enlargeStringInfo(buf, sizeof(int8));
- pq_writeint8(buf, i);
+ enlargeStringInfo(buf, sizeof(uint8));
+ pq_writeuint8(buf, i);
}
-/* append a binary int16 to a StringInfo buffer */
+/* append a binary uint16 to a StringInfo buffer */
static inline void
-pq_sendint16(StringInfo buf, int16 i)
+pq_senduint16(StringInfo buf, uint16 i)
{
- enlargeStringInfo(buf, sizeof(int16));
- pq_writeint16(buf, i);
+ enlargeStringInfo(buf, sizeof(uint16));
+ pq_writeuint16(buf, i);
}
-/* append a binary int32 to a StringInfo buffer */
+/* append a binary uint32 to a StringInfo buffer */
static inline void
-pq_sendint32(StringInfo buf, int32 i)
+pq_senduint32(StringInfo buf, uint32 i)
{
- enlargeStringInfo(buf, sizeof(int32));
- pq_writeint32(buf, i);
+ enlargeStringInfo(buf, sizeof(uint32));
+ pq_writeuint32(buf, i);
}
-/* append a binary int64 to a StringInfo buffer */
+/* append a binary uint64 to a StringInfo buffer */
+static inline void
+pq_senduint64(StringInfo buf, uint64 i)
+{
+ enlargeStringInfo(buf, sizeof(uint64));
+ pq_writeuint64(buf, i);
+}
+
+/* append a binary int64 to a StringInfo buffer, kept for compatibility */
static inline void
pq_sendint64(StringInfo buf, int64 i)
{
enlargeStringInfo(buf, sizeof(int64));
- pq_writeint64(buf, i);
+ pq_writeuint64(buf, (uint64) i);
}
/* append a binary byte to a StringInfo buffer */
static inline void
-pq_sendbyte(StringInfo buf, int8 byt)
+pq_sendbyte(StringInfo buf, uint8 byt)
{
- pq_sendint8(buf, byt);
+ pq_senduint8(buf, byt);
}
/*
@@ -177,13 +185,13 @@ pq_sendint(StringInfo buf, int i, int b)
switch (b)
{
case 1:
- pq_sendint8(buf, (int8) i);
+ pq_senduint8(buf, (uint8) i);
break;
case 2:
- pq_sendint16(buf, (int16) i);
+ pq_senduint16(buf, (uint16) i);
break;
case 4:
- pq_sendint32(buf, (int32) i);
+ pq_senduint32(buf, (uint32) i);
break;
default:
elog(ERROR, "unsupported integer size %d", b);
signature.asc
Description: PGP signature
