aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/arrayfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-09-18 15:21:23 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-09-18 15:21:23 -0400
commit4bd1994650fddf49e717e35f1930d62208845974 (patch)
tree0c6353be3e707d1ccfc7bca07ca87ca5fed1bcd8 /src/backend/utils/adt/arrayfuncs.c
parent3e1683d37e1d751eb2df9a5cb0507bebc6cf7d05 (diff)
downloadpostgresql-4bd1994650fddf49e717e35f1930d62208845974.tar.gz
postgresql-4bd1994650fddf49e717e35f1930d62208845974.zip
Make DatumGetFoo/PG_GETARG_FOO/PG_RETURN_FOO macro names more consistent.
By project convention, these names should include "P" when dealing with a pointer type; that is, if the result of a GETARG macro is of type FOO *, it should be called PG_GETARG_FOO_P not just PG_GETARG_FOO. Some newer types such as JSONB and ranges had not followed the convention, and a number of contrib modules hadn't gotten that memo either. Rename the offending macros to improve consistency. In passing, fix a few places that thought PG_DETOAST_DATUM() returns a Datum; it does not, it returns "struct varlena *". Applying DatumGetPointer to that happens not to cause any bad effects today, but it's formally wrong. Also, adjust an ltree macro that was designed without any thought for what pgindent would do with it. This is all cosmetic and shouldn't have any impact on generated code. Mark Dilger, some further tweaks by me Discussion: https://postgr.es/m/EA5676F4-766F-4F38-8348-ECC7DB427C6A@gmail.com
Diffstat (limited to 'src/backend/utils/adt/arrayfuncs.c')
-rw-r--r--src/backend/utils/adt/arrayfuncs.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 2a4de41bbc0..e4101c9af0c 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -1011,7 +1011,7 @@ CopyArrayEls(ArrayType *array,
Datum
array_out(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
Oid element_type = AARR_ELEMTYPE(v);
int typlen;
bool typbyval;
@@ -1534,7 +1534,7 @@ ReadArrayBinary(StringInfo buf,
Datum
array_send(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
Oid element_type = AARR_ELEMTYPE(v);
int typlen;
bool typbyval;
@@ -1638,7 +1638,7 @@ array_send(PG_FUNCTION_ARGS)
Datum
array_ndims(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
/* Sanity check: does it look like an array at all? */
if (AARR_NDIM(v) <= 0 || AARR_NDIM(v) > MAXDIM)
@@ -1654,7 +1654,7 @@ array_ndims(PG_FUNCTION_ARGS)
Datum
array_dims(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
char *p;
int i;
int *dimv,
@@ -1692,7 +1692,7 @@ array_dims(PG_FUNCTION_ARGS)
Datum
array_lower(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
int reqdim = PG_GETARG_INT32(1);
int *lb;
int result;
@@ -1719,7 +1719,7 @@ array_lower(PG_FUNCTION_ARGS)
Datum
array_upper(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
int reqdim = PG_GETARG_INT32(1);
int *dimv,
*lb;
@@ -1749,7 +1749,7 @@ array_upper(PG_FUNCTION_ARGS)
Datum
array_length(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
int reqdim = PG_GETARG_INT32(1);
int *dimv;
int result;
@@ -1776,7 +1776,7 @@ array_length(PG_FUNCTION_ARGS)
Datum
array_cardinality(PG_FUNCTION_ARGS)
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
PG_RETURN_INT32(ArrayGetNItems(AARR_NDIM(v), AARR_DIMS(v)));
}
@@ -3147,7 +3147,7 @@ array_map(FunctionCallInfo fcinfo, Oid retType, ArrayMapState *amstate)
elog(ERROR, "invalid nargs: %d", fcinfo->nargs);
if (PG_ARGISNULL(0))
elog(ERROR, "null input array");
- v = PG_GETARG_ANY_ARRAY(0);
+ v = PG_GETARG_ANY_ARRAY_P(0);
inpType = AARR_ELEMTYPE(v);
ndim = AARR_NDIM(v);
@@ -3589,8 +3589,8 @@ array_contains_nulls(ArrayType *array)
Datum
array_eq(PG_FUNCTION_ARGS)
{
- AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0);
- AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1);
+ AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
+ AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION();
int ndims1 = AARR_NDIM(array1);
int ndims2 = AARR_NDIM(array2);
@@ -3760,8 +3760,8 @@ btarraycmp(PG_FUNCTION_ARGS)
static int
array_cmp(FunctionCallInfo fcinfo)
{
- AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0);
- AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1);
+ AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
+ AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION();
int ndims1 = AARR_NDIM(array1);
int ndims2 = AARR_NDIM(array2);
@@ -3931,7 +3931,7 @@ array_cmp(FunctionCallInfo fcinfo)
Datum
hash_array(PG_FUNCTION_ARGS)
{
- AnyArrayType *array = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *array = PG_GETARG_ANY_ARRAY_P(0);
int ndims = AARR_NDIM(array);
int *dims = AARR_DIMS(array);
Oid element_type = AARR_ELEMTYPE(array);
@@ -4028,7 +4028,7 @@ hash_array(PG_FUNCTION_ARGS)
Datum
hash_array_extended(PG_FUNCTION_ARGS)
{
- AnyArrayType *array = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *array = PG_GETARG_ANY_ARRAY_P(0);
uint64 seed = PG_GETARG_INT64(1);
int ndims = AARR_NDIM(array);
int *dims = AARR_DIMS(array);
@@ -4260,8 +4260,8 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation,
Datum
arrayoverlap(PG_FUNCTION_ARGS)
{
- AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0);
- AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1);
+ AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
+ AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION();
bool result;
@@ -4278,8 +4278,8 @@ arrayoverlap(PG_FUNCTION_ARGS)
Datum
arraycontains(PG_FUNCTION_ARGS)
{
- AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0);
- AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1);
+ AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
+ AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION();
bool result;
@@ -4296,8 +4296,8 @@ arraycontains(PG_FUNCTION_ARGS)
Datum
arraycontained(PG_FUNCTION_ARGS)
{
- AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0);
- AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1);
+ AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
+ AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION();
bool result;
@@ -5634,7 +5634,7 @@ generate_subscripts(PG_FUNCTION_ARGS)
/* stuff done only on the first call of the function */
if (SRF_IS_FIRSTCALL())
{
- AnyArrayType *v = PG_GETARG_ANY_ARRAY(0);
+ AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
int reqdim = PG_GETARG_INT32(1);
int *lb,
*dimv;
@@ -5996,7 +5996,7 @@ array_unnest(PG_FUNCTION_ARGS)
* and not before. (If no detoast happens, we assume the originally
* passed array will stick around till then.)
*/
- arr = PG_GETARG_ANY_ARRAY(0);
+ arr = PG_GETARG_ANY_ARRAY_P(0);
/* allocate memory for user context */
fctx = (array_unnest_fctx *) palloc(sizeof(array_unnest_fctx));