diff options
author | Andres Freund | 2017-10-12 04:00:46 +0000 |
---|---|---|
committer | Andres Freund | 2017-10-12 04:00:46 +0000 |
commit | 31079a4a8e66e56e48bad94d380fa6224e9ffa0d (patch) | |
tree | 47f68a2def80fca4dd2a5d076bac89dfb2c33102 /src/backend/utils | |
parent | 52328727bea4d9f95af9622e4624b9d1492df88e (diff) |
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/[email protected]
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 14 | ||||
-rw-r--r-- | src/backend/utils/adt/date.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/geo_ops.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/int.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonb.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/nabstime.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/numeric.c | 14 | ||||
-rw-r--r-- | src/backend/utils/adt/oid.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/rangetypes.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/rowtypes.c | 8 | ||||
-rw-r--r-- | src/backend/utils/adt/tid.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/tsquery.c | 13 | ||||
-rw-r--r-- | src/backend/utils/adt/tsvector.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/txid.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/varbit.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/xid.c | 4 |
17 files changed, 50 insertions, 53 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index ca04b13e825..b4c31ef65c2 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -1590,13 +1590,13 @@ array_send(PG_FUNCTION_ARGS) pq_begintypsend(&buf); /* Send the array header information */ - pq_sendint(&buf, ndim, 4); - pq_sendint(&buf, AARR_HASNULL(v) ? 1 : 0, 4); - pq_sendint(&buf, element_type, sizeof(Oid)); + pq_sendint32(&buf, ndim); + pq_sendint32(&buf, AARR_HASNULL(v) ? 1 : 0); + pq_sendint32(&buf, element_type); for (i = 0; i < ndim; i++) { - pq_sendint(&buf, dim[i], 4); - pq_sendint(&buf, lb[i], 4); + pq_sendint32(&buf, dim[i]); + pq_sendint32(&buf, lb[i]); } /* Send the array elements using the element's own sendproc */ @@ -1614,14 +1614,14 @@ array_send(PG_FUNCTION_ARGS) if (isnull) { /* -1 length means a NULL */ - pq_sendint(&buf, -1, 4); + pq_sendint32(&buf, -1); } else { bytea *outputbytes; outputbytes = SendFunctionCall(&my_extra->proc, itemvalue); - pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4); + pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(&buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); pfree(outputbytes); diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 0992bb3fdd0..04e737d0808 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -239,7 +239,7 @@ date_send(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, date, sizeof(date)); + pq_sendint32(&buf, date); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } @@ -2049,7 +2049,7 @@ timetz_send(PG_FUNCTION_ARGS) pq_begintypsend(&buf); pq_sendint64(&buf, time->time); - pq_sendint(&buf, time->zone, sizeof(time->zone)); + pq_sendint32(&buf, time->zone); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 0348855b11c..e13389a6cc7 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -1433,7 +1433,7 @@ path_send(PG_FUNCTION_ARGS) pq_begintypsend(&buf); pq_sendbyte(&buf, path->closed ? 1 : 0); - pq_sendint(&buf, path->npts, sizeof(int32)); + pq_sendint32(&buf, path->npts); for (i = 0; i < path->npts; i++) { pq_sendfloat8(&buf, path->p[i].x); @@ -3514,7 +3514,7 @@ poly_send(PG_FUNCTION_ARGS) int32 i; pq_begintypsend(&buf); - pq_sendint(&buf, poly->npts, sizeof(int32)); + pq_sendint32(&buf, poly->npts); for (i = 0; i < poly->npts; i++) { pq_sendfloat8(&buf, poly->p[i].x); diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index 96ef25b900e..4cd8960b3fc 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -99,7 +99,7 @@ int2send(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, arg1, sizeof(int16)); + pq_sendint16(&buf, arg1); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } @@ -304,7 +304,7 @@ int4send(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, arg1, sizeof(int32)); + pq_sendint32(&buf, arg1); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index 95db8955389..771c05120bb 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -154,7 +154,7 @@ jsonb_send(PG_FUNCTION_ARGS) (void) JsonbToCString(jtext, &jb->root, VARSIZE(jb)); pq_begintypsend(&buf); - pq_sendint(&buf, version, 1); + pq_sendint8(&buf, version); pq_sendtext(&buf, jtext->data, jtext->len); pfree(jtext->data); pfree(jtext); diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 2c5948052d3..2bca39a90cc 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -315,7 +315,7 @@ abstimesend(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, time, sizeof(time)); + pq_sendint32(&buf, time); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } @@ -674,7 +674,7 @@ reltimesend(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, time, sizeof(time)); + pq_sendint32(&buf, time); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } @@ -794,9 +794,9 @@ tintervalsend(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, tinterval->status, sizeof(tinterval->status)); - pq_sendint(&buf, tinterval->data[0], sizeof(tinterval->data[0])); - pq_sendint(&buf, tinterval->data[1], sizeof(tinterval->data[1])); + pq_sendint32(&buf, tinterval->status); + pq_sendint32(&buf, tinterval->data[0]); + pq_sendint32(&buf, tinterval->data[1]); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 48d95e90501..2cd14f34012 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -876,12 +876,12 @@ numeric_send(PG_FUNCTION_ARGS) pq_begintypsend(&buf); - pq_sendint(&buf, x.ndigits, sizeof(int16)); - pq_sendint(&buf, x.weight, sizeof(int16)); - pq_sendint(&buf, x.sign, sizeof(int16)); - pq_sendint(&buf, x.dscale, sizeof(int16)); + pq_sendint16(&buf, x.ndigits); + pq_sendint16(&buf, x.weight); + pq_sendint16(&buf, x.sign); + pq_sendint16(&buf, x.dscale); for (i = 0; i < x.ndigits; i++) - pq_sendint(&buf, x.digits[i], sizeof(NumericDigit)); + pq_sendint16(&buf, x.digits[i]); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } @@ -3693,7 +3693,7 @@ numeric_avg_serialize(PG_FUNCTION_ARGS) pq_sendbytes(&buf, VARDATA_ANY(sumX), VARSIZE_ANY_EXHDR(sumX)); /* maxScale */ - pq_sendint(&buf, state->maxScale, 4); + pq_sendint32(&buf, state->maxScale); /* maxScaleCount */ pq_sendint64(&buf, state->maxScaleCount); @@ -3815,7 +3815,7 @@ numeric_serialize(PG_FUNCTION_ARGS) pq_sendbytes(&buf, VARDATA_ANY(sumX2), VARSIZE_ANY_EXHDR(sumX2)); /* maxScale */ - pq_sendint(&buf, state->maxScale, 4); + pq_sendint32(&buf, state->maxScale); /* maxScaleCount */ pq_sendint64(&buf, state->maxScaleCount); diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index 7baaa1dd4ee..87e87fe54d5 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -154,7 +154,7 @@ oidsend(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, arg1, sizeof(Oid)); + pq_sendint32(&buf, arg1); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c index d0aa33c010b..e79f0dbfca6 100644 --- a/src/backend/utils/adt/rangetypes.c +++ b/src/backend/utils/adt/rangetypes.c @@ -272,7 +272,7 @@ range_send(PG_FUNCTION_ARGS) uint32 bound_len = VARSIZE(bound) - VARHDRSZ; char *bound_data = VARDATA(bound); - pq_sendint(buf, bound_len, 4); + pq_sendint32(buf, bound_len); pq_sendbytes(buf, bound_data, bound_len); } @@ -283,7 +283,7 @@ range_send(PG_FUNCTION_ARGS) uint32 bound_len = VARSIZE(bound) - VARHDRSZ; char *bound_data = VARDATA(bound); - pq_sendint(buf, bound_len, 4); + pq_sendint32(buf, bound_len); pq_sendbytes(buf, bound_data, bound_len); } diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index 98fe00ff394..9b32db5d0ae 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -718,7 +718,7 @@ record_send(PG_FUNCTION_ARGS) if (!TupleDescAttr(tupdesc, i)->attisdropped) validcols++; } - pq_sendint(&buf, validcols, 4); + pq_sendint32(&buf, validcols); for (i = 0; i < ncolumns; i++) { @@ -732,12 +732,12 @@ record_send(PG_FUNCTION_ARGS) if (att->attisdropped) continue; - pq_sendint(&buf, column_type, sizeof(Oid)); + pq_sendint32(&buf, column_type); if (nulls[i]) { /* emit -1 data length to signify a NULL */ - pq_sendint(&buf, -1, 4); + pq_sendint32(&buf, -1); continue; } @@ -756,7 +756,7 @@ record_send(PG_FUNCTION_ARGS) attr = values[i]; outputbytes = SendFunctionCall(&column_info->proc, attr); - pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4); + pq_sendint32(&buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(&buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); } diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 083f7d60a7b..854097dd583 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -149,10 +149,8 @@ tidsend(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, ItemPointerGetBlockNumberNoCheck(itemPtr), - sizeof(BlockNumber)); - pq_sendint(&buf, ItemPointerGetOffsetNumberNoCheck(itemPtr), - sizeof(OffsetNumber)); + pq_sendint32(&buf, ItemPointerGetBlockNumberNoCheck(itemPtr)); + pq_sendint16(&buf, ItemPointerGetOffsetNumberNoCheck(itemPtr)); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index b11d452fc8a..5797aaad34c 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -1009,8 +1009,8 @@ interval_send(PG_FUNCTION_ARGS) pq_begintypsend(&buf); pq_sendint64(&buf, interval->time); - pq_sendint(&buf, interval->day, sizeof(interval->day)); - pq_sendint(&buf, interval->month, sizeof(interval->month)); + pq_sendint32(&buf, interval->day); + pq_sendint32(&buf, interval->month); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c index fdb041971e5..5cdfe4d7322 100644 --- a/src/backend/utils/adt/tsquery.c +++ b/src/backend/utils/adt/tsquery.c @@ -952,23 +952,22 @@ tsquerysend(PG_FUNCTION_ARGS) pq_begintypsend(&buf); - pq_sendint(&buf, query->size, sizeof(uint32)); + pq_sendint32(&buf, query->size); for (i = 0; i < query->size; i++) { - pq_sendint(&buf, item->type, sizeof(item->type)); + pq_sendint8(&buf, item->type); switch (item->type) { case QI_VAL: - pq_sendint(&buf, item->qoperand.weight, sizeof(uint8)); - pq_sendint(&buf, item->qoperand.prefix, sizeof(uint8)); + pq_sendint8(&buf, item->qoperand.weight); + pq_sendint8(&buf, item->qoperand.prefix); pq_sendstring(&buf, GETOPERAND(query) + item->qoperand.distance); break; case QI_OPR: - pq_sendint(&buf, item->qoperator.oper, sizeof(item->qoperator.oper)); + pq_sendint8(&buf, item->qoperator.oper); if (item->qoperator.oper == OP_PHRASE) - pq_sendint(&buf, item->qoperator.distance, - sizeof(item->qoperator.distance)); + pq_sendint16(&buf, item->qoperator.distance); break; default: elog(ERROR, "unrecognized tsquery node type: %d", item->type); diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c index 6f66c1f58ce..b0a9217d1e3 100644 --- a/src/backend/utils/adt/tsvector.c +++ b/src/backend/utils/adt/tsvector.c @@ -410,7 +410,7 @@ tsvectorsend(PG_FUNCTION_ARGS) pq_begintypsend(&buf); - pq_sendint(&buf, vec->size, sizeof(int32)); + pq_sendint32(&buf, vec->size); for (i = 0; i < vec->size; i++) { uint16 npos; @@ -423,14 +423,14 @@ tsvectorsend(PG_FUNCTION_ARGS) pq_sendbyte(&buf, '\0'); npos = POSDATALEN(vec, weptr); - pq_sendint(&buf, npos, sizeof(uint16)); + pq_sendint16(&buf, npos); if (npos > 0) { WordEntryPos *wepptr = POSDATAPTR(vec, weptr); for (j = 0; j < npos; j++) - pq_sendint(&buf, wepptr[j], sizeof(WordEntryPos)); + pq_sendint16(&buf, wepptr[j]); } weptr++; } diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c index 1e38ca2aa5e..9d312edf04f 100644 --- a/src/backend/utils/adt/txid.c +++ b/src/backend/utils/adt/txid.c @@ -640,7 +640,7 @@ txid_snapshot_send(PG_FUNCTION_ARGS) uint32 i; pq_begintypsend(&buf); - pq_sendint(&buf, snap->nxip, 4); + pq_sendint32(&buf, snap->nxip); pq_sendint64(&buf, snap->xmin); pq_sendint64(&buf, snap->xmax); for (i = 0; i < snap->nxip; i++) diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 0cf1c6f6d60..478fab9bfce 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -665,7 +665,7 @@ varbit_send(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, VARBITLEN(s), sizeof(int32)); + pq_sendint32(&buf, VARBITLEN(s)); pq_sendbytes(&buf, (char *) VARBITS(s), VARBITBYTES(s)); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c index 2051709fdef..67c32ac6193 100644 --- a/src/backend/utils/adt/xid.c +++ b/src/backend/utils/adt/xid.c @@ -68,7 +68,7 @@ xidsend(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, arg1, sizeof(arg1)); + pq_sendint32(&buf, arg1); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } @@ -196,7 +196,7 @@ cidsend(PG_FUNCTION_ARGS) StringInfoData buf; pq_begintypsend(&buf); - pq_sendint(&buf, arg1, sizeof(arg1)); + pq_sendint32(&buf, arg1); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } |