Commit 4bd19946 authored by Tom Lane's avatar Tom Lane

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
parent 3e1683d3
...@@ -171,7 +171,7 @@ Datum ...@@ -171,7 +171,7 @@ Datum
gbt_bpchar_consistent(PG_FUNCTION_ARGS) gbt_bpchar_consistent(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
void *query = (void *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); void *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1));
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/* Oid subtype = PG_GETARG_OID(3); */ /* Oid subtype = PG_GETARG_OID(3); */
......
...@@ -37,7 +37,7 @@ Datum ...@@ -37,7 +37,7 @@ Datum
gbt_var_decompress(PG_FUNCTION_ARGS) gbt_var_decompress(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); GBT_VARKEY *key = (GBT_VARKEY *) PG_DETOAST_DATUM(entry->key);
if (key != (GBT_VARKEY *) DatumGetPointer(entry->key)) if (key != (GBT_VARKEY *) DatumGetPointer(entry->key))
{ {
...@@ -159,7 +159,7 @@ gbt_var_node_cp_len(const GBT_VARKEY *node, const gbtree_vinfo *tinfo) ...@@ -159,7 +159,7 @@ gbt_var_node_cp_len(const GBT_VARKEY *node, const gbtree_vinfo *tinfo)
l--; l--;
i++; i++;
} }
return ml; /* lower == upper */ return ml; /* lower == upper */
} }
...@@ -307,7 +307,7 @@ Datum ...@@ -307,7 +307,7 @@ Datum
gbt_var_fetch(PG_FUNCTION_ARGS) gbt_var_fetch(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); GBT_VARKEY *key = (GBT_VARKEY *) PG_DETOAST_DATUM(entry->key);
GBT_VARKEY_R r = gbt_var_key_readable(key); GBT_VARKEY_R r = gbt_var_key_readable(key);
GISTENTRY *retval; GISTENTRY *retval;
......
This diff is collapsed.
...@@ -49,9 +49,9 @@ typedef struct NDBOX ...@@ -49,9 +49,9 @@ typedef struct NDBOX
#define CUBE_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2) #define CUBE_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2)
/* fmgr interface macros */ /* fmgr interface macros */
#define DatumGetNDBOX(x) ((NDBOX *) PG_DETOAST_DATUM(x)) #define DatumGetNDBOXP(x) ((NDBOX *) PG_DETOAST_DATUM(x))
#define PG_GETARG_NDBOX(x) DatumGetNDBOX(PG_GETARG_DATUM(x)) #define PG_GETARG_NDBOX_P(x) DatumGetNDBOXP(PG_GETARG_DATUM(x))
#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x) #define PG_RETURN_NDBOX_P(x) PG_RETURN_POINTER(x)
/* GiST operator strategy numbers */ /* GiST operator strategy numbers */
#define CubeKNNDistanceCoord 15 /* ~> */ #define CubeKNNDistanceCoord 15 /* ~> */
......
...@@ -151,7 +151,7 @@ extern HStore *hstoreUpgrade(Datum orig); ...@@ -151,7 +151,7 @@ extern HStore *hstoreUpgrade(Datum orig);
#define DatumGetHStoreP(d) hstoreUpgrade(d) #define DatumGetHStoreP(d) hstoreUpgrade(d)
#define PG_GETARG_HS(x) DatumGetHStoreP(PG_GETARG_DATUM(x)) #define PG_GETARG_HSTORE_P(x) DatumGetHStoreP(PG_GETARG_DATUM(x))
/* /*
......
...@@ -43,7 +43,7 @@ makeitem(char *str, int len, char flag) ...@@ -43,7 +43,7 @@ makeitem(char *str, int len, char flag)
Datum Datum
gin_extract_hstore(PG_FUNCTION_ARGS) gin_extract_hstore(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
int32 *nentries = (int32 *) PG_GETARG_POINTER(1); int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
Datum *entries = NULL; Datum *entries = NULL;
HEntry *hsent = ARRPTR(hs); HEntry *hsent = ARRPTR(hs);
...@@ -155,7 +155,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS) ...@@ -155,7 +155,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS)
bool *check = (bool *) PG_GETARG_POINTER(0); bool *check = (bool *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1); StrategyNumber strategy = PG_GETARG_UINT16(1);
/* HStore *query = PG_GETARG_HS(2); */ /* HStore *query = PG_GETARG_HSTORE_P(2); */
int32 nkeys = PG_GETARG_INT32(3); int32 nkeys = PG_GETARG_INT32(3);
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
......
...@@ -518,7 +518,7 @@ ghstore_consistent(PG_FUNCTION_ARGS) ...@@ -518,7 +518,7 @@ ghstore_consistent(PG_FUNCTION_ARGS)
if (strategy == HStoreContainsStrategyNumber || if (strategy == HStoreContainsStrategyNumber ||
strategy == HStoreOldContainsStrategyNumber) strategy == HStoreOldContainsStrategyNumber)
{ {
HStore *query = PG_GETARG_HS(1); HStore *query = PG_GETARG_HSTORE_P(1);
HEntry *qe = ARRPTR(query); HEntry *qe = ARRPTR(query);
char *qv = STRPTR(query); char *qv = STRPTR(query);
int count = HS_COUNT(query); int count = HS_COUNT(query);
......
...@@ -962,7 +962,7 @@ hstore_populate_record(PG_FUNCTION_ARGS) ...@@ -962,7 +962,7 @@ hstore_populate_record(PG_FUNCTION_ARGS)
tupTypmod = HeapTupleHeaderGetTypMod(rec); tupTypmod = HeapTupleHeaderGetTypMod(rec);
} }
hs = PG_GETARG_HS(1); hs = PG_GETARG_HSTORE_P(1);
entries = ARRPTR(hs); entries = ARRPTR(hs);
ptr = STRPTR(hs); ptr = STRPTR(hs);
...@@ -1127,7 +1127,7 @@ PG_FUNCTION_INFO_V1(hstore_out); ...@@ -1127,7 +1127,7 @@ PG_FUNCTION_INFO_V1(hstore_out);
Datum Datum
hstore_out(PG_FUNCTION_ARGS) hstore_out(PG_FUNCTION_ARGS)
{ {
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int buflen, int buflen,
i; i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
...@@ -1198,7 +1198,7 @@ PG_FUNCTION_INFO_V1(hstore_send); ...@@ -1198,7 +1198,7 @@ PG_FUNCTION_INFO_V1(hstore_send);
Datum Datum
hstore_send(PG_FUNCTION_ARGS) hstore_send(PG_FUNCTION_ARGS)
{ {
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int i; int i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
char *base = STRPTR(in); char *base = STRPTR(in);
...@@ -1244,7 +1244,7 @@ PG_FUNCTION_INFO_V1(hstore_to_json_loose); ...@@ -1244,7 +1244,7 @@ PG_FUNCTION_INFO_V1(hstore_to_json_loose);
Datum Datum
hstore_to_json_loose(PG_FUNCTION_ARGS) hstore_to_json_loose(PG_FUNCTION_ARGS)
{ {
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int i; int i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
char *base = STRPTR(in); char *base = STRPTR(in);
...@@ -1299,7 +1299,7 @@ PG_FUNCTION_INFO_V1(hstore_to_json); ...@@ -1299,7 +1299,7 @@ PG_FUNCTION_INFO_V1(hstore_to_json);
Datum Datum
hstore_to_json(PG_FUNCTION_ARGS) hstore_to_json(PG_FUNCTION_ARGS)
{ {
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int i; int i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
char *base = STRPTR(in); char *base = STRPTR(in);
...@@ -1344,7 +1344,7 @@ PG_FUNCTION_INFO_V1(hstore_to_jsonb); ...@@ -1344,7 +1344,7 @@ PG_FUNCTION_INFO_V1(hstore_to_jsonb);
Datum Datum
hstore_to_jsonb(PG_FUNCTION_ARGS) hstore_to_jsonb(PG_FUNCTION_ARGS)
{ {
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int i; int i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
char *base = STRPTR(in); char *base = STRPTR(in);
...@@ -1387,7 +1387,7 @@ PG_FUNCTION_INFO_V1(hstore_to_jsonb_loose); ...@@ -1387,7 +1387,7 @@ PG_FUNCTION_INFO_V1(hstore_to_jsonb_loose);
Datum Datum
hstore_to_jsonb_loose(PG_FUNCTION_ARGS) hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
{ {
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int i; int i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
char *base = STRPTR(in); char *base = STRPTR(in);
......
...@@ -130,7 +130,7 @@ PG_FUNCTION_INFO_V1(hstore_fetchval); ...@@ -130,7 +130,7 @@ PG_FUNCTION_INFO_V1(hstore_fetchval);
Datum Datum
hstore_fetchval(PG_FUNCTION_ARGS) hstore_fetchval(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
text *key = PG_GETARG_TEXT_PP(1); text *key = PG_GETARG_TEXT_PP(1);
HEntry *entries = ARRPTR(hs); HEntry *entries = ARRPTR(hs);
text *out; text *out;
...@@ -151,7 +151,7 @@ PG_FUNCTION_INFO_V1(hstore_exists); ...@@ -151,7 +151,7 @@ PG_FUNCTION_INFO_V1(hstore_exists);
Datum Datum
hstore_exists(PG_FUNCTION_ARGS) hstore_exists(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
text *key = PG_GETARG_TEXT_PP(1); text *key = PG_GETARG_TEXT_PP(1);
int idx = hstoreFindKey(hs, NULL, int idx = hstoreFindKey(hs, NULL,
VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key)); VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key));
...@@ -164,7 +164,7 @@ PG_FUNCTION_INFO_V1(hstore_exists_any); ...@@ -164,7 +164,7 @@ PG_FUNCTION_INFO_V1(hstore_exists_any);
Datum Datum
hstore_exists_any(PG_FUNCTION_ARGS) hstore_exists_any(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
int nkeys; int nkeys;
Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys); Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys);
...@@ -198,7 +198,7 @@ PG_FUNCTION_INFO_V1(hstore_exists_all); ...@@ -198,7 +198,7 @@ PG_FUNCTION_INFO_V1(hstore_exists_all);
Datum Datum
hstore_exists_all(PG_FUNCTION_ARGS) hstore_exists_all(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
int nkeys; int nkeys;
Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys); Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys);
...@@ -232,7 +232,7 @@ PG_FUNCTION_INFO_V1(hstore_defined); ...@@ -232,7 +232,7 @@ PG_FUNCTION_INFO_V1(hstore_defined);
Datum Datum
hstore_defined(PG_FUNCTION_ARGS) hstore_defined(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
text *key = PG_GETARG_TEXT_PP(1); text *key = PG_GETARG_TEXT_PP(1);
HEntry *entries = ARRPTR(hs); HEntry *entries = ARRPTR(hs);
int idx = hstoreFindKey(hs, NULL, int idx = hstoreFindKey(hs, NULL,
...@@ -247,7 +247,7 @@ PG_FUNCTION_INFO_V1(hstore_delete); ...@@ -247,7 +247,7 @@ PG_FUNCTION_INFO_V1(hstore_delete);
Datum Datum
hstore_delete(PG_FUNCTION_ARGS) hstore_delete(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
text *key = PG_GETARG_TEXT_PP(1); text *key = PG_GETARG_TEXT_PP(1);
char *keyptr = VARDATA_ANY(key); char *keyptr = VARDATA_ANY(key);
int keylen = VARSIZE_ANY_EXHDR(key); int keylen = VARSIZE_ANY_EXHDR(key);
...@@ -294,7 +294,7 @@ PG_FUNCTION_INFO_V1(hstore_delete_array); ...@@ -294,7 +294,7 @@ PG_FUNCTION_INFO_V1(hstore_delete_array);
Datum Datum
hstore_delete_array(PG_FUNCTION_ARGS) hstore_delete_array(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
HStore *out = palloc(VARSIZE(hs)); HStore *out = palloc(VARSIZE(hs));
int hs_count = HS_COUNT(hs); int hs_count = HS_COUNT(hs);
char *ps, char *ps,
...@@ -373,8 +373,8 @@ PG_FUNCTION_INFO_V1(hstore_delete_hstore); ...@@ -373,8 +373,8 @@ PG_FUNCTION_INFO_V1(hstore_delete_hstore);
Datum Datum
hstore_delete_hstore(PG_FUNCTION_ARGS) hstore_delete_hstore(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
HStore *hs2 = PG_GETARG_HS(1); HStore *hs2 = PG_GETARG_HSTORE_P(1);
HStore *out = palloc(VARSIZE(hs)); HStore *out = palloc(VARSIZE(hs));
int hs_count = HS_COUNT(hs); int hs_count = HS_COUNT(hs);
int hs2_count = HS_COUNT(hs2); int hs2_count = HS_COUNT(hs2);
...@@ -473,8 +473,8 @@ PG_FUNCTION_INFO_V1(hstore_concat); ...@@ -473,8 +473,8 @@ PG_FUNCTION_INFO_V1(hstore_concat);
Datum Datum
hstore_concat(PG_FUNCTION_ARGS) hstore_concat(PG_FUNCTION_ARGS)
{ {
HStore *s1 = PG_GETARG_HS(0); HStore *s1 = PG_GETARG_HSTORE_P(0);
HStore *s2 = PG_GETARG_HS(1); HStore *s2 = PG_GETARG_HSTORE_P(1);
HStore *out = palloc(VARSIZE(s1) + VARSIZE(s2)); HStore *out = palloc(VARSIZE(s1) + VARSIZE(s2));
char *ps1, char *ps1,
*ps2, *ps2,
...@@ -571,7 +571,7 @@ PG_FUNCTION_INFO_V1(hstore_slice_to_array); ...@@ -571,7 +571,7 @@ PG_FUNCTION_INFO_V1(hstore_slice_to_array);
Datum Datum
hstore_slice_to_array(PG_FUNCTION_ARGS) hstore_slice_to_array(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
HEntry *entries = ARRPTR(hs); HEntry *entries = ARRPTR(hs);
char *ptr = STRPTR(hs); char *ptr = STRPTR(hs);
ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1); ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1);
...@@ -634,7 +634,7 @@ PG_FUNCTION_INFO_V1(hstore_slice_to_hstore); ...@@ -634,7 +634,7 @@ PG_FUNCTION_INFO_V1(hstore_slice_to_hstore);
Datum Datum
hstore_slice_to_hstore(PG_FUNCTION_ARGS) hstore_slice_to_hstore(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
HEntry *entries = ARRPTR(hs); HEntry *entries = ARRPTR(hs);
char *ptr = STRPTR(hs); char *ptr = STRPTR(hs);
ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1); ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1);
...@@ -696,7 +696,7 @@ PG_FUNCTION_INFO_V1(hstore_akeys); ...@@ -696,7 +696,7 @@ PG_FUNCTION_INFO_V1(hstore_akeys);
Datum Datum
hstore_akeys(PG_FUNCTION_ARGS) hstore_akeys(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
Datum *d; Datum *d;
ArrayType *a; ArrayType *a;
HEntry *entries = ARRPTR(hs); HEntry *entries = ARRPTR(hs);
...@@ -731,7 +731,7 @@ PG_FUNCTION_INFO_V1(hstore_avals); ...@@ -731,7 +731,7 @@ PG_FUNCTION_INFO_V1(hstore_avals);
Datum Datum
hstore_avals(PG_FUNCTION_ARGS) hstore_avals(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
Datum *d; Datum *d;
bool *nulls; bool *nulls;
ArrayType *a; ArrayType *a;
...@@ -827,7 +827,7 @@ PG_FUNCTION_INFO_V1(hstore_to_array); ...@@ -827,7 +827,7 @@ PG_FUNCTION_INFO_V1(hstore_to_array);
Datum Datum
hstore_to_array(PG_FUNCTION_ARGS) hstore_to_array(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
ArrayType *out = hstore_to_array_internal(hs, 1); ArrayType *out = hstore_to_array_internal(hs, 1);
PG_RETURN_POINTER(out); PG_RETURN_POINTER(out);
...@@ -837,7 +837,7 @@ PG_FUNCTION_INFO_V1(hstore_to_matrix); ...@@ -837,7 +837,7 @@ PG_FUNCTION_INFO_V1(hstore_to_matrix);
Datum Datum
hstore_to_matrix(PG_FUNCTION_ARGS) hstore_to_matrix(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
ArrayType *out = hstore_to_array_internal(hs, 2); ArrayType *out = hstore_to_array_internal(hs, 2);
PG_RETURN_POINTER(out); PG_RETURN_POINTER(out);
...@@ -891,7 +891,7 @@ hstore_skeys(PG_FUNCTION_ARGS) ...@@ -891,7 +891,7 @@ hstore_skeys(PG_FUNCTION_ARGS)
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
{ {
hs = PG_GETARG_HS(0); hs = PG_GETARG_HSTORE_P(0);
funcctx = SRF_FIRSTCALL_INIT(); funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, NULL); setup_firstcall(funcctx, hs, NULL);
} }
...@@ -925,7 +925,7 @@ hstore_svals(PG_FUNCTION_ARGS) ...@@ -925,7 +925,7 @@ hstore_svals(PG_FUNCTION_ARGS)
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
{ {
hs = PG_GETARG_HS(0); hs = PG_GETARG_HSTORE_P(0);
funcctx = SRF_FIRSTCALL_INIT(); funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, NULL); setup_firstcall(funcctx, hs, NULL);
} }
...@@ -967,8 +967,8 @@ PG_FUNCTION_INFO_V1(hstore_contains); ...@@ -967,8 +967,8 @@ PG_FUNCTION_INFO_V1(hstore_contains);
Datum Datum
hstore_contains(PG_FUNCTION_ARGS) hstore_contains(PG_FUNCTION_ARGS)
{ {
HStore *val = PG_GETARG_HS(0); HStore *val = PG_GETARG_HSTORE_P(0);
HStore *tmpl = PG_GETARG_HS(1); HStore *tmpl = PG_GETARG_HSTORE_P(1);
bool res = true; bool res = true;
HEntry *te = ARRPTR(tmpl); HEntry *te = ARRPTR(tmpl);
char *tstr = STRPTR(tmpl); char *tstr = STRPTR(tmpl);
...@@ -1032,7 +1032,7 @@ hstore_each(PG_FUNCTION_ARGS) ...@@ -1032,7 +1032,7 @@ hstore_each(PG_FUNCTION_ARGS)
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
{ {
hs = PG_GETARG_HS(0); hs = PG_GETARG_HSTORE_P(0);
funcctx = SRF_FIRSTCALL_INIT(); funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, fcinfo); setup_firstcall(funcctx, hs, fcinfo);
} }
...@@ -1087,8 +1087,8 @@ PG_FUNCTION_INFO_V1(hstore_cmp); ...@@ -1087,8 +1087,8 @@ PG_FUNCTION_INFO_V1(hstore_cmp);
Datum Datum
hstore_cmp(PG_FUNCTION_ARGS) hstore_cmp(PG_FUNCTION_ARGS)
{ {
HStore *hs1 = PG_GETARG_HS(0); HStore *hs1 = PG_GETARG_HSTORE_P(0);
HStore *hs2 = PG_GETARG_HS(1); HStore *hs2 = PG_GETARG_HSTORE_P(1);
int hcount1 = HS_COUNT(hs1); int hcount1 = HS_COUNT(hs1);
int hcount2 = HS_COUNT(hs2); int hcount2 = HS_COUNT(hs2);
int res = 0; int res = 0;
...@@ -1235,7 +1235,7 @@ PG_FUNCTION_INFO_V1(hstore_hash); ...@@ -1235,7 +1235,7 @@ PG_FUNCTION_INFO_V1(hstore_hash);
Datum Datum
hstore_hash(PG_FUNCTION_ARGS) hstore_hash(PG_FUNCTION_ARGS)
{ {
HStore *hs = PG_GETARG_HS(0); HStore *hs = PG_GETARG_HSTORE_P(0);
Datum hval = hash_any((unsigned char *) VARDATA(hs), Datum hval = hash_any((unsigned char *) VARDATA(hs),
VARSIZE(hs) - VARHDRSZ); VARSIZE(hs) - VARHDRSZ);
......
...@@ -68,7 +68,7 @@ Datum ...@@ -68,7 +68,7 @@ Datum
hstore_to_plperl(PG_FUNCTION_ARGS) hstore_to_plperl(PG_FUNCTION_ARGS)
{ {
dTHX; dTHX;
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int i; int i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
char *base = STRPTR(in); char *base = STRPTR(in);
......
...@@ -85,7 +85,7 @@ PG_FUNCTION_INFO_V1(hstore_to_plpython); ...@@ -85,7 +85,7 @@ PG_FUNCTION_INFO_V1(hstore_to_plpython);
Datum Datum
hstore_to_plpython(PG_FUNCTION_ARGS) hstore_to_plpython(PG_FUNCTION_ARGS)
{ {
HStore *in = PG_GETARG_HS(0); HStore *in = PG_GETARG_HSTORE_P(0);
int i; int i;
int count = HS_COUNT(in); int count = HS_COUNT(in);
char *base = STRPTR(in); char *base = STRPTR(in);
......
...@@ -545,7 +545,7 @@ Datum ...@@ -545,7 +545,7 @@ Datum
_ltree_consistent(PG_FUNCTION_ARGS) _ltree_consistent(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
char *query = (char *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); void *query = (void *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/* Oid subtype = PG_GETARG_OID(3); */ /* Oid subtype = PG_GETARG_OID(3); */
......
...@@ -71,7 +71,7 @@ Datum ...@@ -71,7 +71,7 @@ Datum
_ltree_isparent(PG_FUNCTION_ARGS) _ltree_isparent(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltree *query = PG_GETARG_LTREE(1); ltree *query = PG_GETARG_LTREE_P(1);
bool res = array_iterator(la, ltree_isparent, (void *) query, NULL); bool res = array_iterator(la, ltree_isparent, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0); PG_FREE_IF_COPY(la, 0);
...@@ -92,7 +92,7 @@ Datum ...@@ -92,7 +92,7 @@ Datum
_ltree_risparent(PG_FUNCTION_ARGS) _ltree_risparent(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltree *query = PG_GETARG_LTREE(1); ltree *query = PG_GETARG_LTREE_P(1);
bool res = array_iterator(la, ltree_risparent, (void *) query, NULL); bool res = array_iterator(la, ltree_risparent, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0); PG_FREE_IF_COPY(la, 0);
...@@ -113,7 +113,7 @@ Datum ...@@ -113,7 +113,7 @@ Datum
_ltq_regex(PG_FUNCTION_ARGS) _ltq_regex(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
lquery *query = PG_GETARG_LQUERY(1); lquery *query = PG_GETARG_LQUERY_P(1);
bool res = array_iterator(la, ltq_regex, (void *) query, NULL); bool res = array_iterator(la, ltq_regex, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0); PG_FREE_IF_COPY(la, 0);
...@@ -178,7 +178,7 @@ Datum ...@@ -178,7 +178,7 @@ Datum
_ltxtq_exec(PG_FUNCTION_ARGS) _ltxtq_exec(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltxtquery *query = PG_GETARG_LTXTQUERY(1); ltxtquery *query = PG_GETARG_LTXTQUERY_P(1);
bool res = array_iterator(la, ltxtq_exec, (void *) query, NULL); bool res = array_iterator(la, ltxtq_exec, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0); PG_FREE_IF_COPY(la, 0);
...@@ -200,7 +200,7 @@ Datum ...@@ -200,7 +200,7 @@ Datum
_ltree_extract_isparent(PG_FUNCTION_ARGS) _ltree_extract_isparent(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltree *query = PG_GETARG_LTREE(1); ltree *query = PG_GETARG_LTREE_P(1);
ltree *found, ltree *found,
*item; *item;
...@@ -223,7 +223,7 @@ Datum ...@@ -223,7 +223,7 @@ Datum
_ltree_extract_risparent(PG_FUNCTION_ARGS) _ltree_extract_risparent(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltree *query = PG_GETARG_LTREE(1); ltree *query = PG_GETARG_LTREE_P(1);
ltree *found, ltree *found,
*item; *item;
...@@ -246,7 +246,7 @@ Datum ...@@ -246,7 +246,7 @@ Datum
_ltq_extract_regex(PG_FUNCTION_ARGS) _ltq_extract_regex(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
lquery *query = PG_GETARG_LQUERY(1); lquery *query = PG_GETARG_LQUERY_P(1);
ltree *found, ltree *found,
*item; *item;
...@@ -269,7 +269,7 @@ Datum ...@@ -269,7 +269,7 @@ Datum
_ltxtq_extract_exec(PG_FUNCTION_ARGS) _ltxtq_extract_exec(PG_FUNCTION_ARGS)
{ {
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltxtquery *query = PG_GETARG_LTXTQUERY(1); ltxtquery *query = PG_GETARG_LTXTQUERY_P(1);
ltree *found, ltree *found,
*item; *item;
......
...@@ -302,8 +302,8 @@ checkCond(lquery_level *curq, int query_numlevel, ltree_level *curt, int tree_nu ...@@ -302,8 +302,8 @@ checkCond(lquery_level *curq, int query_numlevel, ltree_level *curt, int tree_nu
Datum Datum
ltq_regex(PG_FUNCTION_ARGS) ltq_regex(PG_FUNCTION_ARGS)
{ {
ltree *tree = PG_GETARG_LTREE(0); ltree *tree = PG_GETARG_LTREE_P(0);
lquery *query = PG_GETARG_LQUERY(1); lquery *query = PG_GETARG_LQUERY_P(1);
bool res = false; bool res = false;
if (query->flag & LQUERY_HASNOT) if (query->flag & LQUERY_HASNOT)
...@@ -338,7 +338,7 @@ ltq_rregex(PG_FUNCTION_ARGS) ...@@ -338,7 +338,7 @@ ltq_rregex(PG_FUNCTION_ARGS)
Datum Datum
lt_q_regex(PG_FUNCTION_ARGS) lt_q_regex(PG_FUNCTION_ARGS)
{ {
ltree *tree = PG_GETARG_LTREE(0); ltree *tree = PG_GETARG_LTREE_P(0);
ArrayType *_query = PG_GETARG_ARRAYTYPE_P(1); ArrayType *_query = PG_GETARG_ARRAYTYPE_P(1);
lquery *query = (lquery *) ARR_DATA_PTR(_query); lquery *query = (lquery *) ARR_DATA_PTR(_query);
bool res = false; bool res = false;
......
...@@ -165,12 +165,21 @@ bool compare_subnode(ltree_level *t, char *q, int len, ...@@ -165,12 +165,21 @@ bool compare_subnode(ltree_level *t, char *q, int len,
ltree *lca_inner(ltree **a, int len); ltree *lca_inner(ltree **a, int len);
int ltree_strncasecmp(const char *a, const char *b, size_t s); int ltree_strncasecmp(const char *a, const char *b, size_t s);
#define PG_GETARG_LTREE(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) /* fmgr macros for ltree objects */
#define PG_GETARG_LTREE_COPY(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) #define DatumGetLtreeP(X) ((ltree *) PG_DETOAST_DATUM(X))
#define PG_GETARG_LQUERY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) #define DatumGetLtreePCopy(X) ((ltree *) PG_DETOAST_DATUM_COPY(X))
#define PG_GETARG_LQUERY_COPY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) #define PG_GETARG_LTREE_P(n) DatumGetLtreeP(PG_GETARG_DATUM(n))
#define PG_GETARG_LTXTQUERY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) #define PG_GETARG_LTREE_P_COPY(n) DatumGetLtreePCopy(PG_GETARG_DATUM(n))
#define PG_GETARG_LTXTQUERY_COPY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
#define DatumGetLqueryP(X) ((lquery *) PG_DETOAST_DATUM(X))
#define DatumGetLqueryPCopy(X) ((lquery *) PG_DETOAST_DATUM_COPY(X))
#define PG_GETARG_LQUERY_P(n) DatumGetLqueryP(PG_GETARG_DATUM(n))
#define PG_GETARG_LQUERY_P_COPY(n) DatumGetLqueryPCopy(PG_GETARG_DATUM(n))
#define DatumGetLtxtqueryP(X) ((ltxtquery *) PG_DETOAST_DATUM(X))
#define DatumGetLtxtqueryPCopy(X) ((ltxtquery *) PG_DETOAST_DATUM_COPY(X))
#define PG_GETARG_LTXTQUERY_P(n) DatumGetLtxtqueryP(PG_GETARG_DATUM(n))
#define PG_GETARG_LTXTQUERY_P_COPY(n) DatumGetLtxtqueryPCopy(PG_GETARG_DATUM(n))
/* GiST support for ltree */ /* GiST support for ltree */
......
...@@ -53,7 +53,7 @@ ltree_compress(PG_FUNCTION_ARGS) ...@@ -53,7 +53,7 @@ ltree_compress(PG_FUNCTION_ARGS)
if (entry->leafkey) if (entry->leafkey)
{ /* ltree */ { /* ltree */
ltree_gist *key; ltree_gist *key;
ltree *val = (ltree *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); ltree *val = DatumGetLtreeP(entry->key);
int32 len = LTG_HDRSIZE + VARSIZE(val); int32 len = LTG_HDRSIZE + VARSIZE(val);
key = (ltree_gist *) palloc0(len); key = (ltree_gist *) palloc0(len);
...@@ -73,7 +73,7 @@ Datum ...@@ -73,7 +73,7 @@ Datum
ltree_decompress(PG_FUNCTION_ARGS) ltree_decompress(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
ltree_gist *key = (ltree_gist *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); ltree_gist *key = (ltree_gist *) PG_DETOAST_DATUM(entry->key);
if (PointerGetDatum(key) != entry->key) if (PointerGetDatum(key) != entry->key)
{ {
...@@ -621,18 +621,18 @@ ltree_consistent(PG_FUNCTION_ARGS) ...@@ -621,18 +621,18 @@ ltree_consistent(PG_FUNCTION_ARGS)
switch (strategy) switch (strategy)
{ {
case BTLessStrategyNumber: case BTLessStrategyNumber:
query = PG_GETARG_LTREE(1); query = PG_GETARG_LTREE_P(1);
res = (GIST_LEAF(entry)) ? res = (GIST_LEAF(entry)) ?
(ltree_compare((ltree *) query, LTG_NODE(key)) > 0) (ltree_compare((ltree *) query, LTG_NODE(key)) > 0)
: :
(ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0); (ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0);
break; break;
case BTLessEqualStrategyNumber: case BTLessEqualStrategyNumber:
query = PG_GETARG_LTREE(1); query = PG_GETARG_LTREE_P(1);
res = (ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0); res = (ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0);
break; break;
case BTEqualStrategyNumber: case BTEqualStrategyNumber:
query = PG_GETARG_LTREE(1); query = PG_GETARG_LTREE_P(1);
if (GIST_LEAF(entry)) if (GIST_LEAF(entry))
res = (ltree_compare((ltree *) query, LTG_NODE(key)) == 0); res = (ltree_compare((ltree *) query, LTG_NODE(key)) == 0);
else else
...@@ -643,25 +643,25 @@ ltree_consistent(PG_FUNCTION_ARGS) ...@@ -643,25 +643,25 @@ ltree_consistent(PG_FUNCTION_ARGS)
); );
break; break;
case BTGreaterEqualStrategyNumber: case BTGreaterEqualStrategyNumber:
query = PG_GETARG_LTREE(1); query = PG_GETARG_LTREE_P(1);
res = (ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0); res = (ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0);
break; break;
case BTGreaterStrategyNumber: case BTGreaterStrategyNumber:
query = PG_GETARG_LTREE(1); query = PG_GETARG_LTREE_P(1);
res = (GIST_LEAF(entry)) ? res = (GIST_LEAF(entry)) ?
(ltree_compare((ltree *) query, LTG_GETRNODE(key)) < 0) (ltree_compare((ltree *) query, LTG_GETRNODE(key)) < 0)
: :
(ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0); (ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0);
break; break;
case 10: case 10:
query = PG_GETARG_LTREE_COPY(1); query = PG_GETARG_LTREE_P_COPY(1);
res = (GIST_LEAF(entry)) ? res = (GIST_LEAF(entry)) ?
inner_isparent((ltree *) query, LTG_NODE(key)) inner_isparent((ltree *) query, LTG_NODE(key))
: :
gist_isparent(key, (ltree *) query); gist_isparent(key, (ltree *) query);
break; break;
case 11: case 11:
query = PG_GETARG_LTREE(1); query = PG_GETARG_LTREE_P(1);
res = (GIST_LEAF(entry)) ? res = (GIST_LEAF(entry)) ?
inner_isparent(LTG_NODE(key), (ltree *) query) inner_isparent(LTG_NODE(key), (ltree *) query)
: :
...@@ -669,7 +669,7 @@ ltree_consistent(PG_FUNCTION_ARGS) ...@@ -669,7 +669,7 @@ ltree_consistent(PG_FUNCTION_ARGS)
break; break;
case 12: case 12:
case 13: case 13:
query = PG_GETARG_LQUERY(1); query = PG_GETARG_LQUERY_P(1);
if (GIST_LEAF(entry)) if (GIST_LEAF(entry))
res = DatumGetBool(DirectFunctionCall2(ltq_regex, res = DatumGetBool(DirectFunctionCall2(ltq_regex,
PointerGetDatum(LTG_NODE(key)), PointerGetDatum(LTG_NODE(key)),
...@@ -680,18 +680,18 @@ ltree_consistent(PG_FUNCTION_ARGS) ...@@ -680,18 +680,18 @@ ltree_consistent(PG_FUNCTION_ARGS)
break; break;
case 14: case 14:
case 15: case 15:
query = PG_GETARG_LQUERY(1); query = PG_GETARG_LTXTQUERY_P(1);
if (GIST_LEAF(entry)) if (GIST_LEAF(entry))
res = DatumGetBool(DirectFunctionCall2(ltxtq_exec, res = DatumGetBool(DirectFunctionCall2(ltxtq_exec,
PointerGetDatum(LTG_NODE(key)), PointerGetDatum(LTG_NODE(key)),
PointerGetDatum((lquery *) query) PointerGetDatum((ltxtquery *) query)
)); ));
else else
res = gist_qtxt(key, (ltxtquery *) query); res = gist_qtxt(key, (ltxtquery *) query);
break; break;
case 16: case 16:
case 17: case 17:
query = DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1))); query = PG_GETARG_ARRAYTYPE_P(1);
if (GIST_LEAF(entry)) if (GIST_LEAF(entry))
res = DatumGetBool(DirectFunctionCall2(lt_q_regex, res = DatumGetBool(DirectFunctionCall2(lt_q_regex,
PointerGetDatum(LTG_NODE(key)), PointerGetDatum(LTG_NODE(key)),
......
...@@ -149,7 +149,7 @@ ltree_in(PG_FUNCTION_ARGS) ...@@ -149,7 +149,7 @@ ltree_in(PG_FUNCTION_ARGS)
Datum Datum
ltree_out(PG_FUNCTION_ARGS) ltree_out(PG_FUNCTION_ARGS)
{ {
ltree *in = PG_GETARG_LTREE(0); ltree *in = PG_GETARG_LTREE_P(0);
char *buf, char *buf,
*ptr; *ptr;
int i; int i;
...@@ -521,7 +521,7 @@ lquery_in(PG_FUNCTION_ARGS) ...@@ -521,7 +521,7 @@ lquery_in(PG_FUNCTION_ARGS)
Datum Datum
lquery_out(PG_FUNCTION_ARGS) lquery_out(PG_FUNCTION_ARGS)
{ {
lquery *in = PG_GETARG_LQUERY(0); lquery *in = PG_GETARG_LQUERY_P(0);
char *buf, char *buf,
*ptr; *ptr;
int i, int i,
......
...@@ -67,65 +67,65 @@ ltree_compare(const ltree *a, const ltree *b) ...@@ -67,65 +67,65 @@ ltree_compare(const ltree *a, const ltree *b)
} }
#define RUNCMP \ #define RUNCMP \
ltree *a = PG_GETARG_LTREE(0); \ ltree *a = PG_GETARG_LTREE_P(0); \
ltree *b = PG_GETARG_LTREE(1); \ ltree *b = PG_GETARG_LTREE_P(1); \
int res = ltree_compare(a,b); \ int res = ltree_compare(a,b); \
PG_FREE_IF_COPY(a,0); \ PG_FREE_IF_COPY(a,0); \
PG_FREE_IF_COPY(b,1); \ PG_FREE_IF_COPY(b,1)
Datum Datum
ltree_cmp(PG_FUNCTION_ARGS) ltree_cmp(PG_FUNCTION_ARGS)
{ {
RUNCMP RUNCMP;
PG_RETURN_INT32(res); PG_RETURN_INT32(res);
} }
Datum Datum
ltree_lt(PG_FUNCTION_ARGS) ltree_lt(PG_FUNCTION_ARGS)
{ {
RUNCMP RUNCMP;
PG_RETURN_BOOL((res < 0) ? true : false); PG_RETURN_BOOL((res < 0) ? true : false);
} }
Datum Datum
ltree_le(PG_FUNCTION_ARGS) ltree_le(PG_FUNCTION_ARGS)
{ {
RUNCMP RUNCMP;
PG_RETURN_BOOL((res <= 0) ? true : false); PG_RETURN_BOOL((res <= 0) ? true : false);
} }
Datum Datum
ltree_eq(PG_FUNCTION_ARGS) ltree_eq(PG_FUNCTION_ARGS)
{ {
RUNCMP RUNCMP;
PG_RETURN_BOOL((res == 0) ? true : false); PG_RETURN_BOOL((res == 0) ? true : false);
} }
Datum Datum
ltree_ge(PG_FUNCTION_ARGS) ltree_ge(PG_FUNCTION_ARGS)
{ {
RUNCMP RUNCMP;
PG_RETURN_BOOL((res >= 0) ? true : false); PG_RETURN_BOOL((res >= 0) ? true : false);
} }
Datum Datum
ltree_gt(PG_FUNCTION_ARGS) ltree_gt(PG_FUNCTION_ARGS)
{ {
RUNCMP RUNCMP;
PG_RETURN_BOOL((res > 0) ? true : false); PG_RETURN_BOOL((res > 0) ? true : false);
} }
Datum Datum
ltree_ne(PG_FUNCTION_ARGS) ltree_ne(PG_FUNCTION_ARGS)
{ {
RUNCMP RUNCMP;
PG_RETURN_BOOL((res != 0) ? true : false); PG_RETURN_BOOL((res != 0) ? true : false);
} }
Datum Datum
nlevel(PG_FUNCTION_ARGS) nlevel(PG_FUNCTION_ARGS)
{ {
ltree *a = PG_GETARG_LTREE(0); ltree *a = PG_GETARG_LTREE_P(0);
int res = a->numlevel; int res = a->numlevel;
PG_FREE_IF_COPY(a, 0); PG_FREE_IF_COPY(a, 0);
...@@ -159,8 +159,8 @@ inner_isparent(const ltree *c, const ltree *p) ...@@ -159,8 +159,8 @@ inner_isparent(const ltree *c, const ltree *p)
Datum Datum
ltree_isparent(PG_FUNCTION_ARGS) ltree_isparent(PG_FUNCTION_ARGS)
{ {
ltree *c = PG_GETARG_LTREE(1); ltree *c = PG_GETARG_LTREE_P(1);
ltree *p = PG_GETARG_LTREE(0); ltree *p = PG_GETARG_LTREE_P(0);
bool res = inner_isparent(c, p); bool res = inner_isparent(c, p);
PG_FREE_IF_COPY(c, 1); PG_FREE_IF_COPY(c, 1);
...@@ -171,8 +171,8 @@ ltree_isparent(PG_FUNCTION_ARGS) ...@@ -171,8 +171,8 @@ ltree_isparent(PG_FUNCTION_ARGS)
Datum Datum
ltree_risparent(PG_FUNCTION_ARGS) ltree_risparent(PG_FUNCTION_ARGS)
{ {
ltree *c = PG_GETARG_LTREE(0); ltree *c = PG_GETARG_LTREE_P(0);
ltree *p = PG_GETARG_LTREE(1); ltree *p = PG_GETARG_LTREE_P(1);
bool res = inner_isparent(c, p); bool res = inner_isparent(c, p);
PG_FREE_IF_COPY(c, 0); PG_FREE_IF_COPY(c, 0);
...@@ -223,7 +223,7 @@ inner_subltree(ltree *t, int32 startpos, int32 endpos) ...@@ -223,7 +223,7 @@ inner_subltree(ltree *t, int32 startpos, int32 endpos)
Datum Datum
subltree(PG_FUNCTION_ARGS) subltree(PG_FUNCTION_ARGS)
{ {
ltree *t = PG_GETARG_LTREE(0); ltree *t = PG_GETARG_LTREE_P(0);
ltree *res = inner_subltree(t, PG_GETARG_INT32(1), PG_GETARG_INT32(2)); ltree *res = inner_subltree(t, PG_GETARG_INT32(1), PG_GETARG_INT32(2));
PG_FREE_IF_COPY(t, 0); PG_FREE_IF_COPY(t, 0);
...@@ -233,7 +233,7 @@ subltree(PG_FUNCTION_ARGS) ...@@ -233,7 +233,7 @@ subltree(PG_FUNCTION_ARGS)
Datum Datum
subpath(PG_FUNCTION_ARGS) subpath(PG_FUNCTION_ARGS)
{ {
ltree *t = PG_GETARG_LTREE(0); ltree *t = PG_GETARG_LTREE_P(0);
int32 start = PG_GETARG_INT32(1); int32 start = PG_GETARG_INT32(1);
int32 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0; int32 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int32 end; int32 end;
...@@ -282,8 +282,8 @@ ltree_concat(ltree *a, ltree *b) ...@@ -282,8 +282,8 @@ ltree_concat(ltree *a, ltree *b)
Datum Datum
ltree_addltree(PG_FUNCTION_ARGS) ltree_addltree(PG_FUNCTION_ARGS)
{ {
ltree *a = PG_GETARG_LTREE(0); ltree *a = PG_GETARG_LTREE_P(0);
ltree *b = PG_GETARG_LTREE(1); ltree *b = PG_GETARG_LTREE_P(1);
ltree *r; ltree *r;
r = ltree_concat(a, b); r = ltree_concat(a, b);
...@@ -295,7 +295,7 @@ ltree_addltree(PG_FUNCTION_ARGS) ...@@ -295,7 +295,7 @@ ltree_addltree(PG_FUNCTION_ARGS)
Datum Datum
ltree_addtext(PG_FUNCTION_ARGS) ltree_addtext(PG_FUNCTION_ARGS)
{ {
ltree *a = PG_GETARG_LTREE(0); ltree *a = PG_GETARG_LTREE_P(0);
text *b = PG_GETARG_TEXT_PP(1); text *b = PG_GETARG_TEXT_PP(1);
char *s; char *s;
ltree *r, ltree *r,
...@@ -320,8 +320,8 @@ ltree_addtext(PG_FUNCTION_ARGS) ...@@ -320,8 +320,8 @@ ltree_addtext(PG_FUNCTION_ARGS)
Datum Datum
ltree_index(PG_FUNCTION_ARGS) ltree_index(PG_FUNCTION_ARGS)
{ {
ltree *a = PG_GETARG_LTREE(0); ltree *a = PG_GETARG_LTREE_P(0);
ltree *b = PG_GETARG_LTREE(1); ltree *b = PG_GETARG_LTREE_P(1);
int start = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0; int start = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int i, int i,
j; j;
...@@ -380,7 +380,7 @@ ltree_index(PG_FUNCTION_ARGS) ...@@ -380,7 +380,7 @@ ltree_index(PG_FUNCTION_ARGS)
Datum Datum
ltree_textadd(PG_FUNCTION_ARGS) ltree_textadd(PG_FUNCTION_ARGS)
{ {
ltree *a = PG_GETARG_LTREE(1); ltree *a = PG_GETARG_LTREE_P(1);
text *b = PG_GETARG_TEXT_PP(0); text *b = PG_GETARG_TEXT_PP(0);
char *s; char *s;
ltree *r, ltree *r,
...@@ -476,7 +476,7 @@ lca(PG_FUNCTION_ARGS) ...@@ -476,7 +476,7 @@ lca(PG_FUNCTION_ARGS)
a = (ltree **) palloc(sizeof(ltree *) * fcinfo->nargs); a = (ltree **) palloc(sizeof(ltree *) * fcinfo->nargs);
for (i = 0; i < fcinfo->nargs; i++) for (i = 0; i < fcinfo->nargs; i++)
a[i] = PG_GETARG_LTREE(i); a[i] = PG_GETARG_LTREE_P(i);
res = lca_inner(a, (int) fcinfo->nargs); res = lca_inner(a, (int) fcinfo->nargs);
for (i = 0; i < fcinfo->nargs; i++) for (i = 0; i < fcinfo->nargs; i++)
PG_FREE_IF_COPY(a[i], i); PG_FREE_IF_COPY(a[i], i);
...@@ -508,7 +508,7 @@ text2ltree(PG_FUNCTION_ARGS) ...@@ -508,7 +508,7 @@ text2ltree(PG_FUNCTION_ARGS)
Datum Datum
ltree2text(PG_FUNCTION_ARGS) ltree2text(PG_FUNCTION_ARGS)
{ {
ltree *in = PG_GETARG_LTREE(0); ltree *in = PG_GETARG_LTREE_P(0);
char *ptr; char *ptr;
int i; int i;
ltree_level *curlevel; ltree_level *curlevel;
......
...@@ -515,7 +515,7 @@ infix(INFIX *in, bool first) ...@@ -515,7 +515,7 @@ infix(INFIX *in, bool first)
Datum Datum
ltxtq_out(PG_FUNCTION_ARGS) ltxtq_out(PG_FUNCTION_ARGS)
{ {
ltxtquery *query = PG_GETARG_LTXTQUERY(0); ltxtquery *query = PG_GETARG_LTXTQUERY_P(0);
INFIX nrm; INFIX nrm;
if (query->size == 0) if (query->size == 0)
......
...@@ -86,8 +86,8 @@ checkcondition_str(void *checkval, ITEM *val) ...@@ -86,8 +86,8 @@ checkcondition_str(void *checkval, ITEM *val)
Datum Datum
ltxtq_exec(PG_FUNCTION_ARGS) ltxtq_exec(PG_FUNCTION_ARGS)
{ {
ltree *val = PG_GETARG_LTREE(0); ltree *val = PG_GETARG_LTREE_P(0);
ltxtquery *query = PG_GETARG_LTXTQUERY(1); ltxtquery *query = PG_GETARG_LTXTQUERY_P(1);
CHKVAL chkval; CHKVAL chkval;
bool result; bool result;
......
...@@ -40,7 +40,7 @@ PG_FUNCTION_INFO_V1(ltree_to_plpython); ...@@ -40,7 +40,7 @@ PG_FUNCTION_INFO_V1(ltree_to_plpython);
Datum Datum
ltree_to_plpython(PG_FUNCTION_ARGS) ltree_to_plpython(PG_FUNCTION_ARGS)
{ {
ltree *in = PG_GETARG_LTREE(0); ltree *in = PG_GETARG_LTREE_P(0);
int i; int i;
PyObject *list; PyObject *list;
ltree_level *curlevel; ltree_level *curlevel;
......
...@@ -271,7 +271,7 @@ Datum ...@@ -271,7 +271,7 @@ Datum
jsonb_to_tsvector_byid(PG_FUNCTION_ARGS) jsonb_to_tsvector_byid(PG_FUNCTION_ARGS)
{ {
Oid cfgId = PG_GETARG_OID(0); Oid cfgId = PG_GETARG_OID(0);
Jsonb *jb = PG_GETARG_JSONB(1); Jsonb *jb = PG_GETARG_JSONB_P(1);
TSVector result; TSVector result;
TSVectorBuildState state; TSVectorBuildState state;
ParsedText prs; ParsedText prs;
...@@ -293,13 +293,13 @@ jsonb_to_tsvector_byid(PG_FUNCTION_ARGS) ...@@ -293,13 +293,13 @@ jsonb_to_tsvector_byid(PG_FUNCTION_ARGS)
Datum Datum
jsonb_to_tsvector(PG_FUNCTION_ARGS) jsonb_to_tsvector(PG_FUNCTION_ARGS)
{ {
Jsonb *jb = PG_GETARG_JSONB(0); Jsonb *jb = PG_GETARG_JSONB_P(0);
Oid cfgId; Oid cfgId;
cfgId = getTSCurrentConfig(true); cfgId = getTSCurrentConfig(true);
PG_RETURN_DATUM(DirectFunctionCall2(jsonb_to_tsvector_byid, PG_RETURN_DATUM(DirectFunctionCall2(jsonb_to_tsvector_byid,
ObjectIdGetDatum(cfgId), ObjectIdGetDatum(cfgId),
JsonbGetDatum(jb))); JsonbPGetDatum(jb)));
} }
Datum Datum
......
...@@ -383,7 +383,7 @@ Datum ...@@ -383,7 +383,7 @@ Datum
ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS) ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS)
{ {
Oid tsconfig = PG_GETARG_OID(0); 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); TSQuery query = PG_GETARG_TSQUERY(2);
text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL; text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
Jsonb *out; Jsonb *out;
...@@ -424,7 +424,7 @@ ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS) ...@@ -424,7 +424,7 @@ ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS)
pfree(prs.stopsel); pfree(prs.stopsel);
} }
PG_RETURN_JSONB(out); PG_RETURN_JSONB_P(out);
} }
Datum Datum
......
...@@ -394,11 +394,11 @@ DatumGetExpandedArrayX(Datum d, ArrayMetaState *metacache) ...@@ -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. * array. The result must not be modified in-place.
*/ */
AnyArrayType * AnyArrayType *
DatumGetAnyArray(Datum d) DatumGetAnyArrayP(Datum d)
{ {
ExpandedArrayHeader *eah; ExpandedArrayHeader *eah;
......
...@@ -1011,7 +1011,7 @@ CopyArrayEls(ArrayType *array, ...@@ -1011,7 +1011,7 @@ CopyArrayEls(ArrayType *array,
Datum Datum
array_out(PG_FUNCTION_ARGS) 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); Oid element_type = AARR_ELEMTYPE(v);
int typlen; int typlen;
bool typbyval; bool typbyval;
...@@ -1534,7 +1534,7 @@ ReadArrayBinary(StringInfo buf, ...@@ -1534,7 +1534,7 @@ ReadArrayBinary(StringInfo buf,
Datum Datum
array_send(PG_FUNCTION_ARGS) 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); Oid element_type = AARR_ELEMTYPE(v);
int typlen; int typlen;
bool typbyval; bool typbyval;
...@@ -1638,7 +1638,7 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1638,7 +1638,7 @@ array_send(PG_FUNCTION_ARGS)
Datum Datum
array_ndims(PG_FUNCTION_ARGS) 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? */ /* Sanity check: does it look like an array at all? */
if (AARR_NDIM(v) <= 0 || AARR_NDIM(v) > MAXDIM) if (AARR_NDIM(v) <= 0 || AARR_NDIM(v) > MAXDIM)
...@@ -1654,7 +1654,7 @@ array_ndims(PG_FUNCTION_ARGS) ...@@ -1654,7 +1654,7 @@ array_ndims(PG_FUNCTION_ARGS)
Datum Datum
array_dims(PG_FUNCTION_ARGS) array_dims(PG_FUNCTION_ARGS)
{ {
AnyArrayType *v = PG_GETARG_ANY_ARRAY(0); AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
char *p; char *p;
int i; int i;
int *dimv, int *dimv,
...@@ -1692,7 +1692,7 @@ array_dims(PG_FUNCTION_ARGS) ...@@ -1692,7 +1692,7 @@ array_dims(PG_FUNCTION_ARGS)
Datum Datum
array_lower(PG_FUNCTION_ARGS) 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 reqdim = PG_GETARG_INT32(1);
int *lb; int *lb;
int result; int result;
...@@ -1719,7 +1719,7 @@ array_lower(PG_FUNCTION_ARGS) ...@@ -1719,7 +1719,7 @@ array_lower(PG_FUNCTION_ARGS)
Datum Datum
array_upper(PG_FUNCTION_ARGS) 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 reqdim = PG_GETARG_INT32(1);
int *dimv, int *dimv,
*lb; *lb;
...@@ -1749,7 +1749,7 @@ array_upper(PG_FUNCTION_ARGS) ...@@ -1749,7 +1749,7 @@ array_upper(PG_FUNCTION_ARGS)
Datum Datum
array_length(PG_FUNCTION_ARGS) 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 reqdim = PG_GETARG_INT32(1);
int *dimv; int *dimv;
int result; int result;
...@@ -1776,7 +1776,7 @@ array_length(PG_FUNCTION_ARGS) ...@@ -1776,7 +1776,7 @@ array_length(PG_FUNCTION_ARGS)
Datum Datum
array_cardinality(PG_FUNCTION_ARGS) 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))); PG_RETURN_INT32(ArrayGetNItems(AARR_NDIM(v), AARR_DIMS(v)));
} }
...@@ -3147,7 +3147,7 @@ array_map(FunctionCallInfo fcinfo, Oid retType, ArrayMapState *amstate) ...@@ -3147,7 +3147,7 @@ array_map(FunctionCallInfo fcinfo, Oid retType, ArrayMapState *amstate)
elog(ERROR, "invalid nargs: %d", fcinfo->nargs); elog(ERROR, "invalid nargs: %d", fcinfo->nargs);
if (PG_ARGISNULL(0)) if (PG_ARGISNULL(0))
elog(ERROR, "null input array"); elog(ERROR, "null input array");
v = PG_GETARG_ANY_ARRAY(0); v = PG_GETARG_ANY_ARRAY_P(0);
inpType = AARR_ELEMTYPE(v); inpType = AARR_ELEMTYPE(v);
ndim = AARR_NDIM(v); ndim = AARR_NDIM(v);
...@@ -3589,8 +3589,8 @@ array_contains_nulls(ArrayType *array) ...@@ -3589,8 +3589,8 @@ array_contains_nulls(ArrayType *array)
Datum Datum
array_eq(PG_FUNCTION_ARGS) array_eq(PG_FUNCTION_ARGS)
{ {
AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0); AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1); AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION(); Oid collation = PG_GET_COLLATION();
int ndims1 = AARR_NDIM(array1); int ndims1 = AARR_NDIM(array1);
int ndims2 = AARR_NDIM(array2); int ndims2 = AARR_NDIM(array2);
...@@ -3760,8 +3760,8 @@ btarraycmp(PG_FUNCTION_ARGS) ...@@ -3760,8 +3760,8 @@ btarraycmp(PG_FUNCTION_ARGS)
static int static int
array_cmp(FunctionCallInfo fcinfo) array_cmp(FunctionCallInfo fcinfo)
{ {
AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0); AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1); AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION(); Oid collation = PG_GET_COLLATION();
int ndims1 = AARR_NDIM(array1); int ndims1 = AARR_NDIM(array1);
int ndims2 = AARR_NDIM(array2); int ndims2 = AARR_NDIM(array2);
...@@ -3931,7 +3931,7 @@ array_cmp(FunctionCallInfo fcinfo) ...@@ -3931,7 +3931,7 @@ array_cmp(FunctionCallInfo fcinfo)
Datum Datum
hash_array(PG_FUNCTION_ARGS) 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 ndims = AARR_NDIM(array);
int *dims = AARR_DIMS(array); int *dims = AARR_DIMS(array);
Oid element_type = AARR_ELEMTYPE(array); Oid element_type = AARR_ELEMTYPE(array);
...@@ -4028,7 +4028,7 @@ hash_array(PG_FUNCTION_ARGS) ...@@ -4028,7 +4028,7 @@ hash_array(PG_FUNCTION_ARGS)
Datum Datum
hash_array_extended(PG_FUNCTION_ARGS) 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); uint64 seed = PG_GETARG_INT64(1);
int ndims = AARR_NDIM(array); int ndims = AARR_NDIM(array);
int *dims = AARR_DIMS(array); int *dims = AARR_DIMS(array);
...@@ -4260,8 +4260,8 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation, ...@@ -4260,8 +4260,8 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation,
Datum Datum
arrayoverlap(PG_FUNCTION_ARGS) arrayoverlap(PG_FUNCTION_ARGS)
{ {
AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0); AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1); AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION(); Oid collation = PG_GET_COLLATION();
bool result; bool result;
...@@ -4278,8 +4278,8 @@ arrayoverlap(PG_FUNCTION_ARGS) ...@@ -4278,8 +4278,8 @@ arrayoverlap(PG_FUNCTION_ARGS)
Datum Datum
arraycontains(PG_FUNCTION_ARGS) arraycontains(PG_FUNCTION_ARGS)
{ {
AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0); AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1); AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION(); Oid collation = PG_GET_COLLATION();
bool result; bool result;
...@@ -4296,8 +4296,8 @@ arraycontains(PG_FUNCTION_ARGS) ...@@ -4296,8 +4296,8 @@ arraycontains(PG_FUNCTION_ARGS)
Datum Datum
arraycontained(PG_FUNCTION_ARGS) arraycontained(PG_FUNCTION_ARGS)
{ {
AnyArrayType *array1 = PG_GETARG_ANY_ARRAY(0); AnyArrayType *array1 = PG_GETARG_ANY_ARRAY_P(0);
AnyArrayType *array2 = PG_GETARG_ANY_ARRAY(1); AnyArrayType *array2 = PG_GETARG_ANY_ARRAY_P(1);
Oid collation = PG_GET_COLLATION(); Oid collation = PG_GET_COLLATION();
bool result; bool result;
...@@ -5634,7 +5634,7 @@ generate_subscripts(PG_FUNCTION_ARGS) ...@@ -5634,7 +5634,7 @@ generate_subscripts(PG_FUNCTION_ARGS)
/* stuff done only on the first call of the function */ /* stuff done only on the first call of the function */
if (SRF_IS_FIRSTCALL()) 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 reqdim = PG_GETARG_INT32(1);
int *lb, int *lb,
*dimv; *dimv;
...@@ -5996,7 +5996,7 @@ array_unnest(PG_FUNCTION_ARGS) ...@@ -5996,7 +5996,7 @@ array_unnest(PG_FUNCTION_ARGS)
* and not before. (If no detoast happens, we assume the originally * and not before. (If no detoast happens, we assume the originally
* passed array will stick around till then.) * 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 */ /* allocate memory for user context */
fctx = (array_unnest_fctx *) palloc(sizeof(array_unnest_fctx)); fctx = (array_unnest_fctx *) palloc(sizeof(array_unnest_fctx));
......
...@@ -130,7 +130,7 @@ jsonb_recv(PG_FUNCTION_ARGS) ...@@ -130,7 +130,7 @@ jsonb_recv(PG_FUNCTION_ARGS)
Datum Datum
jsonb_out(PG_FUNCTION_ARGS) jsonb_out(PG_FUNCTION_ARGS)
{ {
Jsonb *jb = PG_GETARG_JSONB(0); Jsonb *jb = PG_GETARG_JSONB_P(0);
char *out; char *out;
out = JsonbToCString(NULL, &jb->root, VARSIZE(jb)); out = JsonbToCString(NULL, &jb->root, VARSIZE(jb));
...@@ -146,7 +146,7 @@ jsonb_out(PG_FUNCTION_ARGS) ...@@ -146,7 +146,7 @@ jsonb_out(PG_FUNCTION_ARGS)
Datum Datum
jsonb_send(PG_FUNCTION_ARGS) jsonb_send(PG_FUNCTION_ARGS)
{ {
Jsonb *jb = PG_GETARG_JSONB(0); Jsonb *jb = PG_GETARG_JSONB_P(0);
StringInfoData buf; StringInfoData buf;
StringInfo jtext = makeStringInfo(); StringInfo jtext = makeStringInfo();
int version = 1; int version = 1;
...@@ -171,7 +171,7 @@ jsonb_send(PG_FUNCTION_ARGS) ...@@ -171,7 +171,7 @@ jsonb_send(PG_FUNCTION_ARGS)
Datum Datum
jsonb_typeof(PG_FUNCTION_ARGS) jsonb_typeof(PG_FUNCTION_ARGS)
{ {
Jsonb *in = PG_GETARG_JSONB(0); Jsonb *in = PG_GETARG_JSONB_P(0);
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
char *result; char *result;
...@@ -878,7 +878,7 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result, ...@@ -878,7 +878,7 @@ datum_to_jsonb(Datum val, bool is_null, JsonbInState *result,
break; break;
case JSONBTYPE_JSONB: case JSONBTYPE_JSONB:
{ {
Jsonb *jsonb = DatumGetJsonb(val); Jsonb *jsonb = DatumGetJsonbP(val);
JsonbIterator *it; JsonbIterator *it;
it = JsonbIteratorInit(&jsonb->root); it = JsonbIteratorInit(&jsonb->root);
......
...@@ -66,7 +66,7 @@ gin_compare_jsonb(PG_FUNCTION_ARGS) ...@@ -66,7 +66,7 @@ gin_compare_jsonb(PG_FUNCTION_ARGS)
Datum Datum
gin_extract_jsonb(PG_FUNCTION_ARGS) 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); int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
int total = 2 * JB_ROOT_COUNT(jb); int total = 2 * JB_ROOT_COUNT(jb);
JsonbIterator *it; JsonbIterator *it;
...@@ -196,7 +196,7 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS) ...@@ -196,7 +196,7 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS)
bool *check = (bool *) PG_GETARG_POINTER(0); bool *check = (bool *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1); 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); int32 nkeys = PG_GETARG_INT32(3);
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
...@@ -268,7 +268,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS) ...@@ -268,7 +268,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0); GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1); 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); int32 nkeys = PG_GETARG_INT32(3);
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
...@@ -329,7 +329,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS) ...@@ -329,7 +329,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
Datum Datum
gin_extract_jsonb_path(PG_FUNCTION_ARGS) 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); int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
int total = 2 * JB_ROOT_COUNT(jb); int total = 2 * JB_ROOT_COUNT(jb);
JsonbIterator *it; JsonbIterator *it;
...@@ -454,7 +454,7 @@ gin_consistent_jsonb_path(PG_FUNCTION_ARGS) ...@@ -454,7 +454,7 @@ gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
bool *check = (bool *) PG_GETARG_POINTER(0); bool *check = (bool *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1); 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); int32 nkeys = PG_GETARG_INT32(3);
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
...@@ -492,7 +492,7 @@ gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS) ...@@ -492,7 +492,7 @@ gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0); GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1); 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); int32 nkeys = PG_GETARG_INT32(3);
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
Datum Datum
jsonb_exists(PG_FUNCTION_ARGS) 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); text *key = PG_GETARG_TEXT_PP(1);
JsonbValue kval; JsonbValue kval;
JsonbValue *v = NULL; JsonbValue *v = NULL;
...@@ -46,7 +46,7 @@ jsonb_exists(PG_FUNCTION_ARGS) ...@@ -46,7 +46,7 @@ jsonb_exists(PG_FUNCTION_ARGS)
Datum Datum
jsonb_exists_any(PG_FUNCTION_ARGS) 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); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
int i; int i;
Datum *key_datums; Datum *key_datums;
...@@ -79,7 +79,7 @@ jsonb_exists_any(PG_FUNCTION_ARGS) ...@@ -79,7 +79,7 @@ jsonb_exists_any(PG_FUNCTION_ARGS)
Datum Datum
jsonb_exists_all(PG_FUNCTION_ARGS) 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); ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
int i; int i;
Datum *key_datums; Datum *key_datums;
...@@ -112,8 +112,8 @@ jsonb_exists_all(PG_FUNCTION_ARGS) ...@@ -112,8 +112,8 @@ jsonb_exists_all(PG_FUNCTION_ARGS)
Datum Datum
jsonb_contains(PG_FUNCTION_ARGS) jsonb_contains(PG_FUNCTION_ARGS)
{ {
Jsonb *val = PG_GETARG_JSONB(0); Jsonb *val = PG_GETARG_JSONB_P(0);
Jsonb *tmpl = PG_GETARG_JSONB(1); Jsonb *tmpl = PG_GETARG_JSONB_P(1);
JsonbIterator *it1, JsonbIterator *it1,
*it2; *it2;
...@@ -131,8 +131,8 @@ Datum ...@@ -131,8 +131,8 @@ Datum
jsonb_contained(PG_FUNCTION_ARGS) jsonb_contained(PG_FUNCTION_ARGS)
{ {
/* Commutator of "contains" */ /* Commutator of "contains" */
Jsonb *tmpl = PG_GETARG_JSONB(0); Jsonb *tmpl = PG_GETARG_JSONB_P(0);
Jsonb *val = PG_GETARG_JSONB(1); Jsonb *val = PG_GETARG_JSONB_P(1);
JsonbIterator *it1, JsonbIterator *it1,
*it2; *it2;
...@@ -149,8 +149,8 @@ jsonb_contained(PG_FUNCTION_ARGS) ...@@ -149,8 +149,8 @@ jsonb_contained(PG_FUNCTION_ARGS)
Datum Datum
jsonb_ne(PG_FUNCTION_ARGS) jsonb_ne(PG_FUNCTION_ARGS)
{ {
Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB(1); Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res; bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) != 0); res = (compareJsonbContainers(&jba->root, &jbb->root) != 0);
...@@ -166,8 +166,8 @@ jsonb_ne(PG_FUNCTION_ARGS) ...@@ -166,8 +166,8 @@ jsonb_ne(PG_FUNCTION_ARGS)
Datum Datum
jsonb_lt(PG_FUNCTION_ARGS) jsonb_lt(PG_FUNCTION_ARGS)
{ {
Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB(1); Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res; bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) < 0); res = (compareJsonbContainers(&jba->root, &jbb->root) < 0);
...@@ -180,8 +180,8 @@ jsonb_lt(PG_FUNCTION_ARGS) ...@@ -180,8 +180,8 @@ jsonb_lt(PG_FUNCTION_ARGS)
Datum Datum
jsonb_gt(PG_FUNCTION_ARGS) jsonb_gt(PG_FUNCTION_ARGS)
{ {
Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB(1); Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res; bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) > 0); res = (compareJsonbContainers(&jba->root, &jbb->root) > 0);
...@@ -194,8 +194,8 @@ jsonb_gt(PG_FUNCTION_ARGS) ...@@ -194,8 +194,8 @@ jsonb_gt(PG_FUNCTION_ARGS)
Datum Datum
jsonb_le(PG_FUNCTION_ARGS) jsonb_le(PG_FUNCTION_ARGS)
{ {
Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB(1); Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res; bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) <= 0); res = (compareJsonbContainers(&jba->root, &jbb->root) <= 0);
...@@ -208,8 +208,8 @@ jsonb_le(PG_FUNCTION_ARGS) ...@@ -208,8 +208,8 @@ jsonb_le(PG_FUNCTION_ARGS)
Datum Datum
jsonb_ge(PG_FUNCTION_ARGS) jsonb_ge(PG_FUNCTION_ARGS)
{ {
Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB(1); Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res; bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) >= 0); res = (compareJsonbContainers(&jba->root, &jbb->root) >= 0);
...@@ -222,8 +222,8 @@ jsonb_ge(PG_FUNCTION_ARGS) ...@@ -222,8 +222,8 @@ jsonb_ge(PG_FUNCTION_ARGS)
Datum Datum
jsonb_eq(PG_FUNCTION_ARGS) jsonb_eq(PG_FUNCTION_ARGS)
{ {
Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB(1); Jsonb *jbb = PG_GETARG_JSONB_P(1);
bool res; bool res;
res = (compareJsonbContainers(&jba->root, &jbb->root) == 0); res = (compareJsonbContainers(&jba->root, &jbb->root) == 0);
...@@ -236,8 +236,8 @@ jsonb_eq(PG_FUNCTION_ARGS) ...@@ -236,8 +236,8 @@ jsonb_eq(PG_FUNCTION_ARGS)
Datum Datum
jsonb_cmp(PG_FUNCTION_ARGS) jsonb_cmp(PG_FUNCTION_ARGS)
{ {
Jsonb *jba = PG_GETARG_JSONB(0); Jsonb *jba = PG_GETARG_JSONB_P(0);
Jsonb *jbb = PG_GETARG_JSONB(1); Jsonb *jbb = PG_GETARG_JSONB_P(1);
int res; int res;
res = compareJsonbContainers(&jba->root, &jbb->root); res = compareJsonbContainers(&jba->root, &jbb->root);
...@@ -253,7 +253,7 @@ jsonb_cmp(PG_FUNCTION_ARGS) ...@@ -253,7 +253,7 @@ jsonb_cmp(PG_FUNCTION_ARGS)
Datum Datum
jsonb_hash(PG_FUNCTION_ARGS) jsonb_hash(PG_FUNCTION_ARGS)
{ {
Jsonb *jb = PG_GETARG_JSONB(0); Jsonb *jb = PG_GETARG_JSONB_P(0);
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
JsonbIteratorToken r; JsonbIteratorToken r;
...@@ -295,7 +295,7 @@ jsonb_hash(PG_FUNCTION_ARGS) ...@@ -295,7 +295,7 @@ jsonb_hash(PG_FUNCTION_ARGS)
Datum Datum
jsonb_hash_extended(PG_FUNCTION_ARGS) 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); uint64 seed = PG_GETARG_INT64(1);
JsonbIterator *it; JsonbIterator *it;
JsonbValue v; JsonbValue v;
...@@ -311,7 +311,7 @@ jsonb_hash_extended(PG_FUNCTION_ARGS) ...@@ -311,7 +311,7 @@ jsonb_hash_extended(PG_FUNCTION_ARGS)
{ {
switch (r) switch (r)
{ {
/* Rotation is left to JsonbHashScalarValueExtended() */ /* Rotation is left to JsonbHashScalarValueExtended() */
case WJB_BEGIN_ARRAY: case WJB_BEGIN_ARRAY:
hash ^= ((uint64) JB_FARRAY) << 32 | JB_FARRAY; hash ^= ((uint64) JB_FARRAY) << 32 | JB_FARRAY;
break; break;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -203,7 +203,7 @@ rangesel(PG_FUNCTION_ARGS) ...@@ -203,7 +203,7 @@ rangesel(PG_FUNCTION_ARGS)
/* Both sides are the same range type */ /* Both sides are the same range type */
typcache = range_get_typcache(fcinfo, vardata.vartype); 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, ...@@ -406,7 +406,7 @@ calc_hist_selectivity(TypeCacheEntry *typcache, VariableStatData *vardata,
hist_upper = (RangeBound *) palloc(sizeof(RangeBound) * nhist); hist_upper = (RangeBound *) palloc(sizeof(RangeBound) * nhist);
for (i = 0; i < nhist; i++) 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); &hist_lower[i], &hist_upper[i], &empty);
/* The histogram should not contain any empty ranges */ /* The histogram should not contain any empty ranges */
if (empty) if (empty)
......
...@@ -132,7 +132,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) ...@@ -132,7 +132,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS)
{ {
spgChooseIn *in = (spgChooseIn *) PG_GETARG_POINTER(0); spgChooseIn *in = (spgChooseIn *) PG_GETARG_POINTER(0);
spgChooseOut *out = (spgChooseOut *) PG_GETARG_POINTER(1); spgChooseOut *out = (spgChooseOut *) PG_GETARG_POINTER(1);
RangeType *inRange = DatumGetRangeType(in->datum), RangeType *inRange = DatumGetRangeTypeP(in->datum),
*centroid; *centroid;
int16 quadrant; int16 quadrant;
TypeCacheEntry *typcache; TypeCacheEntry *typcache;
...@@ -142,7 +142,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) ...@@ -142,7 +142,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS)
out->resultType = spgMatchNode; out->resultType = spgMatchNode;
/* nodeN will be set by core */ /* nodeN will be set by core */
out->result.matchNode.levelAdd = 0; out->result.matchNode.levelAdd = 0;
out->result.matchNode.restDatum = RangeTypeGetDatum(inRange); out->result.matchNode.restDatum = RangeTypePGetDatum(inRange);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
...@@ -161,11 +161,11 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) ...@@ -161,11 +161,11 @@ spg_range_quad_choose(PG_FUNCTION_ARGS)
else else
out->result.matchNode.nodeN = 1; out->result.matchNode.nodeN = 1;
out->result.matchNode.levelAdd = 1; out->result.matchNode.levelAdd = 1;
out->result.matchNode.restDatum = RangeTypeGetDatum(inRange); out->result.matchNode.restDatum = RangeTypePGetDatum(inRange);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
centroid = DatumGetRangeType(in->prefixDatum); centroid = DatumGetRangeTypeP(in->prefixDatum);
quadrant = getQuadrant(typcache, centroid, inRange); quadrant = getQuadrant(typcache, centroid, inRange);
Assert(quadrant <= in->nNodes); Assert(quadrant <= in->nNodes);
...@@ -174,7 +174,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS) ...@@ -174,7 +174,7 @@ spg_range_quad_choose(PG_FUNCTION_ARGS)
out->resultType = spgMatchNode; out->resultType = spgMatchNode;
out->result.matchNode.nodeN = quadrant - 1; out->result.matchNode.nodeN = quadrant - 1;
out->result.matchNode.levelAdd = 1; out->result.matchNode.levelAdd = 1;
out->result.matchNode.restDatum = RangeTypeGetDatum(inRange); out->result.matchNode.restDatum = RangeTypePGetDatum(inRange);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
...@@ -213,7 +213,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) ...@@ -213,7 +213,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS)
*upperBounds; *upperBounds;
typcache = range_get_typcache(fcinfo, typcache = range_get_typcache(fcinfo,
RangeTypeGetOid(DatumGetRangeType(in->datums[0]))); RangeTypeGetOid(DatumGetRangeTypeP(in->datums[0])));
/* Allocate memory for bounds */ /* Allocate memory for bounds */
lowerBounds = palloc(sizeof(RangeBound) * in->nTuples); lowerBounds = palloc(sizeof(RangeBound) * in->nTuples);
...@@ -223,7 +223,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) ...@@ -223,7 +223,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS)
/* Deserialize bounds of ranges, count non-empty ranges */ /* Deserialize bounds of ranges, count non-empty ranges */
for (i = 0; i < in->nTuples; i++) 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); &lowerBounds[j], &upperBounds[j], &empty);
if (!empty) if (!empty)
j++; j++;
...@@ -249,9 +249,9 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) ...@@ -249,9 +249,9 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS)
/* Place all ranges into node 0 */ /* Place all ranges into node 0 */
for (i = 0; i < in->nTuples; i++) 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; out->mapTuplesToNodes[i] = 0;
} }
PG_RETURN_VOID(); PG_RETURN_VOID();
...@@ -267,7 +267,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) ...@@ -267,7 +267,7 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS)
centroid = range_serialize(typcache, &lowerBounds[nonEmptyCount / 2], centroid = range_serialize(typcache, &lowerBounds[nonEmptyCount / 2],
&upperBounds[nonEmptyCount / 2], false); &upperBounds[nonEmptyCount / 2], false);
out->hasPrefix = true; out->hasPrefix = true;
out->prefixDatum = RangeTypeGetDatum(centroid); out->prefixDatum = RangeTypePGetDatum(centroid);
/* Create node for empty ranges only if it is a root node */ /* Create node for empty ranges only if it is a root node */
out->nNodes = (in->level == 0) ? 5 : 4; out->nNodes = (in->level == 0) ? 5 : 4;
...@@ -282,10 +282,10 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS) ...@@ -282,10 +282,10 @@ spg_range_quad_picksplit(PG_FUNCTION_ARGS)
*/ */
for (i = 0; i < in->nTuples; i++) 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); int16 quadrant = getQuadrant(typcache, centroid, range);
out->leafTupleDatums[i] = RangeTypeGetDatum(range); out->leafTupleDatums[i] = RangeTypePGetDatum(range);
out->mapTuplesToNodes[i] = quadrant - 1; out->mapTuplesToNodes[i] = quadrant - 1;
} }
...@@ -347,7 +347,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) ...@@ -347,7 +347,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
*/ */
if (strategy != RANGESTRAT_CONTAINS_ELEM) if (strategy != RANGESTRAT_CONTAINS_ELEM)
empty = RangeIsEmpty( empty = RangeIsEmpty(
DatumGetRangeType(in->scankeys[i].sk_argument)); DatumGetRangeTypeP(in->scankeys[i].sk_argument));
else else
empty = false; empty = false;
...@@ -415,9 +415,9 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) ...@@ -415,9 +415,9 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
RangeType *centroid; RangeType *centroid;
/* This node has a centroid. Fetch it. */ /* This node has a centroid. Fetch it. */
centroid = DatumGetRangeType(in->prefixDatum); centroid = DatumGetRangeTypeP(in->prefixDatum);
typcache = range_get_typcache(fcinfo, typcache = range_get_typcache(fcinfo,
RangeTypeGetOid(DatumGetRangeType(centroid))); RangeTypeGetOid(DatumGetRangeTypeP(centroid)));
range_deserialize(typcache, centroid, &centroidLower, &centroidUpper, range_deserialize(typcache, centroid, &centroidLower, &centroidUpper,
&centroidEmpty); &centroidEmpty);
...@@ -482,7 +482,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) ...@@ -482,7 +482,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
} }
else else
{ {
range = DatumGetRangeType(in->scankeys[i].sk_argument); range = DatumGetRangeTypeP(in->scankeys[i].sk_argument);
range_deserialize(typcache, range, &lower, &upper, &empty); range_deserialize(typcache, range, &lower, &upper, &empty);
} }
...@@ -558,7 +558,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS) ...@@ -558,7 +558,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
*/ */
if (in->traversalValue != (Datum) 0) if (in->traversalValue != (Datum) 0)
{ {
prevCentroid = DatumGetRangeType(in->traversalValue); prevCentroid = DatumGetRangeTypeP(in->traversalValue);
range_deserialize(typcache, prevCentroid, range_deserialize(typcache, prevCentroid,
&prevLower, &prevUpper, &prevEmpty); &prevLower, &prevUpper, &prevEmpty);
} }
...@@ -921,7 +921,7 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS) ...@@ -921,7 +921,7 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS)
{ {
spgLeafConsistentIn *in = (spgLeafConsistentIn *) PG_GETARG_POINTER(0); spgLeafConsistentIn *in = (spgLeafConsistentIn *) PG_GETARG_POINTER(0);
spgLeafConsistentOut *out = (spgLeafConsistentOut *) PG_GETARG_POINTER(1); spgLeafConsistentOut *out = (spgLeafConsistentOut *) PG_GETARG_POINTER(1);
RangeType *leafRange = DatumGetRangeType(in->leafDatum); RangeType *leafRange = DatumGetRangeTypeP(in->leafDatum);
TypeCacheEntry *typcache; TypeCacheEntry *typcache;
bool res; bool res;
int i; int i;
...@@ -945,35 +945,35 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS) ...@@ -945,35 +945,35 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS)
{ {
case RANGESTRAT_BEFORE: case RANGESTRAT_BEFORE:
res = range_before_internal(typcache, leafRange, res = range_before_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_OVERLEFT: case RANGESTRAT_OVERLEFT:
res = range_overleft_internal(typcache, leafRange, res = range_overleft_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_OVERLAPS: case RANGESTRAT_OVERLAPS:
res = range_overlaps_internal(typcache, leafRange, res = range_overlaps_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_OVERRIGHT: case RANGESTRAT_OVERRIGHT:
res = range_overright_internal(typcache, leafRange, res = range_overright_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_AFTER: case RANGESTRAT_AFTER:
res = range_after_internal(typcache, leafRange, res = range_after_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_ADJACENT: case RANGESTRAT_ADJACENT:
res = range_adjacent_internal(typcache, leafRange, res = range_adjacent_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_CONTAINS: case RANGESTRAT_CONTAINS:
res = range_contains_internal(typcache, leafRange, res = range_contains_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_CONTAINED_BY: case RANGESTRAT_CONTAINED_BY:
res = range_contained_by_internal(typcache, leafRange, res = range_contained_by_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
case RANGESTRAT_CONTAINS_ELEM: case RANGESTRAT_CONTAINS_ELEM:
res = range_contains_elem_internal(typcache, leafRange, res = range_contains_elem_internal(typcache, leafRange,
...@@ -981,7 +981,7 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS) ...@@ -981,7 +981,7 @@ spg_range_quad_leaf_consistent(PG_FUNCTION_ARGS)
break; break;
case RANGESTRAT_EQ: case RANGESTRAT_EQ:
res = range_eq_internal(typcache, leafRange, res = range_eq_internal(typcache, leafRange,
DatumGetRangeType(keyDatum)); DatumGetRangeTypeP(keyDatum));
break; break;
default: default:
elog(ERROR, "unrecognized range strategy: %d", elog(ERROR, "unrecognized range strategy: %d",
......
...@@ -144,7 +144,7 @@ compute_range_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, ...@@ -144,7 +144,7 @@ compute_range_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
total_width += VARSIZE_ANY(DatumGetPointer(value)); total_width += VARSIZE_ANY(DatumGetPointer(value));
/* Get range and deserialize it for further analysis. */ /* Get range and deserialize it for further analysis. */
range = DatumGetRangeType(value); range = DatumGetRangeTypeP(value);
range_deserialize(typcache, range, &lower, &upper, &empty); range_deserialize(typcache, range, &lower, &upper, &empty);
if (!empty) if (!empty)
......
...@@ -110,7 +110,7 @@ static int outbuf_maxlen = 0; ...@@ -110,7 +110,7 @@ static int outbuf_maxlen = 0;
Datum Datum
gtsvectorout(PG_FUNCTION_ARGS) 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; char *outbuf;
if (outbuf_maxlen == 0) if (outbuf_maxlen == 0)
...@@ -273,7 +273,7 @@ Datum ...@@ -273,7 +273,7 @@ Datum
gtsvector_decompress(PG_FUNCTION_ARGS) gtsvector_decompress(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); 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)) if (key != (SignTSVector *) DatumGetPointer(entry->key))
{ {
......
...@@ -252,7 +252,7 @@ typedef struct ArrayIteratorData *ArrayIterator; ...@@ -252,7 +252,7 @@ typedef struct ArrayIteratorData *ArrayIterator;
#define PG_RETURN_EXPANDED_ARRAY(x) PG_RETURN_DATUM(EOHPGetRWDatum(&(x)->hdr)) #define PG_RETURN_EXPANDED_ARRAY(x) PG_RETURN_DATUM(EOHPGetRWDatum(&(x)->hdr))
/* fmgr macros for AnyArrayType (ie, get either varlena or expanded form) */ /* 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. * Access macros for varlena array header fields.
...@@ -440,7 +440,7 @@ extern Datum expand_array(Datum arraydatum, MemoryContext parentcontext, ...@@ -440,7 +440,7 @@ extern Datum expand_array(Datum arraydatum, MemoryContext parentcontext,
extern ExpandedArrayHeader *DatumGetExpandedArray(Datum d); extern ExpandedArrayHeader *DatumGetExpandedArray(Datum d);
extern ExpandedArrayHeader *DatumGetExpandedArrayX(Datum d, extern ExpandedArrayHeader *DatumGetExpandedArrayX(Datum d,
ArrayMetaState *metacache); ArrayMetaState *metacache);
extern AnyArrayType *DatumGetAnyArray(Datum d); extern AnyArrayType *DatumGetAnyArrayP(Datum d);
extern void deconstruct_expanded_array(ExpandedArrayHeader *eah); extern void deconstruct_expanded_array(ExpandedArrayHeader *eah);
#endif /* ARRAY_H */ #endif /* ARRAY_H */
...@@ -65,10 +65,10 @@ typedef enum ...@@ -65,10 +65,10 @@ typedef enum
#define JGIN_MAXLENGTH 125 /* max length of text part before hashing */ #define JGIN_MAXLENGTH 125 /* max length of text part before hashing */
/* Convenience macros */ /* Convenience macros */
#define DatumGetJsonb(d) ((Jsonb *) PG_DETOAST_DATUM(d)) #define DatumGetJsonbP(d) ((Jsonb *) PG_DETOAST_DATUM(d))
#define JsonbGetDatum(p) PointerGetDatum(p) #define JsonbPGetDatum(p) PointerGetDatum(p)
#define PG_GETARG_JSONB(x) DatumGetJsonb(PG_GETARG_DATUM(x)) #define PG_GETARG_JSONB_P(x) DatumGetJsonbP(PG_GETARG_DATUM(x))
#define PG_RETURN_JSONB(x) PG_RETURN_POINTER(x) #define PG_RETURN_JSONB_P(x) PG_RETURN_POINTER(x)
typedef struct JsonbPair JsonbPair; typedef struct JsonbPair JsonbPair;
typedef struct JsonbValue JsonbValue; typedef struct JsonbValue JsonbValue;
......
...@@ -68,12 +68,12 @@ typedef struct ...@@ -68,12 +68,12 @@ typedef struct
/* /*
* fmgr macros for range type objects * fmgr macros for range type objects
*/ */
#define DatumGetRangeType(X) ((RangeType *) PG_DETOAST_DATUM(X)) #define DatumGetRangeTypeP(X) ((RangeType *) PG_DETOAST_DATUM(X))
#define DatumGetRangeTypeCopy(X) ((RangeType *) PG_DETOAST_DATUM_COPY(X)) #define DatumGetRangeTypePCopy(X) ((RangeType *) PG_DETOAST_DATUM_COPY(X))
#define RangeTypeGetDatum(X) PointerGetDatum(X) #define RangeTypePGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_RANGE(n) DatumGetRangeType(PG_GETARG_DATUM(n)) #define PG_GETARG_RANGE_P(n) DatumGetRangeTypeP(PG_GETARG_DATUM(n))
#define PG_GETARG_RANGE_COPY(n) DatumGetRangeTypeCopy(PG_GETARG_DATUM(n)) #define PG_GETARG_RANGE_P_COPY(n) DatumGetRangeTypePCopy(PG_GETARG_DATUM(n))
#define PG_RETURN_RANGE(x) return RangeTypeGetDatum(x) #define PG_RETURN_RANGE_P(x) return RangeTypePGetDatum(x)
/* Operator strategy numbers used in the GiST and SP-GiST range opclasses */ /* Operator strategy numbers used in the GiST and SP-GiST range opclasses */
/* Numbers are chosen to match up operator names with existing usages */ /* Numbers are chosen to match up operator names with existing usages */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment