diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/tsearch/to_tsany.c | 6 | ||||
-rw-r--r-- | src/backend/tsearch/wparser.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/array_expanded.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 46 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonb.c | 8 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonb_gin.c | 12 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonb_op.c | 48 | ||||
-rw-r--r-- | src/backend/utils/adt/jsonfuncs.c | 94 | ||||
-rw-r--r-- | src/backend/utils/adt/rangetypes.c | 134 | ||||
-rw-r--r-- | src/backend/utils/adt/rangetypes_gist.c | 96 | ||||
-rw-r--r-- | src/backend/utils/adt/rangetypes_selfuncs.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/rangetypes_spgist.c | 54 | ||||
-rw-r--r-- | src/backend/utils/adt/rangetypes_typanalyze.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/tsgistidx.c | 4 | ||||
-rw-r--r-- | src/include/utils/array.h | 4 | ||||
-rw-r--r-- | src/include/utils/jsonb.h | 8 | ||||
-rw-r--r-- | src/include/utils/rangetypes.h | 12 |
17 files changed, 270 insertions, 270 deletions
diff --git a/src/backend/tsearch/to_tsany.c b/src/backend/tsearch/to_tsany.c index 35d9ab276cf..cf55e3910d0 100644 --- a/src/backend/tsearch/to_tsany.c +++ b/src/backend/tsearch/to_tsany.c @@ -271,7 +271,7 @@ Datum jsonb_to_tsvector_byid(PG_FUNCTION_ARGS) { Oid cfgId = PG_GETARG_OID(0); - Jsonb *jb = PG_GETARG_JSONB(1); + Jsonb *jb = PG_GETARG_JSONB_P(1); TSVector result; TSVectorBuildState state; ParsedText prs; @@ -293,13 +293,13 @@ jsonb_to_tsvector_byid(PG_FUNCTION_ARGS) Datum jsonb_to_tsvector(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); Oid cfgId; cfgId = getTSCurrentConfig(true); PG_RETURN_DATUM(DirectFunctionCall2(jsonb_to_tsvector_byid, ObjectIdGetDatum(cfgId), - JsonbGetDatum(jb))); + JsonbPGetDatum(jb))); } Datum diff --git a/src/backend/tsearch/wparser.c b/src/backend/tsearch/wparser.c index c9ce80a91af..523c3edd7d1 100644 --- a/src/backend/tsearch/wparser.c +++ b/src/backend/tsearch/wparser.c @@ -383,7 +383,7 @@ Datum ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS) { Oid tsconfig = PG_GETARG_OID(0); - Jsonb *jb = PG_GETARG_JSONB(1); + Jsonb *jb = PG_GETARG_JSONB_P(1); TSQuery query = PG_GETARG_TSQUERY(2); text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL; Jsonb *out; @@ -424,7 +424,7 @@ ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS) pfree(prs.stopsel); } - PG_RETURN_JSONB(out); + PG_RETURN_JSONB_P(out); } Datum diff --git a/src/backend/utils/adt/array_expanded.c b/src/backend/utils/adt/array_expanded.c index f256c7f13db..31583f9033f 100644 --- a/src/backend/utils/adt/array_expanded.c +++ b/src/backend/utils/adt/array_expanded.c @@ -394,11 +394,11 @@ DatumGetExpandedArrayX(Datum d, ArrayMetaState *metacache) } /* - * DatumGetAnyArray: return either an expanded array or a detoasted varlena + * DatumGetAnyArrayP: return either an expanded array or a detoasted varlena * array. The result must not be modified in-place. */ AnyArrayType * -DatumGetAnyArray(Datum d) +DatumGetAnyArrayP(Datum d) { ExpandedArrayHeader *eah; 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)); diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index 1eb7f3d6f9d..95db8955389 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -130,7 +130,7 @@ jsonb_recv(PG_FUNCTION_ARGS) Datum jsonb_out(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); char *out; out = JsonbToCString(NULL, &jb->root, VARSIZE(jb)); @@ -146,7 +146,7 @@ jsonb_out(PG_FUNCTION_ARGS) Datum jsonb_send(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); StringInfoData buf; StringInfo jtext = makeStringInfo(); int version = 1; @@ -171,7 +171,7 @@ jsonb_send(PG_FUNCTION_ARGS) Datum jsonb_typeof(PG_FUNCTION_ARGS) { - Jsonb *in = PG_GETARG_JSONB(0); + Jsonb *in = PG_GETARG_JSONB_P(0); JsonbIterator *it; JsonbValue v; char *result; @@ -878,7 +878,7 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result, break; case JSONBTYPE_JSONB: { - Jsonb *jsonb = DatumGetJsonb(val); + Jsonb *jsonb = DatumGetJsonbP(val); JsonbIterator *it; it = JsonbIteratorInit(&jsonb->root); diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c index 8e8e8fd850a..4e1ba10e9c1 100644 --- a/src/backend/utils/adt/jsonb_gin.c +++ b/src/backend/utils/adt/jsonb_gin.c @@ -66,7 +66,7 @@ gin_compare_jsonb(PG_FUNCTION_ARGS) Datum gin_extract_jsonb(PG_FUNCTION_ARGS) { - Jsonb *jb = (Jsonb *) PG_GETARG_JSONB(0); + Jsonb *jb = (Jsonb *) PG_GETARG_JSONB_P(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); int total = 2 * JB_ROOT_COUNT(jb); JsonbIterator *it; @@ -196,7 +196,7 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS) bool *check = (bool *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); - /* Jsonb *query = PG_GETARG_JSONB(2); */ + /* Jsonb *query = PG_GETARG_JSONB_P(2); */ int32 nkeys = PG_GETARG_INT32(3); /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ @@ -268,7 +268,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS) GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); - /* Jsonb *query = PG_GETARG_JSONB(2); */ + /* Jsonb *query = PG_GETARG_JSONB_P(2); */ int32 nkeys = PG_GETARG_INT32(3); /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ @@ -329,7 +329,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS) Datum gin_extract_jsonb_path(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); int total = 2 * JB_ROOT_COUNT(jb); JsonbIterator *it; @@ -454,7 +454,7 @@ gin_consistent_jsonb_path(PG_FUNCTION_ARGS) bool *check = (bool *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); - /* Jsonb *query = PG_GETARG_JSONB(2); */ + /* Jsonb *query = PG_GETARG_JSONB_P(2); */ int32 nkeys = PG_GETARG_INT32(3); /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ @@ -492,7 +492,7 @@ gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS) GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); - /* Jsonb *query = PG_GETARG_JSONB(2); */ + /* Jsonb *query = PG_GETARG_JSONB_P(2); */ int32 nkeys = PG_GETARG_INT32(3); /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ diff --git a/src/backend/utils/adt/jsonb_op.c b/src/backend/utils/adt/jsonb_op.c index 52a7e19a542..d54a07d2044 100644 --- a/src/backend/utils/adt/jsonb_op.c +++ b/src/backend/utils/adt/jsonb_op.c @@ -21,7 +21,7 @@ Datum jsonb_exists(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); text *key = PG_GETARG_TEXT_PP(1); JsonbValue kval; JsonbValue *v = NULL; @@ -46,7 +46,7 @@ jsonb_exists(PG_FUNCTION_ARGS) Datum jsonb_exists_any(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1); int i; Datum *key_datums; @@ -79,7 +79,7 @@ jsonb_exists_any(PG_FUNCTION_ARGS) Datum jsonb_exists_all(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1); int i; Datum *key_datums; @@ -112,8 +112,8 @@ jsonb_exists_all(PG_FUNCTION_ARGS) Datum jsonb_contains(PG_FUNCTION_ARGS) { - Jsonb *val = PG_GETARG_JSONB(0); - Jsonb *tmpl = PG_GETARG_JSONB(1); + Jsonb *val = PG_GETARG_JSONB_P(0); + Jsonb *tmpl = PG_GETARG_JSONB_P(1); JsonbIterator *it1, *it2; @@ -131,8 +131,8 @@ Datum jsonb_contained(PG_FUNCTION_ARGS) { /* Commutator of "contains" */ - Jsonb *tmpl = PG_GETARG_JSONB(0); - Jsonb *val = PG_GETARG_JSONB(1); + Jsonb *tmpl = PG_GETARG_JSONB_P(0); + Jsonb *val = PG_GETARG_JSONB_P(1); JsonbIterator *it1, *it2; @@ -149,8 +149,8 @@ jsonb_contained(PG_FUNCTION_ARGS) Datum jsonb_ne(PG_FUNCTION_ARGS) { - Jsonb *jba = PG_GETARG_JSONB(0); - Jsonb *jbb = PG_GETARG_JSONB(1); + Jsonb *jba = PG_GETARG_JSONB_P(0); + Jsonb *jbb = PG_GETARG_JSONB_P(1); bool res; res = (compareJsonbContainers(&jba->root, &jbb->root) != 0); @@ -166,8 +166,8 @@ jsonb_ne(PG_FUNCTION_ARGS) Datum jsonb_lt(PG_FUNCTION_ARGS) { - Jsonb *jba = PG_GETARG_JSONB(0); - Jsonb *jbb = PG_GETARG_JSONB(1); + Jsonb *jba = PG_GETARG_JSONB_P(0); + Jsonb *jbb = PG_GETARG_JSONB_P(1); bool res; res = (compareJsonbContainers(&jba->root, &jbb->root) < 0); @@ -180,8 +180,8 @@ jsonb_lt(PG_FUNCTION_ARGS) Datum jsonb_gt(PG_FUNCTION_ARGS) { - Jsonb *jba = PG_GETARG_JSONB(0); - Jsonb *jbb = PG_GETARG_JSONB(1); + Jsonb *jba = PG_GETARG_JSONB_P(0); + Jsonb *jbb = PG_GETARG_JSONB_P(1); bool res; res = (compareJsonbContainers(&jba->root, &jbb->root) > 0); @@ -194,8 +194,8 @@ jsonb_gt(PG_FUNCTION_ARGS) Datum jsonb_le(PG_FUNCTION_ARGS) { - Jsonb *jba = PG_GETARG_JSONB(0); - Jsonb *jbb = PG_GETARG_JSONB(1); + Jsonb *jba = PG_GETARG_JSONB_P(0); + Jsonb *jbb = PG_GETARG_JSONB_P(1); bool res; res = (compareJsonbContainers(&jba->root, &jbb->root) <= 0); @@ -208,8 +208,8 @@ jsonb_le(PG_FUNCTION_ARGS) Datum jsonb_ge(PG_FUNCTION_ARGS) { - Jsonb *jba = PG_GETARG_JSONB(0); - Jsonb *jbb = PG_GETARG_JSONB(1); + Jsonb *jba = PG_GETARG_JSONB_P(0); + Jsonb *jbb = PG_GETARG_JSONB_P(1); bool res; res = (compareJsonbContainers(&jba->root, &jbb->root) >= 0); @@ -222,8 +222,8 @@ jsonb_ge(PG_FUNCTION_ARGS) Datum jsonb_eq(PG_FUNCTION_ARGS) { - Jsonb *jba = PG_GETARG_JSONB(0); - Jsonb *jbb = PG_GETARG_JSONB(1); + Jsonb *jba = PG_GETARG_JSONB_P(0); + Jsonb *jbb = PG_GETARG_JSONB_P(1); bool res; res = (compareJsonbContainers(&jba->root, &jbb->root) == 0); @@ -236,8 +236,8 @@ jsonb_eq(PG_FUNCTION_ARGS) Datum jsonb_cmp(PG_FUNCTION_ARGS) { - Jsonb *jba = PG_GETARG_JSONB(0); - Jsonb *jbb = PG_GETARG_JSONB(1); + Jsonb *jba = PG_GETARG_JSONB_P(0); + Jsonb *jbb = PG_GETARG_JSONB_P(1); int res; res = compareJsonbContainers(&jba->root, &jbb->root); @@ -253,7 +253,7 @@ jsonb_cmp(PG_FUNCTION_ARGS) Datum jsonb_hash(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); JsonbIterator *it; JsonbValue v; JsonbIteratorToken r; @@ -295,7 +295,7 @@ jsonb_hash(PG_FUNCTION_ARGS) Datum jsonb_hash_extended(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); uint64 seed = PG_GETARG_INT64(1); JsonbIterator *it; JsonbValue v; @@ -311,7 +311,7 @@ jsonb_hash_extended(PG_FUNCTION_ARGS) { switch (r) { - /* Rotation is left to JsonbHashScalarValueExtended() */ + /* Rotation is left to JsonbHashScalarValueExtended() */ case WJB_BEGIN_ARRAY: hash ^= ((uint64) JB_FARRAY) << 32 | JB_FARRAY; break; diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 68feeb2c5b5..d36fd9e9290 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -499,7 +499,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS) if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); bool skipNested = false; JsonbIterator *it; JsonbValue v; @@ -703,7 +703,7 @@ json_object_field(PG_FUNCTION_ARGS) Datum jsonb_object_field(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); text *key = PG_GETARG_TEXT_PP(1); JsonbValue *v; @@ -715,7 +715,7 @@ jsonb_object_field(PG_FUNCTION_ARGS) VARSIZE_ANY_EXHDR(key)); if (v != NULL) - PG_RETURN_JSONB(JsonbValueToJsonb(v)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(v)); PG_RETURN_NULL(); } @@ -739,7 +739,7 @@ json_object_field_text(PG_FUNCTION_ARGS) Datum jsonb_object_field_text(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); text *key = PG_GETARG_TEXT_PP(1); JsonbValue *v; @@ -805,7 +805,7 @@ json_array_element(PG_FUNCTION_ARGS) Datum jsonb_array_element(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); int element = PG_GETARG_INT32(1); JsonbValue *v; @@ -825,7 +825,7 @@ jsonb_array_element(PG_FUNCTION_ARGS) v = getIthJsonbValueFromContainer(&jb->root, element); if (v != NULL) - PG_RETURN_JSONB(JsonbValueToJsonb(v)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(v)); PG_RETURN_NULL(); } @@ -848,7 +848,7 @@ json_array_element_text(PG_FUNCTION_ARGS) Datum jsonb_array_element_text(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); int element = PG_GETARG_INT32(1); JsonbValue *v; @@ -1375,7 +1375,7 @@ jsonb_extract_path_text(PG_FUNCTION_ARGS) static Datum get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); ArrayType *path = PG_GETARG_ARRAYTYPE_P(1); Jsonb *res; Datum *pathtext; @@ -1435,7 +1435,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text) else { /* not text mode - just hand back the jsonb */ - PG_RETURN_JSONB(jb); + PG_RETURN_JSONB_P(jb); } } @@ -1533,7 +1533,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text) else { /* not text mode - just hand back the jsonb */ - PG_RETURN_JSONB(res); + PG_RETURN_JSONB_P(res); } } @@ -1571,7 +1571,7 @@ json_array_length(PG_FUNCTION_ARGS) Datum jsonb_array_length(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); if (JB_ROOT_IS_SCALAR(jb)) ereport(ERROR, @@ -1661,7 +1661,7 @@ jsonb_each_text(PG_FUNCTION_ARGS) static Datum each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); ReturnSetInfo *rsi; Tuplestorestate *tuple_store; TupleDesc tupdesc; @@ -1976,7 +1976,7 @@ static Datum elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); ReturnSetInfo *rsi; Tuplestorestate *tuple_store; TupleDesc tupdesc; @@ -2799,7 +2799,7 @@ populate_scalar(ScalarIOData *io, Oid typid, int32 typmod, JsValue *jsv) { Jsonb *jsonb = JsonbValueToJsonb(jbv); /* directly use jsonb */ - return JsonbGetDatum(jsonb); + return JsonbPGetDatum(jsonb); } /* convert jsonb to string for typio call */ else if (typid == JSONOID && jbv->type != jbvBinary) @@ -3235,7 +3235,7 @@ populate_record_worker(FunctionCallInfo fcinfo, const char *funcname, } else { - Jsonb *jb = PG_GETARG_JSONB(json_arg_num); + Jsonb *jb = PG_GETARG_JSONB_P(json_arg_num); jsv.val.jsonb = &jbv; @@ -3552,7 +3552,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname, } else { - Jsonb *jb = PG_GETARG_JSONB(json_arg_num); + Jsonb *jb = PG_GETARG_JSONB_P(json_arg_num); JsonbIterator *it; JsonbValue v; bool skipNested = false; @@ -3904,7 +3904,7 @@ json_strip_nulls(PG_FUNCTION_ARGS) Datum jsonb_strip_nulls(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); JsonbIterator *it; JsonbParseState *parseState = NULL; JsonbValue *res = NULL; @@ -4013,7 +4013,7 @@ addJsonbToParseState(JsonbParseState **jbps, Jsonb *jb) Datum jsonb_pretty(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); StringInfo str = makeStringInfo(); JsonbToCStringIndent(str, &jb->root, VARSIZE(jb)); @@ -4029,8 +4029,8 @@ jsonb_pretty(PG_FUNCTION_ARGS) Datum jsonb_concat(PG_FUNCTION_ARGS) { - Jsonb *jb1 = PG_GETARG_JSONB(0); - Jsonb *jb2 = PG_GETARG_JSONB(1); + Jsonb *jb1 = PG_GETARG_JSONB_P(0); + Jsonb *jb2 = PG_GETARG_JSONB_P(1); JsonbParseState *state = NULL; JsonbValue *res; JsonbIterator *it1, @@ -4045,9 +4045,9 @@ jsonb_concat(PG_FUNCTION_ARGS) if (JB_ROOT_IS_OBJECT(jb1) == JB_ROOT_IS_OBJECT(jb2)) { if (JB_ROOT_COUNT(jb1) == 0 && !JB_ROOT_IS_SCALAR(jb2)) - PG_RETURN_JSONB(jb2); + PG_RETURN_JSONB_P(jb2); else if (JB_ROOT_COUNT(jb2) == 0 && !JB_ROOT_IS_SCALAR(jb1)) - PG_RETURN_JSONB(jb1); + PG_RETURN_JSONB_P(jb1); } it1 = JsonbIteratorInit(&jb1->root); @@ -4057,7 +4057,7 @@ jsonb_concat(PG_FUNCTION_ARGS) Assert(res != NULL); - PG_RETURN_JSONB(JsonbValueToJsonb(res)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(res)); } @@ -4070,7 +4070,7 @@ jsonb_concat(PG_FUNCTION_ARGS) Datum jsonb_delete(PG_FUNCTION_ARGS) { - Jsonb *in = PG_GETARG_JSONB(0); + Jsonb *in = PG_GETARG_JSONB_P(0); text *key = PG_GETARG_TEXT_PP(1); char *keyptr = VARDATA_ANY(key); int keylen = VARSIZE_ANY_EXHDR(key); @@ -4087,7 +4087,7 @@ jsonb_delete(PG_FUNCTION_ARGS) errmsg("cannot delete from scalar"))); if (JB_ROOT_COUNT(in) == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); it = JsonbIteratorInit(&in->root); @@ -4111,7 +4111,7 @@ jsonb_delete(PG_FUNCTION_ARGS) Assert(res != NULL); - PG_RETURN_JSONB(JsonbValueToJsonb(res)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(res)); } /* @@ -4123,7 +4123,7 @@ jsonb_delete(PG_FUNCTION_ARGS) Datum jsonb_delete_array(PG_FUNCTION_ARGS) { - Jsonb *in = PG_GETARG_JSONB(0); + Jsonb *in = PG_GETARG_JSONB_P(0); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1); Datum *keys_elems; bool *keys_nulls; @@ -4146,13 +4146,13 @@ jsonb_delete_array(PG_FUNCTION_ARGS) errmsg("cannot delete from scalar"))); if (JB_ROOT_COUNT(in) == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); deconstruct_array(keys, TEXTOID, -1, false, 'i', &keys_elems, &keys_nulls, &keys_len); if (keys_len == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); it = JsonbIteratorInit(&in->root); @@ -4197,7 +4197,7 @@ jsonb_delete_array(PG_FUNCTION_ARGS) Assert(res != NULL); - PG_RETURN_JSONB(JsonbValueToJsonb(res)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(res)); } /* @@ -4210,7 +4210,7 @@ jsonb_delete_array(PG_FUNCTION_ARGS) Datum jsonb_delete_idx(PG_FUNCTION_ARGS) { - Jsonb *in = PG_GETARG_JSONB(0); + Jsonb *in = PG_GETARG_JSONB_P(0); int idx = PG_GETARG_INT32(1); JsonbParseState *state = NULL; JsonbIterator *it; @@ -4231,7 +4231,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS) errmsg("cannot delete from object using integer index"))); if (JB_ROOT_COUNT(in) == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); it = JsonbIteratorInit(&in->root); @@ -4248,7 +4248,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS) } if (idx >= n) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); pushJsonbValue(&state, r, NULL); @@ -4265,7 +4265,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS) Assert(res != NULL); - PG_RETURN_JSONB(JsonbValueToJsonb(res)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(res)); } /* @@ -4275,9 +4275,9 @@ jsonb_delete_idx(PG_FUNCTION_ARGS) Datum jsonb_set(PG_FUNCTION_ARGS) { - Jsonb *in = PG_GETARG_JSONB(0); + Jsonb *in = PG_GETARG_JSONB_P(0); ArrayType *path = PG_GETARG_ARRAYTYPE_P(1); - Jsonb *newval = PG_GETARG_JSONB(2); + Jsonb *newval = PG_GETARG_JSONB_P(2); bool create = PG_GETARG_BOOL(3); JsonbValue *res = NULL; Datum *path_elems; @@ -4297,13 +4297,13 @@ jsonb_set(PG_FUNCTION_ARGS) errmsg("cannot set path in scalar"))); if (JB_ROOT_COUNT(in) == 0 && !create) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); deconstruct_array(path, TEXTOID, -1, false, 'i', &path_elems, &path_nulls, &path_len); if (path_len == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); it = JsonbIteratorInit(&in->root); @@ -4312,7 +4312,7 @@ jsonb_set(PG_FUNCTION_ARGS) Assert(res != NULL); - PG_RETURN_JSONB(JsonbValueToJsonb(res)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(res)); } @@ -4322,7 +4322,7 @@ jsonb_set(PG_FUNCTION_ARGS) Datum jsonb_delete_path(PG_FUNCTION_ARGS) { - Jsonb *in = PG_GETARG_JSONB(0); + Jsonb *in = PG_GETARG_JSONB_P(0); ArrayType *path = PG_GETARG_ARRAYTYPE_P(1); JsonbValue *res = NULL; Datum *path_elems; @@ -4342,13 +4342,13 @@ jsonb_delete_path(PG_FUNCTION_ARGS) errmsg("cannot delete path in scalar"))); if (JB_ROOT_COUNT(in) == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); deconstruct_array(path, TEXTOID, -1, false, 'i', &path_elems, &path_nulls, &path_len); if (path_len == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); it = JsonbIteratorInit(&in->root); @@ -4357,7 +4357,7 @@ jsonb_delete_path(PG_FUNCTION_ARGS) Assert(res != NULL); - PG_RETURN_JSONB(JsonbValueToJsonb(res)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(res)); } /* @@ -4367,9 +4367,9 @@ jsonb_delete_path(PG_FUNCTION_ARGS) Datum jsonb_insert(PG_FUNCTION_ARGS) { - Jsonb *in = PG_GETARG_JSONB(0); + Jsonb *in = PG_GETARG_JSONB_P(0); ArrayType *path = PG_GETARG_ARRAYTYPE_P(1); - Jsonb *newval = PG_GETARG_JSONB(2); + Jsonb *newval = PG_GETARG_JSONB_P(2); bool after = PG_GETARG_BOOL(3); JsonbValue *res = NULL; Datum *path_elems; @@ -4392,7 +4392,7 @@ jsonb_insert(PG_FUNCTION_ARGS) &path_elems, &path_nulls, &path_len); if (path_len == 0) - PG_RETURN_JSONB(in); + PG_RETURN_JSONB_P(in); it = JsonbIteratorInit(&in->root); @@ -4401,7 +4401,7 @@ jsonb_insert(PG_FUNCTION_ARGS) Assert(res != NULL); - PG_RETURN_JSONB(JsonbValueToJsonb(res)); + PG_RETURN_JSONB_P(JsonbValueToJsonb(res)); } /* diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c index dae505159ee..d0aa33c010b 100644 --- a/src/backend/utils/adt/rangetypes.c +++ b/src/backend/utils/adt/rangetypes.c @@ -115,13 +115,13 @@ range_in(PG_FUNCTION_ARGS) /* serialize and canonicalize */ range = make_range(cache->typcache, &lower, &upper, flags & RANGE_EMPTY); - PG_RETURN_RANGE(range); + PG_RETURN_RANGE_P(range); } Datum range_out(PG_FUNCTION_ARGS) { - RangeType *range = PG_GETARG_RANGE(0); + RangeType *range = PG_GETARG_RANGE_P(0); char *output_str; RangeIOData *cache; char flags; @@ -238,13 +238,13 @@ range_recv(PG_FUNCTION_ARGS) /* serialize and canonicalize */ range = make_range(cache->typcache, &lower, &upper, flags & RANGE_EMPTY); - PG_RETURN_RANGE(range); + PG_RETURN_RANGE_P(range); } Datum range_send(PG_FUNCTION_ARGS) { - RangeType *range = PG_GETARG_RANGE(0); + RangeType *range = PG_GETARG_RANGE_P(0); StringInfo buf = makeStringInfo(); RangeIOData *cache; char flags; @@ -381,7 +381,7 @@ range_constructor2(PG_FUNCTION_ARGS) range = make_range(typcache, &lower, &upper, false); - PG_RETURN_RANGE(range); + PG_RETURN_RANGE_P(range); } /* Construct general range value from three arguments */ @@ -418,7 +418,7 @@ range_constructor3(PG_FUNCTION_ARGS) range = make_range(typcache, &lower, &upper, false); - PG_RETURN_RANGE(range); + PG_RETURN_RANGE_P(range); } @@ -428,7 +428,7 @@ range_constructor3(PG_FUNCTION_ARGS) Datum range_lower(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); + RangeType *r1 = PG_GETARG_RANGE_P(0); TypeCacheEntry *typcache; RangeBound lower; RangeBound upper; @@ -449,7 +449,7 @@ range_lower(PG_FUNCTION_ARGS) Datum range_upper(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); + RangeType *r1 = PG_GETARG_RANGE_P(0); TypeCacheEntry *typcache; RangeBound lower; RangeBound upper; @@ -473,7 +473,7 @@ range_upper(PG_FUNCTION_ARGS) Datum range_empty(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); + RangeType *r1 = PG_GETARG_RANGE_P(0); char flags = range_get_flags(r1); PG_RETURN_BOOL(flags & RANGE_EMPTY); @@ -483,7 +483,7 @@ range_empty(PG_FUNCTION_ARGS) Datum range_lower_inc(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); + RangeType *r1 = PG_GETARG_RANGE_P(0); char flags = range_get_flags(r1); PG_RETURN_BOOL(flags & RANGE_LB_INC); @@ -493,7 +493,7 @@ range_lower_inc(PG_FUNCTION_ARGS) Datum range_upper_inc(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); + RangeType *r1 = PG_GETARG_RANGE_P(0); char flags = range_get_flags(r1); PG_RETURN_BOOL(flags & RANGE_UB_INC); @@ -503,7 +503,7 @@ range_upper_inc(PG_FUNCTION_ARGS) Datum range_lower_inf(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); + RangeType *r1 = PG_GETARG_RANGE_P(0); char flags = range_get_flags(r1); PG_RETURN_BOOL(flags & RANGE_LB_INF); @@ -513,7 +513,7 @@ range_lower_inf(PG_FUNCTION_ARGS) Datum range_upper_inf(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); + RangeType *r1 = PG_GETARG_RANGE_P(0); char flags = range_get_flags(r1); PG_RETURN_BOOL(flags & RANGE_UB_INF); @@ -526,7 +526,7 @@ range_upper_inf(PG_FUNCTION_ARGS) Datum range_contains_elem(PG_FUNCTION_ARGS) { - RangeType *r = PG_GETARG_RANGE(0); + RangeType *r = PG_GETARG_RANGE_P(0); Datum val = PG_GETARG_DATUM(1); TypeCacheEntry *typcache; @@ -540,7 +540,7 @@ Datum elem_contained_by_range(PG_FUNCTION_ARGS) { Datum val = PG_GETARG_DATUM(0); - RangeType *r = PG_GETARG_RANGE(1); + RangeType *r = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r)); @@ -587,8 +587,8 @@ range_eq_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_eq(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -607,8 +607,8 @@ range_ne_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_ne(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -620,8 +620,8 @@ range_ne(PG_FUNCTION_ARGS) Datum range_contains(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -633,8 +633,8 @@ range_contains(PG_FUNCTION_ARGS) Datum range_contained_by(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -671,8 +671,8 @@ range_before_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_before(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -709,8 +709,8 @@ range_after_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_after(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -810,8 +810,8 @@ range_adjacent_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_adjacent(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -856,8 +856,8 @@ range_overlaps_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_overlaps(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -897,8 +897,8 @@ range_overleft_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_overleft(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -938,8 +938,8 @@ range_overright_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2) Datum range_overright(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); @@ -954,8 +954,8 @@ range_overright(PG_FUNCTION_ARGS) Datum range_minus(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; RangeBound lower1, lower2; @@ -979,7 +979,7 @@ range_minus(PG_FUNCTION_ARGS) /* if either is empty, r1 is the correct answer */ if (empty1 || empty2) - PG_RETURN_RANGE(r1); + PG_RETURN_RANGE_P(r1); cmp_l1l2 = range_cmp_bounds(typcache, &lower1, &lower2); cmp_l1u2 = range_cmp_bounds(typcache, &lower1, &upper2); @@ -992,23 +992,23 @@ range_minus(PG_FUNCTION_ARGS) errmsg("result of range difference would not be contiguous"))); if (cmp_l1u2 > 0 || cmp_u1l2 < 0) - PG_RETURN_RANGE(r1); + PG_RETURN_RANGE_P(r1); if (cmp_l1l2 >= 0 && cmp_u1u2 <= 0) - PG_RETURN_RANGE(make_empty_range(typcache)); + PG_RETURN_RANGE_P(make_empty_range(typcache)); if (cmp_l1l2 <= 0 && cmp_u1l2 >= 0 && cmp_u1u2 <= 0) { lower2.inclusive = !lower2.inclusive; lower2.lower = false; /* it will become the upper bound */ - PG_RETURN_RANGE(make_range(typcache, &lower1, &lower2, false)); + PG_RETURN_RANGE_P(make_range(typcache, &lower1, &lower2, false)); } if (cmp_l1l2 >= 0 && cmp_u1u2 >= 0 && cmp_l1u2 <= 0) { upper2.inclusive = !upper2.inclusive; upper2.lower = true; /* it will become the lower bound */ - PG_RETURN_RANGE(make_range(typcache, &upper2, &upper1, false)); + PG_RETURN_RANGE_P(make_range(typcache, &upper2, &upper1, false)); } elog(ERROR, "unexpected case in range_minus"); @@ -1068,13 +1068,13 @@ range_union_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2, Datum range_union(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); - PG_RETURN_RANGE(range_union_internal(typcache, r1, r2, true)); + PG_RETURN_RANGE_P(range_union_internal(typcache, r1, r2, true)); } /* @@ -1084,21 +1084,21 @@ range_union(PG_FUNCTION_ARGS) Datum range_merge(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; typcache = range_get_typcache(fcinfo, RangeTypeGetOid(r1)); - PG_RETURN_RANGE(range_union_internal(typcache, r1, r2, false)); + PG_RETURN_RANGE_P(range_union_internal(typcache, r1, r2, false)); } /* set intersection */ Datum range_intersect(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; RangeBound lower1, lower2; @@ -1119,7 +1119,7 @@ range_intersect(PG_FUNCTION_ARGS) range_deserialize(typcache, r2, &lower2, &upper2, &empty2); if (empty1 || empty2 || !DatumGetBool(range_overlaps(fcinfo))) - PG_RETURN_RANGE(make_empty_range(typcache)); + PG_RETURN_RANGE_P(make_empty_range(typcache)); if (range_cmp_bounds(typcache, &lower1, &lower2) >= 0) result_lower = &lower1; @@ -1131,7 +1131,7 @@ range_intersect(PG_FUNCTION_ARGS) else result_upper = &upper2; - PG_RETURN_RANGE(make_range(typcache, result_lower, result_upper, false)); + PG_RETURN_RANGE_P(make_range(typcache, result_lower, result_upper, false)); } /* Btree support */ @@ -1140,8 +1140,8 @@ range_intersect(PG_FUNCTION_ARGS) Datum range_cmp(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); TypeCacheEntry *typcache; RangeBound lower1, lower2; @@ -1221,7 +1221,7 @@ range_gt(PG_FUNCTION_ARGS) Datum hash_range(PG_FUNCTION_ARGS) { - RangeType *r = PG_GETARG_RANGE(0); + RangeType *r = PG_GETARG_RANGE_P(0); uint32 result; TypeCacheEntry *typcache; TypeCacheEntry *scache; @@ -1287,7 +1287,7 @@ hash_range(PG_FUNCTION_ARGS) Datum hash_range_extended(PG_FUNCTION_ARGS) { - RangeType *r = PG_GETARG_RANGE(0); + RangeType *r = PG_GETARG_RANGE_P(0); Datum seed = PG_GETARG_DATUM(1); uint64 result; TypeCacheEntry *typcache; @@ -1355,7 +1355,7 @@ hash_range_extended(PG_FUNCTION_ARGS) Datum int4range_canonical(PG_FUNCTION_ARGS) { - RangeType *r = PG_GETARG_RANGE(0); + RangeType *r = PG_GETARG_RANGE_P(0); TypeCacheEntry *typcache; RangeBound lower; RangeBound upper; @@ -1366,7 +1366,7 @@ int4range_canonical(PG_FUNCTION_ARGS) range_deserialize(typcache, r, &lower, &upper, &empty); if (empty) - PG_RETURN_RANGE(r); + PG_RETURN_RANGE_P(r); if (!lower.infinite && !lower.inclusive) { @@ -1380,13 +1380,13 @@ int4range_canonical(PG_FUNCTION_ARGS) upper.inclusive = false; } - PG_RETURN_RANGE(range_serialize(typcache, &lower, &upper, false)); + PG_RETURN_RANGE_P(range_serialize(typcache, &lower, &upper, false)); } Datum int8range_canonical(PG_FUNCTION_ARGS) { - RangeType *r = PG_GETARG_RANGE(0); + RangeType *r = PG_GETARG_RANGE_P(0); TypeCacheEntry *typcache; RangeBound lower; RangeBound upper; @@ -1397,7 +1397,7 @@ int8range_canonical(PG_FUNCTION_ARGS) range_deserialize(typcache, r, &lower, &upper, &empty); if (empty) - PG_RETURN_RANGE(r); + PG_RETURN_RANGE_P(r); if (!lower.infinite && !lower.inclusive) { @@ -1411,13 +1411,13 @@ int8range_canonical(PG_FUNCTION_ARGS) upper.inclusive = false; } - PG_RETURN_RANGE(range_serialize(typcache, &lower, &upper, false)); + PG_RETURN_RANGE_P(range_serialize(typcache, &lower, &upper, false)); } Datum daterange_canonical(PG_FUNCTION_ARGS) { - RangeType *r = PG_GETARG_RANGE(0); + RangeType *r = PG_GETARG_RANGE_P(0); TypeCacheEntry *typcache; RangeBound lower; RangeBound upper; @@ -1428,7 +1428,7 @@ daterange_canonical(PG_FUNCTION_ARGS) range_deserialize(typcache, r, &lower, &upper, &empty); if (empty) - PG_RETURN_RANGE(r); + PG_RETURN_RANGE_P(r); if (!lower.infinite && !lower.inclusive) { @@ -1442,7 +1442,7 @@ daterange_canonical(PG_FUNCTION_ARGS) upper.inclusive = false; } - PG_RETURN_RANGE(range_serialize(typcache, &lower, &upper, false)); + PG_RETURN_RANGE_P(range_serialize(typcache, &lower, &upper, false)); } /* @@ -1799,8 +1799,8 @@ make_range(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, /* no need to call canonical on empty ranges ... */ if (OidIsValid(typcache->rng_canonical_finfo.fn_oid) && !RangeIsEmpty(range)) - range = DatumGetRangeType(FunctionCall1(&typcache->rng_canonical_finfo, - RangeTypeGetDatum(range))); + range = DatumGetRangeTypeP(FunctionCall1(&typcache->rng_canonical_finfo, + RangeTypePGetDatum(range))); return range; } diff --git a/src/backend/utils/adt/rangetypes_gist.c b/src/backend/utils/adt/rangetypes_gist.c index a1f4f4d3722..cb2d5a3b73a 100644 --- a/src/backend/utils/adt/rangetypes_gist.c +++ b/src/backend/utils/adt/rangetypes_gist.c @@ -177,7 +177,7 @@ range_gist_consistent(PG_FUNCTION_ARGS) /* Oid subtype = PG_GETARG_OID(3); */ bool *recheck = (bool *) PG_GETARG_POINTER(4); - RangeType *key = DatumGetRangeType(entry->key); + RangeType *key = DatumGetRangeTypeP(entry->key); TypeCacheEntry *typcache; /* All operators served by this function are exact */ @@ -203,17 +203,17 @@ range_gist_union(PG_FUNCTION_ARGS) TypeCacheEntry *typcache; int i; - result_range = DatumGetRangeType(ent[0].key); + result_range = DatumGetRangeTypeP(ent[0].key); typcache = range_get_typcache(fcinfo, RangeTypeGetOid(result_range)); for (i = 1; i < entryvec->n; i++) { result_range = range_super_union(typcache, result_range, - DatumGetRangeType(ent[i].key)); + DatumGetRangeTypeP(ent[i].key)); } - PG_RETURN_RANGE(result_range); + PG_RETURN_RANGE_P(result_range); } /* compress, decompress, fetch are no-ops */ @@ -257,8 +257,8 @@ range_gist_penalty(PG_FUNCTION_ARGS) GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1); float *penalty = (float *) PG_GETARG_POINTER(2); - RangeType *orig = DatumGetRangeType(origentry->key); - RangeType *new = DatumGetRangeType(newentry->key); + RangeType *orig = DatumGetRangeTypeP(origentry->key); + RangeType *new = DatumGetRangeTypeP(newentry->key); TypeCacheEntry *typcache; bool has_subtype_diff; RangeBound orig_lower, @@ -526,7 +526,7 @@ range_gist_picksplit(PG_FUNCTION_ARGS) int total_count; /* use first item to look up range type's info */ - pred_left = DatumGetRangeType(entryvec->vector[FirstOffsetNumber].key); + pred_left = DatumGetRangeTypeP(entryvec->vector[FirstOffsetNumber].key); typcache = range_get_typcache(fcinfo, RangeTypeGetOid(pred_left)); maxoff = entryvec->n - 1; @@ -540,7 +540,7 @@ range_gist_picksplit(PG_FUNCTION_ARGS) memset(count_in_classes, 0, sizeof(count_in_classes)); for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - RangeType *range = DatumGetRangeType(entryvec->vector[i].key); + RangeType *range = DatumGetRangeTypeP(entryvec->vector[i].key); count_in_classes[get_gist_range_class(range)]++; } @@ -670,8 +670,8 @@ range_gist_picksplit(PG_FUNCTION_ARGS) Datum range_gist_same(PG_FUNCTION_ARGS) { - RangeType *r1 = PG_GETARG_RANGE(0); - RangeType *r2 = PG_GETARG_RANGE(1); + RangeType *r1 = PG_GETARG_RANGE_P(0); + RangeType *r2 = PG_GETARG_RANGE_P(1); bool *result = (bool *) PG_GETARG_POINTER(2); /* @@ -787,39 +787,39 @@ range_gist_consistent_int(TypeCacheEntry *typcache, StrategyNumber strategy, switch (strategy) { case RANGESTRAT_BEFORE: - if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeType(query))) + if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeTypeP(query))) return false; return (!range_overright_internal(typcache, key, - DatumGetRangeType(query))); + DatumGetRangeTypeP(query))); case RANGESTRAT_OVERLEFT: - if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeType(query))) + if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeTypeP(query))) return false; return (!range_after_internal(typcache, key, - DatumGetRangeType(query))); + DatumGetRangeTypeP(query))); case RANGESTRAT_OVERLAPS: return range_overlaps_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_OVERRIGHT: - if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeType(query))) + if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeTypeP(query))) return false; return (!range_before_internal(typcache, key, - DatumGetRangeType(query))); + DatumGetRangeTypeP(query))); case RANGESTRAT_AFTER: - if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeType(query))) + if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeTypeP(query))) return false; return (!range_overleft_internal(typcache, key, - DatumGetRangeType(query))); + DatumGetRangeTypeP(query))); case RANGESTRAT_ADJACENT: - if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeType(query))) + if (RangeIsEmpty(key) || RangeIsEmpty(DatumGetRangeTypeP(query))) return false; if (range_adjacent_internal(typcache, key, - DatumGetRangeType(query))) + DatumGetRangeTypeP(query))) return true; return range_overlaps_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_CONTAINS: return range_contains_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_CONTAINED_BY: /* @@ -830,7 +830,7 @@ range_gist_consistent_int(TypeCacheEntry *typcache, StrategyNumber strategy, if (RangeIsOrContainsEmpty(key)) return true; return range_overlaps_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_CONTAINS_ELEM: return range_contains_elem_internal(typcache, key, query); case RANGESTRAT_EQ: @@ -839,10 +839,10 @@ range_gist_consistent_int(TypeCacheEntry *typcache, StrategyNumber strategy, * If query is empty, descend only if the key is or contains any * empty ranges. Otherwise, descend if key contains query. */ - if (RangeIsEmpty(DatumGetRangeType(query))) + if (RangeIsEmpty(DatumGetRangeTypeP(query))) return RangeIsOrContainsEmpty(key); return range_contains_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); default: elog(ERROR, "unrecognized range strategy: %d", strategy); return false; /* keep compiler quiet */ @@ -860,32 +860,32 @@ range_gist_consistent_leaf(TypeCacheEntry *typcache, StrategyNumber strategy, { case RANGESTRAT_BEFORE: return range_before_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_OVERLEFT: return range_overleft_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_OVERLAPS: return range_overlaps_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_OVERRIGHT: return range_overright_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_AFTER: return range_after_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_ADJACENT: return range_adjacent_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_CONTAINS: return range_contains_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_CONTAINED_BY: return range_contained_by_internal(typcache, key, - DatumGetRangeType(query)); + DatumGetRangeTypeP(query)); case RANGESTRAT_CONTAINS_ELEM: return range_contains_elem_internal(typcache, key, query); case RANGESTRAT_EQ: - return range_eq_internal(typcache, key, DatumGetRangeType(query)); + return range_eq_internal(typcache, key, DatumGetRangeTypeP(query)); default: elog(ERROR, "unrecognized range strategy: %d", strategy); return false; /* keep compiler quiet */ @@ -915,7 +915,7 @@ range_gist_fallback_split(TypeCacheEntry *typcache, v->spl_nright = 0; for (i = FirstOffsetNumber; i <= maxoff; i++) { - RangeType *range = DatumGetRangeType(entryvec->vector[i].key); + RangeType *range = DatumGetRangeTypeP(entryvec->vector[i].key); if (i < split_idx) PLACE_LEFT(range, i); @@ -923,8 +923,8 @@ range_gist_fallback_split(TypeCacheEntry *typcache, PLACE_RIGHT(range, i); } - v->spl_ldatum = RangeTypeGetDatum(left_range); - v->spl_rdatum = RangeTypeGetDatum(right_range); + v->spl_ldatum = RangeTypePGetDatum(left_range); + v->spl_rdatum = RangeTypePGetDatum(right_range); } /* @@ -951,7 +951,7 @@ range_gist_class_split(TypeCacheEntry *typcache, v->spl_nright = 0; for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - RangeType *range = DatumGetRangeType(entryvec->vector[i].key); + RangeType *range = DatumGetRangeTypeP(entryvec->vector[i].key); int class; /* Get class of range */ @@ -967,8 +967,8 @@ range_gist_class_split(TypeCacheEntry *typcache, } } - v->spl_ldatum = RangeTypeGetDatum(left_range); - v->spl_rdatum = RangeTypeGetDatum(right_range); + v->spl_ldatum = RangeTypePGetDatum(left_range); + v->spl_rdatum = RangeTypePGetDatum(right_range); } /* @@ -1000,7 +1000,7 @@ range_gist_single_sorting_split(TypeCacheEntry *typcache, */ for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - RangeType *range = DatumGetRangeType(entryvec->vector[i].key); + RangeType *range = DatumGetRangeTypeP(entryvec->vector[i].key); RangeBound bound2; bool empty; @@ -1026,7 +1026,7 @@ range_gist_single_sorting_split(TypeCacheEntry *typcache, for (i = 0; i < maxoff; i++) { int idx = sortItems[i].index; - RangeType *range = DatumGetRangeType(entryvec->vector[idx].key); + RangeType *range = DatumGetRangeTypeP(entryvec->vector[idx].key); if (i < split_idx) PLACE_LEFT(range, idx); @@ -1034,8 +1034,8 @@ range_gist_single_sorting_split(TypeCacheEntry *typcache, PLACE_RIGHT(range, idx); } - v->spl_ldatum = RangeTypeGetDatum(left_range); - v->spl_rdatum = RangeTypeGetDatum(right_range); + v->spl_ldatum = RangeTypePGetDatum(left_range); + v->spl_rdatum = RangeTypePGetDatum(right_range); } /* @@ -1102,7 +1102,7 @@ range_gist_double_sorting_split(TypeCacheEntry *typcache, /* Fill arrays of bounds */ for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { - RangeType *range = DatumGetRangeType(entryvec->vector[i].key); + RangeType *range = DatumGetRangeTypeP(entryvec->vector[i].key); bool empty; range_deserialize(typcache, range, @@ -1277,7 +1277,7 @@ range_gist_double_sorting_split(TypeCacheEntry *typcache, /* * Get upper and lower bounds along selected axis. */ - range = DatumGetRangeType(entryvec->vector[i].key); + range = DatumGetRangeTypeP(entryvec->vector[i].key); range_deserialize(typcache, range, &lower, &upper, &empty); @@ -1347,7 +1347,7 @@ range_gist_double_sorting_split(TypeCacheEntry *typcache, { int idx = common_entries[i].index; - range = DatumGetRangeType(entryvec->vector[idx].key); + range = DatumGetRangeTypeP(entryvec->vector[idx].key); /* * Check if we have to place this entry in either group to achieve diff --git a/src/backend/utils/adt/rangetypes_selfuncs.c b/src/backend/utils/adt/rangetypes_selfuncs.c index ed13c27fcb8..cba8974dbe6 100644 --- a/src/backend/utils/adt/rangetypes_selfuncs.c +++ b/src/backend/utils/adt/rangetypes_selfuncs.c @@ -203,7 +203,7 @@ rangesel(PG_FUNCTION_ARGS) /* Both sides are the same range type */ typcache = range_get_typcache(fcinfo, vardata.vartype); - constrange = DatumGetRangeType(((Const *) other)->constvalue); + constrange = DatumGetRangeTypeP(((Const *) other)->constvalue); } /* @@ -406,7 +406,7 @@ calc_hist_selectivity(TypeCacheEntry *typcache, VariableStatData *vardata, hist_upper = (RangeBound *) palloc(sizeof(RangeBound) * nhist); for (i = 0; i < nhist; i++) { - range_deserialize(typcache, DatumGetRangeType(hslot.values[i]), + range_deserialize(typcache, DatumGetRangeTypeP(hslot.values[i]), &hist_lower[i], &hist_upper[i], &empty); /* The histogram should not contain any empty ranges */ if (empty) diff --git a/src/backend/utils/adt/rangetypes_spgist.c b/src/backend/utils/adt/rangetypes_spgist.c index e82c4e1a9e1..d934105d322 100644 --- a/src/backend/utils/adt/rangetypes_spgist.c +++ b/src/backend/utils/adt/rangetypes_spgist.c @@ -132,7 +132,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) { spgChooseIn *in = (spgChooseIn *) PG_GETARG_POINTER(0); spgChooseOut *out = (spgChooseOut *) PG_GETARG_POINTER(1); - RangeType *inRange = DatumGetRangeType(in->datum), + RangeType *inRange = DatumGetRangeTypeP(in->datum), *centroid; int16 quadrant; TypeCacheEntry *typcache; @@ -142,7 +142,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) out->resultType = spgMatchNode; /* nodeN will be set by core */ out->result.matchNode.levelAdd = 0; - out->result.matchNode.restDatum = RangeTypeGetDatum(inRange); + out->result.matchNode.restDatum = RangeTypePGetDatum(inRange); PG_RETURN_VOID(); } @@ -161,11 +161,11 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) else out->result.matchNode.nodeN = 1; out->result.matchNode.levelAdd = 1; - out->result.matchNode.restDatum = RangeTypeGetDatum(inRange); + out->result.matchNode.restDatum = RangeTypePGetDatum(inRange); PG_RETURN_VOID(); } - centroid = DatumGetRangeType(in->prefixDatum); + centroid = DatumGetRangeTypeP(in->prefixDatum); quadrant = getQuadrant(typcache, centroid, inRange); Assert(quadrant <= in->nNodes); @@ -174,7 +174,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) out->resultType = spgMatchNode; out->result.matchNode.nodeN = quadrant - 1; out->result.matchNode.levelAdd = 1; - out->result.matchNode.restDatum = RangeTypeGetDatum(inRange); + out->result.matchNode.restDatum = RangeTypePGetDatum(inRange); PG_RETURN_VOID(); } @@ -213,7 +213,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) *upperBounds; typcache = range_get_typcache(fcinfo, - RangeTypeGetOid(DatumGetRangeType(in->datums[0]))); + RangeTypeGetOid(DatumGetRangeTypeP(in->datums[0]))); /* Allocate memory for bounds */ lowerBounds = palloc(sizeof(RangeBound) * in->nTuples); @@ -223,7 +223,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) /* Deserialize bounds of ranges, count non-empty ranges */ for (i = 0; i < in->nTuples; i++) { - range_deserialize(typcache, DatumGetRangeType(in->datums[i]), + range_deserialize(typcache, DatumGetRangeTypeP(in->datums[i]), &lowerBounds[j], &upperBounds[j], &empty); if (!empty) j++; @@ -249,9 +249,9 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) /* Place all ranges into node 0 */ for (i = 0; i < in->nTuples; i++) { - RangeType *range = DatumGetRangeType(in->datums[i]); + RangeType *range = DatumGetRangeTypeP(in->datums[i]); - out->leafTupleDatums[i] = RangeTypeGetDatum(range); + out->leafTupleDatums[i] = RangeTypePGetDatum(range); out->mapTuplesToNodes[i] = 0; } PG_RETURN_VOID(); @@ -267,7 +267,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) centroid = range_serialize(typcache, &lowerBounds[nonEmptyCount / 2], &upperBounds[nonEmptyCount / 2], false); out->hasPrefix = true; - out->prefixDatum = RangeTypeGetDatum(centroid); + out->prefixDatum = RangeTypePGetDatum(centroid); /* Create node for empty ranges only if it is a root node */ out->nNodes = (in->level == 0) ? 5 : 4; @@ -282,10 +282,10 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) */ for (i = 0; i < in->nTuples; i++) { - RangeType *range = DatumGetRangeType(in->datums[i]); + RangeType *range = DatumGetRangeTypeP(in->datums[i]); int16 quadrant = getQuadrant(typcache, centroid, range); - out->leafTupleDatums[i] = RangeTypeGetDatum(range); + out->leafTupleDatums[i] = RangeTypePGetDatum(range); out->mapTuplesToNodes[i] = quadrant - 1; } @@ -347,7 +347,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) */ if (strategy != RANGESTRAT_CONTAINS_ELEM) empty = RangeIsEmpty( - DatumGetRangeType(in->scankeys[i].sk_argument)); + DatumGetRangeTypeP(in->scankeys[i].sk_argument)); else empty = false; @@ -415,9 +415,9 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) RangeType *centroid; /* This node has a centroid. Fetch it. */ - centroid = DatumGetRangeType(in->prefixDatum); + centroid = DatumGetRangeTypeP(in->prefixDatum); typcache = range_get_typcache(fcinfo, - RangeTypeGetOid(DatumGetRangeType(centroid))); + RangeTypeGetOid(DatumGetRangeTypeP(centroid))); range_deserialize(typcache, centroid, ¢roidLower, ¢roidUpper, ¢roidEmpty); @@ -482,7 +482,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) } else { - range = DatumGetRangeType(in->scankeys[i].sk_argument); + range = DatumGetRangeTypeP(in->scankeys[i].sk_argument); range_deserialize(typcache, range, &lower, &upper, &empty); } @@ -558,7 +558,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) */ if (in->traversalValue != (Datum) 0) { - prevCentroid = DatumGetRangeType(in->traversalValue); + prevCentroid = DatumGetRangeTypeP(in->traversalValue); range_deserialize(typcache, prevCentroid, &prevLower, &prevUpper, &prevEmpty); } @@ -921,7 +921,7 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS) { spgLeafConsistentIn *in = (spgLeafConsistentIn *) PG_GETARG_POINTER(0); spgLeafConsistentOut *out = (spgLeafConsistentOut *) PG_GETARG_POINTER(1); - RangeType *leafRange = DatumGetRangeType(in->leafDatum); + RangeType *leafRange = DatumGetRangeTypeP(in->leafDatum); TypeCacheEntry *typcache; bool res; int i; @@ -945,35 +945,35 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS) { case RANGESTRAT_BEFORE: res = range_before_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_OVERLEFT: res = range_overleft_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_OVERLAPS: res = range_overlaps_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_OVERRIGHT: res = range_overright_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_AFTER: res = range_after_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_ADJACENT: res = range_adjacent_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_CONTAINS: res = range_contains_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_CONTAINED_BY: res = range_contained_by_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; case RANGESTRAT_CONTAINS_ELEM: res = range_contains_elem_internal(typcache, leafRange, @@ -981,7 +981,7 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS) break; case RANGESTRAT_EQ: res = range_eq_internal(typcache, leafRange, - DatumGetRangeType(keyDatum)); + DatumGetRangeTypeP(keyDatum)); break; default: elog(ERROR, "unrecognized range strategy: %d", diff --git a/src/backend/utils/adt/rangetypes_typanalyze.c b/src/backend/utils/adt/rangetypes_typanalyze.c index 324bbe48e5f..3efd982d1b2 100644 --- a/src/backend/utils/adt/rangetypes_typanalyze.c +++ b/src/backend/utils/adt/rangetypes_typanalyze.c @@ -144,7 +144,7 @@ compute_range_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, total_width += VARSIZE_ANY(DatumGetPointer(value)); /* Get range and deserialize it for further analysis. */ - range = DatumGetRangeType(value); + range = DatumGetRangeTypeP(value); range_deserialize(typcache, range, &lower, &upper, &empty); if (!empty) diff --git a/src/backend/utils/adt/tsgistidx.c b/src/backend/utils/adt/tsgistidx.c index d8b86f63931..732d87f22ff 100644 --- a/src/backend/utils/adt/tsgistidx.c +++ b/src/backend/utils/adt/tsgistidx.c @@ -110,7 +110,7 @@ static int outbuf_maxlen = 0; Datum gtsvectorout(PG_FUNCTION_ARGS) { - SignTSVector *key = (SignTSVector *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_POINTER(0))); + SignTSVector *key = (SignTSVector *) PG_DETOAST_DATUM(PG_GETARG_POINTER(0)); char *outbuf; if (outbuf_maxlen == 0) @@ -273,7 +273,7 @@ Datum gtsvector_decompress(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - SignTSVector *key = (SignTSVector *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); + SignTSVector *key = (SignTSVector *) PG_DETOAST_DATUM(entry->key); if (key != (SignTSVector *) DatumGetPointer(entry->key)) { diff --git a/src/include/utils/array.h b/src/include/utils/array.h index 61a67a21e36..d6d3c582b6a 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -252,7 +252,7 @@ typedef struct ArrayIteratorData *ArrayIterator; #define PG_RETURN_EXPANDED_ARRAY(x) PG_RETURN_DATUM(EOHPGetRWDatum(&(x)->hdr)) /* fmgr macros for AnyArrayType (ie, get either varlena or expanded form) */ -#define PG_GETARG_ANY_ARRAY(n) DatumGetAnyArray(PG_GETARG_DATUM(n)) +#define PG_GETARG_ANY_ARRAY_P(n) DatumGetAnyArrayP(PG_GETARG_DATUM(n)) /* * Access macros for varlena array header fields. @@ -440,7 +440,7 @@ extern Datum expand_array(Datum arraydatum, MemoryContext parentcontext, extern ExpandedArrayHeader *DatumGetExpandedArray(Datum d); extern ExpandedArrayHeader *DatumGetExpandedArrayX(Datum d, ArrayMetaState *metacache); -extern AnyArrayType *DatumGetAnyArray(Datum d); +extern AnyArrayType *DatumGetAnyArrayP(Datum d); extern void deconstruct_expanded_array(ExpandedArrayHeader *eah); #endif /* ARRAY_H */ diff --git a/src/include/utils/jsonb.h b/src/include/utils/jsonb.h index 24f491663bb..d639bbc960e 100644 --- a/src/include/utils/jsonb.h +++ b/src/include/utils/jsonb.h @@ -65,10 +65,10 @@ typedef enum #define JGIN_MAXLENGTH 125 /* max length of text part before hashing */ /* Convenience macros */ -#define DatumGetJsonb(d) ((Jsonb *) PG_DETOAST_DATUM(d)) -#define JsonbGetDatum(p) PointerGetDatum(p) -#define PG_GETARG_JSONB(x) DatumGetJsonb(PG_GETARG_DATUM(x)) -#define PG_RETURN_JSONB(x) PG_RETURN_POINTER(x) +#define DatumGetJsonbP(d) ((Jsonb *) PG_DETOAST_DATUM(d)) +#define JsonbPGetDatum(p) PointerGetDatum(p) +#define PG_GETARG_JSONB_P(x) DatumGetJsonbP(PG_GETARG_DATUM(x)) +#define PG_RETURN_JSONB_P(x) PG_RETURN_POINTER(x) typedef struct JsonbPair JsonbPair; typedef struct JsonbValue JsonbValue; diff --git a/src/include/utils/rangetypes.h b/src/include/utils/rangetypes.h index 55448893170..1ef5e542536 100644 --- a/src/include/utils/rangetypes.h +++ b/src/include/utils/rangetypes.h @@ -68,12 +68,12 @@ typedef struct /* * fmgr macros for range type objects */ -#define DatumGetRangeType(X) ((RangeType *) PG_DETOAST_DATUM(X)) -#define DatumGetRangeTypeCopy(X) ((RangeType *) PG_DETOAST_DATUM_COPY(X)) -#define RangeTypeGetDatum(X) PointerGetDatum(X) -#define PG_GETARG_RANGE(n) DatumGetRangeType(PG_GETARG_DATUM(n)) -#define PG_GETARG_RANGE_COPY(n) DatumGetRangeTypeCopy(PG_GETARG_DATUM(n)) -#define PG_RETURN_RANGE(x) return RangeTypeGetDatum(x) +#define DatumGetRangeTypeP(X) ((RangeType *) PG_DETOAST_DATUM(X)) +#define DatumGetRangeTypePCopy(X) ((RangeType *) PG_DETOAST_DATUM_COPY(X)) +#define RangeTypePGetDatum(X) PointerGetDatum(X) +#define PG_GETARG_RANGE_P(n) DatumGetRangeTypeP(PG_GETARG_DATUM(n)) +#define PG_GETARG_RANGE_P_COPY(n) DatumGetRangeTypePCopy(PG_GETARG_DATUM(n)) +#define PG_RETURN_RANGE_P(x) return RangeTypePGetDatum(x) /* Operator strategy numbers used in the GiST and SP-GiST range opclasses */ /* Numbers are chosen to match up operator names with existing usages */ |