gbt_bpchar_consistent(PG_FUNCTION_ARGS)
{
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);
/* Oid subtype = PG_GETARG_OID(3); */
gbt_var_decompress(PG_FUNCTION_ARGS)
{
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))
{
l--;
i++;
}
- return ml; /* lower == upper */
+ return ml; /* lower == upper */
}
gbt_var_fetch(PG_FUNCTION_ARGS)
{
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);
GISTENTRY *retval;
cube_scanner_finish();
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
else
SET_POINT_BIT(result);
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
/*
for (i = 0; i < dim; i++)
result->x[i] = dur[i];
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
Datum
cube_subset(PG_FUNCTION_ARGS)
{
- NDBOX *c = PG_GETARG_NDBOX(0);
+ NDBOX *c = PG_GETARG_NDBOX_P(0);
ArrayType *idx = PG_GETARG_ARRAYTYPE_P(1);
NDBOX *result;
int size,
}
PG_FREE_IF_COPY(c, 0);
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
Datum
cube_out(PG_FUNCTION_ARGS)
{
- NDBOX *cube = PG_GETARG_NDBOX(0);
+ NDBOX *cube = PG_GETARG_NDBOX_P(0);
StringInfoData buf;
int dim = DIM(cube);
int i;
g_cube_consistent(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
- NDBOX *query = PG_GETARG_NDBOX(1);
+ NDBOX *query = PG_GETARG_NDBOX_P(1);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/* Oid subtype = PG_GETARG_OID(3); */
* g_cube_leaf_consistent
*/
if (GIST_LEAF(entry))
- res = g_cube_leaf_consistent(DatumGetNDBOX(entry->key),
+ res = g_cube_leaf_consistent(DatumGetNDBOXP(entry->key),
query, strategy);
else
- res = g_cube_internal_consistent(DatumGetNDBOX(entry->key),
+ res = g_cube_internal_consistent(DatumGetNDBOXP(entry->key),
query, strategy);
PG_FREE_IF_COPY(query, 1);
NDBOX *tmp;
int i;
- tmp = DatumGetNDBOX(entryvec->vector[0].key);
+ tmp = DatumGetNDBOXP(entryvec->vector[0].key);
/*
* sizep = sizeof(NDBOX); -- NDBOX has variable size
for (i = 1; i < entryvec->n; i++)
{
out = g_cube_binary_union(tmp,
- DatumGetNDBOX(entryvec->vector[i].key),
+ DatumGetNDBOXP(entryvec->vector[i].key),
sizep);
tmp = out;
}
g_cube_decompress(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
- NDBOX *key = DatumGetNDBOX(PG_DETOAST_DATUM(entry->key));
+ NDBOX *key = DatumGetNDBOXP(entry->key);
- if (key != DatumGetNDBOX(entry->key))
+ if (key != DatumGetNDBOXP(entry->key))
{
GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
double tmp1,
tmp2;
- ud = cube_union_v0(DatumGetNDBOX(origentry->key),
- DatumGetNDBOX(newentry->key));
+ ud = cube_union_v0(DatumGetNDBOXP(origentry->key),
+ DatumGetNDBOXP(newentry->key));
rt_cube_size(ud, &tmp1);
- rt_cube_size(DatumGetNDBOX(origentry->key), &tmp2);
+ rt_cube_size(DatumGetNDBOXP(origentry->key), &tmp2);
*result = (float) (tmp1 - tmp2);
PG_RETURN_FLOAT8(*result);
for (i = FirstOffsetNumber; i < maxoff; i = OffsetNumberNext(i))
{
- datum_alpha = DatumGetNDBOX(entryvec->vector[i].key);
+ datum_alpha = DatumGetNDBOXP(entryvec->vector[i].key);
for (j = OffsetNumberNext(i); j <= maxoff; j = OffsetNumberNext(j))
{
- datum_beta = DatumGetNDBOX(entryvec->vector[j].key);
+ datum_beta = DatumGetNDBOXP(entryvec->vector[j].key);
/* compute the wasted space by unioning these guys */
/* size_waste = size_union - size_inter; */
union_d = cube_union_v0(datum_alpha, datum_beta);
rt_cube_size(union_d, &size_union);
- inter_d = DatumGetNDBOX(DirectFunctionCall2(cube_inter,
- entryvec->vector[i].key, entryvec->vector[j].key));
+ inter_d = DatumGetNDBOXP(DirectFunctionCall2(cube_inter,
+ entryvec->vector[i].key,
+ entryvec->vector[j].key));
rt_cube_size(inter_d, &size_inter);
size_waste = size_union - size_inter;
right = v->spl_right;
v->spl_nright = 0;
- datum_alpha = DatumGetNDBOX(entryvec->vector[seed_1].key);
+ datum_alpha = DatumGetNDBOXP(entryvec->vector[seed_1].key);
datum_l = cube_union_v0(datum_alpha, datum_alpha);
rt_cube_size(datum_l, &size_l);
- datum_beta = DatumGetNDBOX(entryvec->vector[seed_2].key);
+ datum_beta = DatumGetNDBOXP(entryvec->vector[seed_2].key);
datum_r = cube_union_v0(datum_beta, datum_beta);
rt_cube_size(datum_r, &size_r);
}
/* okay, which page needs least enlargement? */
- datum_alpha = DatumGetNDBOX(entryvec->vector[i].key);
+ datum_alpha = DatumGetNDBOXP(entryvec->vector[i].key);
union_dl = cube_union_v0(datum_l, datum_alpha);
union_dr = cube_union_v0(datum_r, datum_alpha);
rt_cube_size(union_dl, &size_alpha);
Datum
g_cube_same(PG_FUNCTION_ARGS)
{
- NDBOX *b1 = PG_GETARG_NDBOX(0);
- NDBOX *b2 = PG_GETARG_NDBOX(1);
+ NDBOX *b1 = PG_GETARG_NDBOX_P(0);
+ NDBOX *b2 = PG_GETARG_NDBOX_P(1);
bool *result = (bool *) PG_GETARG_POINTER(2);
if (cube_cmp_v0(b1, b2) == 0)
else
*result = FALSE;
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
/*
Datum
cube_union(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0);
- NDBOX *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0);
+ NDBOX *b = PG_GETARG_NDBOX_P(1);
NDBOX *res;
res = cube_union_v0(a, b);
PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1);
- PG_RETURN_NDBOX(res);
+ PG_RETURN_NDBOX_P(res);
}
/* cube_inter */
Datum
cube_inter(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0);
- NDBOX *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0);
+ NDBOX *b = PG_GETARG_NDBOX_P(1);
NDBOX *result;
bool swapped = false;
int i;
/*
* Is it OK to return a non-null intersection for non-overlapping boxes?
*/
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
/* cube_size */
Datum
cube_size(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0);
+ NDBOX *a = PG_GETARG_NDBOX_P(0);
double result;
rt_cube_size(a, &result);
Datum
cube_cmp(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
int32 res;
res = cube_cmp_v0(a, b);
Datum
cube_eq(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
int32 res;
res = cube_cmp_v0(a, b);
Datum
cube_ne(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
int32 res;
res = cube_cmp_v0(a, b);
Datum
cube_lt(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
int32 res;
res = cube_cmp_v0(a, b);
Datum
cube_gt(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
int32 res;
res = cube_cmp_v0(a, b);
Datum
cube_le(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
int32 res;
res = cube_cmp_v0(a, b);
Datum
cube_ge(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
int32 res;
res = cube_cmp_v0(a, b);
Datum
cube_contains(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
bool res;
res = cube_contains_v0(a, b);
Datum
cube_contained(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
bool res;
res = cube_contains_v0(b, a);
Datum
cube_overlap(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
bool res;
res = cube_overlap_v0(a, b);
Datum
cube_distance(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
bool swapped = false;
double d,
distance;
Datum
distance_taxicab(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
bool swapped = false;
double distance;
int i;
Datum
distance_chebyshev(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0),
- *b = PG_GETARG_NDBOX(1);
+ NDBOX *a = PG_GETARG_NDBOX_P(0),
+ *b = PG_GETARG_NDBOX_P(1);
bool swapped = false;
double d,
distance;
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
- NDBOX *cube = DatumGetNDBOX(entry->key);
+ NDBOX *cube = DatumGetNDBOXP(entry->key);
double retval;
if (strategy == CubeKNNDistanceCoord)
}
else
{
- NDBOX *query = PG_GETARG_NDBOX(1);
+ NDBOX *query = PG_GETARG_NDBOX_P(1);
switch (strategy)
{
Datum
cube_is_point(PG_FUNCTION_ARGS)
{
- NDBOX *cube = PG_GETARG_NDBOX(0);
+ NDBOX *cube = PG_GETARG_NDBOX_P(0);
bool result;
result = cube_is_point_internal(cube);
Datum
cube_dim(PG_FUNCTION_ARGS)
{
- NDBOX *c = PG_GETARG_NDBOX(0);
+ NDBOX *c = PG_GETARG_NDBOX_P(0);
int dim = DIM(c);
PG_FREE_IF_COPY(c, 0);
Datum
cube_ll_coord(PG_FUNCTION_ARGS)
{
- NDBOX *c = PG_GETARG_NDBOX(0);
+ NDBOX *c = PG_GETARG_NDBOX_P(0);
int n = PG_GETARG_INT32(1);
double result;
Datum
cube_ur_coord(PG_FUNCTION_ARGS)
{
- NDBOX *c = PG_GETARG_NDBOX(0);
+ NDBOX *c = PG_GETARG_NDBOX_P(0);
int n = PG_GETARG_INT32(1);
double result;
Datum
cube_coord(PG_FUNCTION_ARGS)
{
- NDBOX *cube = PG_GETARG_NDBOX(0);
+ NDBOX *cube = PG_GETARG_NDBOX_P(0);
int coord = PG_GETARG_INT32(1);
if (coord <= 0 || coord > 2 * DIM(cube))
Datum
cube_coord_llur(PG_FUNCTION_ARGS)
{
- NDBOX *cube = PG_GETARG_NDBOX(0);
+ NDBOX *cube = PG_GETARG_NDBOX_P(0);
int coord = PG_GETARG_INT32(1);
if (coord <= 0 || coord > 2 * DIM(cube))
Datum
cube_enlarge(PG_FUNCTION_ARGS)
{
- NDBOX *a = PG_GETARG_NDBOX(0);
+ NDBOX *a = PG_GETARG_NDBOX_P(0);
double r = PG_GETARG_FLOAT8(1);
int32 n = PG_GETARG_INT32(2);
NDBOX *result;
}
PG_FREE_IF_COPY(a, 0);
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
/* Create a one dimensional box with identical upper and lower coordinates */
SET_POINT_BIT(result);
result->x[0] = x;
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
/* Create a one dimensional box */
result->x[1] = x1;
}
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
/* Add a dimension to an existing cube with the same values for the new
Datum
cube_c_f8(PG_FUNCTION_ARGS)
{
- NDBOX *cube = PG_GETARG_NDBOX(0);
+ NDBOX *cube = PG_GETARG_NDBOX_P(0);
double x = PG_GETARG_FLOAT8(1);
NDBOX *result;
int size;
}
PG_FREE_IF_COPY(cube, 0);
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
/* Add a dimension to an existing cube */
Datum
cube_c_f8_f8(PG_FUNCTION_ARGS)
{
- NDBOX *cube = PG_GETARG_NDBOX(0);
+ NDBOX *cube = PG_GETARG_NDBOX_P(0);
double x1 = PG_GETARG_FLOAT8(1);
double x2 = PG_GETARG_FLOAT8(2);
NDBOX *result;
}
PG_FREE_IF_COPY(cube, 0);
- PG_RETURN_NDBOX(result);
+ PG_RETURN_NDBOX_P(result);
}
#define CUBE_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2)
/* fmgr interface macros */
-#define DatumGetNDBOX(x) ((NDBOX *) PG_DETOAST_DATUM(x))
-#define PG_GETARG_NDBOX(x) DatumGetNDBOX(PG_GETARG_DATUM(x))
-#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x)
+#define DatumGetNDBOXP(x) ((NDBOX *) PG_DETOAST_DATUM(x))
+#define PG_GETARG_NDBOX_P(x) DatumGetNDBOXP(PG_GETARG_DATUM(x))
+#define PG_RETURN_NDBOX_P(x) PG_RETURN_POINTER(x)
/* GiST operator strategy numbers */
#define CubeKNNDistanceCoord 15 /* ~> */
#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))
/*
Datum
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);
Datum *entries = NULL;
HEntry *hsent = ARRPTR(hs);
bool *check = (bool *) PG_GETARG_POINTER(0);
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);
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
if (strategy == HStoreContainsStrategyNumber ||
strategy == HStoreOldContainsStrategyNumber)
{
- HStore *query = PG_GETARG_HS(1);
+ HStore *query = PG_GETARG_HSTORE_P(1);
HEntry *qe = ARRPTR(query);
char *qv = STRPTR(query);
int count = HS_COUNT(query);
tupTypmod = HeapTupleHeaderGetTypMod(rec);
}
- hs = PG_GETARG_HS(1);
+ hs = PG_GETARG_HSTORE_P(1);
entries = ARRPTR(hs);
ptr = STRPTR(hs);
Datum
hstore_out(PG_FUNCTION_ARGS)
{
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int buflen,
i;
int count = HS_COUNT(in);
Datum
hstore_send(PG_FUNCTION_ARGS)
{
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
Datum
hstore_to_json_loose(PG_FUNCTION_ARGS)
{
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
Datum
hstore_to_json(PG_FUNCTION_ARGS)
{
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
Datum
hstore_to_jsonb(PG_FUNCTION_ARGS)
{
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
Datum
hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
{
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
Datum
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);
HEntry *entries = ARRPTR(hs);
text *out;
Datum
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);
int idx = hstoreFindKey(hs, NULL,
VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key));
Datum
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);
int nkeys;
Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys);
Datum
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);
int nkeys;
Pairs *key_pairs = hstoreArrayToPairs(keys, &nkeys);
Datum
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);
HEntry *entries = ARRPTR(hs);
int idx = hstoreFindKey(hs, NULL,
Datum
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);
char *keyptr = VARDATA_ANY(key);
int keylen = VARSIZE_ANY_EXHDR(key);
Datum
hstore_delete_array(PG_FUNCTION_ARGS)
{
- HStore *hs = PG_GETARG_HS(0);
+ HStore *hs = PG_GETARG_HSTORE_P(0);
HStore *out = palloc(VARSIZE(hs));
int hs_count = HS_COUNT(hs);
char *ps,
Datum
hstore_delete_hstore(PG_FUNCTION_ARGS)
{
- HStore *hs = PG_GETARG_HS(0);
- HStore *hs2 = PG_GETARG_HS(1);
+ HStore *hs = PG_GETARG_HSTORE_P(0);
+ HStore *hs2 = PG_GETARG_HSTORE_P(1);
HStore *out = palloc(VARSIZE(hs));
int hs_count = HS_COUNT(hs);
int hs2_count = HS_COUNT(hs2);
Datum
hstore_concat(PG_FUNCTION_ARGS)
{
- HStore *s1 = PG_GETARG_HS(0);
- HStore *s2 = PG_GETARG_HS(1);
+ HStore *s1 = PG_GETARG_HSTORE_P(0);
+ HStore *s2 = PG_GETARG_HSTORE_P(1);
HStore *out = palloc(VARSIZE(s1) + VARSIZE(s2));
char *ps1,
*ps2,
Datum
hstore_slice_to_array(PG_FUNCTION_ARGS)
{
- HStore *hs = PG_GETARG_HS(0);
+ HStore *hs = PG_GETARG_HSTORE_P(0);
HEntry *entries = ARRPTR(hs);
char *ptr = STRPTR(hs);
ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1);
Datum
hstore_slice_to_hstore(PG_FUNCTION_ARGS)
{
- HStore *hs = PG_GETARG_HS(0);
+ HStore *hs = PG_GETARG_HSTORE_P(0);
HEntry *entries = ARRPTR(hs);
char *ptr = STRPTR(hs);
ArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1);
Datum
hstore_akeys(PG_FUNCTION_ARGS)
{
- HStore *hs = PG_GETARG_HS(0);
+ HStore *hs = PG_GETARG_HSTORE_P(0);
Datum *d;
ArrayType *a;
HEntry *entries = ARRPTR(hs);
Datum
hstore_avals(PG_FUNCTION_ARGS)
{
- HStore *hs = PG_GETARG_HS(0);
+ HStore *hs = PG_GETARG_HSTORE_P(0);
Datum *d;
bool *nulls;
ArrayType *a;
Datum
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);
PG_RETURN_POINTER(out);
Datum
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);
PG_RETURN_POINTER(out);
if (SRF_IS_FIRSTCALL())
{
- hs = PG_GETARG_HS(0);
+ hs = PG_GETARG_HSTORE_P(0);
funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, NULL);
}
if (SRF_IS_FIRSTCALL())
{
- hs = PG_GETARG_HS(0);
+ hs = PG_GETARG_HSTORE_P(0);
funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, NULL);
}
Datum
hstore_contains(PG_FUNCTION_ARGS)
{
- HStore *val = PG_GETARG_HS(0);
- HStore *tmpl = PG_GETARG_HS(1);
+ HStore *val = PG_GETARG_HSTORE_P(0);
+ HStore *tmpl = PG_GETARG_HSTORE_P(1);
bool res = true;
HEntry *te = ARRPTR(tmpl);
char *tstr = STRPTR(tmpl);
if (SRF_IS_FIRSTCALL())
{
- hs = PG_GETARG_HS(0);
+ hs = PG_GETARG_HSTORE_P(0);
funcctx = SRF_FIRSTCALL_INIT();
setup_firstcall(funcctx, hs, fcinfo);
}
Datum
hstore_cmp(PG_FUNCTION_ARGS)
{
- HStore *hs1 = PG_GETARG_HS(0);
- HStore *hs2 = PG_GETARG_HS(1);
+ HStore *hs1 = PG_GETARG_HSTORE_P(0);
+ HStore *hs2 = PG_GETARG_HSTORE_P(1);
int hcount1 = HS_COUNT(hs1);
int hcount2 = HS_COUNT(hs2);
int res = 0;
Datum
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),
VARSIZE(hs) - VARHDRSZ);
hstore_to_plperl(PG_FUNCTION_ARGS)
{
dTHX;
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
Datum
hstore_to_plpython(PG_FUNCTION_ARGS)
{
- HStore *in = PG_GETARG_HS(0);
+ HStore *in = PG_GETARG_HSTORE_P(0);
int i;
int count = HS_COUNT(in);
char *base = STRPTR(in);
_ltree_consistent(PG_FUNCTION_ARGS)
{
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);
/* Oid subtype = PG_GETARG_OID(3); */
_ltree_isparent(PG_FUNCTION_ARGS)
{
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);
PG_FREE_IF_COPY(la, 0);
_ltree_risparent(PG_FUNCTION_ARGS)
{
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);
PG_FREE_IF_COPY(la, 0);
_ltq_regex(PG_FUNCTION_ARGS)
{
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);
PG_FREE_IF_COPY(la, 0);
_ltxtq_exec(PG_FUNCTION_ARGS)
{
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);
PG_FREE_IF_COPY(la, 0);
_ltree_extract_isparent(PG_FUNCTION_ARGS)
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
- ltree *query = PG_GETARG_LTREE(1);
+ ltree *query = PG_GETARG_LTREE_P(1);
ltree *found,
*item;
_ltree_extract_risparent(PG_FUNCTION_ARGS)
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
- ltree *query = PG_GETARG_LTREE(1);
+ ltree *query = PG_GETARG_LTREE_P(1);
ltree *found,
*item;
_ltq_extract_regex(PG_FUNCTION_ARGS)
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
- lquery *query = PG_GETARG_LQUERY(1);
+ lquery *query = PG_GETARG_LQUERY_P(1);
ltree *found,
*item;
_ltxtq_extract_exec(PG_FUNCTION_ARGS)
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
- ltxtquery *query = PG_GETARG_LTXTQUERY(1);
+ ltxtquery *query = PG_GETARG_LTXTQUERY_P(1);
ltree *found,
*item;
Datum
ltq_regex(PG_FUNCTION_ARGS)
{
- ltree *tree = PG_GETARG_LTREE(0);
- lquery *query = PG_GETARG_LQUERY(1);
+ ltree *tree = PG_GETARG_LTREE_P(0);
+ lquery *query = PG_GETARG_LQUERY_P(1);
bool res = false;
if (query->flag & LQUERY_HASNOT)
Datum
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);
lquery *query = (lquery *) ARR_DATA_PTR(_query);
bool res = false;
ltree *lca_inner(ltree **a, int len);
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))))
-#define PG_GETARG_LTREE_COPY(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
-#define PG_GETARG_LQUERY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
-#define PG_GETARG_LQUERY_COPY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
-#define PG_GETARG_LTXTQUERY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
-#define PG_GETARG_LTXTQUERY_COPY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
+/* fmgr macros for ltree objects */
+#define DatumGetLtreeP(X) ((ltree *) PG_DETOAST_DATUM(X))
+#define DatumGetLtreePCopy(X) ((ltree *) PG_DETOAST_DATUM_COPY(X))
+#define PG_GETARG_LTREE_P(n) DatumGetLtreeP(PG_GETARG_DATUM(n))
+#define PG_GETARG_LTREE_P_COPY(n) DatumGetLtreePCopy(PG_GETARG_DATUM(n))
+
+#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 */
if (entry->leafkey)
{ /* ltree */
ltree_gist *key;
- ltree *val = (ltree *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
+ ltree *val = DatumGetLtreeP(entry->key);
int32 len = LTG_HDRSIZE + VARSIZE(val);
key = (ltree_gist *) palloc0(len);
ltree_decompress(PG_FUNCTION_ARGS)
{
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)
{
switch (strategy)
{
case BTLessStrategyNumber:
- query = PG_GETARG_LTREE(1);
+ query = PG_GETARG_LTREE_P(1);
res = (GIST_LEAF(entry)) ?
(ltree_compare((ltree *) query, LTG_NODE(key)) > 0)
:
(ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0);
break;
case BTLessEqualStrategyNumber:
- query = PG_GETARG_LTREE(1);
+ query = PG_GETARG_LTREE_P(1);
res = (ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0);
break;
case BTEqualStrategyNumber:
- query = PG_GETARG_LTREE(1);
+ query = PG_GETARG_LTREE_P(1);
if (GIST_LEAF(entry))
res = (ltree_compare((ltree *) query, LTG_NODE(key)) == 0);
else
);
break;
case BTGreaterEqualStrategyNumber:
- query = PG_GETARG_LTREE(1);
+ query = PG_GETARG_LTREE_P(1);
res = (ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0);
break;
case BTGreaterStrategyNumber:
- query = PG_GETARG_LTREE(1);
+ query = PG_GETARG_LTREE_P(1);
res = (GIST_LEAF(entry)) ?
(ltree_compare((ltree *) query, LTG_GETRNODE(key)) < 0)
:
(ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0);
break;
case 10:
- query = PG_GETARG_LTREE_COPY(1);
+ query = PG_GETARG_LTREE_P_COPY(1);
res = (GIST_LEAF(entry)) ?
inner_isparent((ltree *) query, LTG_NODE(key))
:
gist_isparent(key, (ltree *) query);
break;
case 11:
- query = PG_GETARG_LTREE(1);
+ query = PG_GETARG_LTREE_P(1);
res = (GIST_LEAF(entry)) ?
inner_isparent(LTG_NODE(key), (ltree *) query)
:
break;
case 12:
case 13:
- query = PG_GETARG_LQUERY(1);
+ query = PG_GETARG_LQUERY_P(1);
if (GIST_LEAF(entry))
res = DatumGetBool(DirectFunctionCall2(ltq_regex,
PointerGetDatum(LTG_NODE(key)),
break;
case 14:
case 15:
- query = PG_GETARG_LQUERY(1);
+ query = PG_GETARG_LTXTQUERY_P(1);
if (GIST_LEAF(entry))
res = DatumGetBool(DirectFunctionCall2(ltxtq_exec,
PointerGetDatum(LTG_NODE(key)),
- PointerGetDatum((lquery *) query)
+ PointerGetDatum((ltxtquery *) query)
));
else
res = gist_qtxt(key, (ltxtquery *) query);
break;
case 16:
case 17:
- query = DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1)));
+ query = PG_GETARG_ARRAYTYPE_P(1);
if (GIST_LEAF(entry))
res = DatumGetBool(DirectFunctionCall2(lt_q_regex,
PointerGetDatum(LTG_NODE(key)),
Datum
ltree_out(PG_FUNCTION_ARGS)
{
- ltree *in = PG_GETARG_LTREE(0);
+ ltree *in = PG_GETARG_LTREE_P(0);
char *buf,
*ptr;
int i;
Datum
lquery_out(PG_FUNCTION_ARGS)
{
- lquery *in = PG_GETARG_LQUERY(0);
+ lquery *in = PG_GETARG_LQUERY_P(0);
char *buf,
*ptr;
int i,
}
#define RUNCMP \
-ltree *a = PG_GETARG_LTREE(0); \
-ltree *b = PG_GETARG_LTREE(1); \
-int res = ltree_compare(a,b); \
-PG_FREE_IF_COPY(a,0); \
-PG_FREE_IF_COPY(b,1); \
+ltree *a = PG_GETARG_LTREE_P(0); \
+ltree *b = PG_GETARG_LTREE_P(1); \
+int res = ltree_compare(a,b); \
+PG_FREE_IF_COPY(a,0); \
+PG_FREE_IF_COPY(b,1)
Datum
ltree_cmp(PG_FUNCTION_ARGS)
{
- RUNCMP
- PG_RETURN_INT32(res);
+ RUNCMP;
+ PG_RETURN_INT32(res);
}
Datum
ltree_lt(PG_FUNCTION_ARGS)
{
- RUNCMP
- PG_RETURN_BOOL((res < 0) ? true : false);
+ RUNCMP;
+ PG_RETURN_BOOL((res < 0) ? true : false);
}
Datum
ltree_le(PG_FUNCTION_ARGS)
{
- RUNCMP
- PG_RETURN_BOOL((res <= 0) ? true : false);
+ RUNCMP;
+ PG_RETURN_BOOL((res <= 0) ? true : false);
}
Datum
ltree_eq(PG_FUNCTION_ARGS)
{
- RUNCMP
- PG_RETURN_BOOL((res == 0) ? true : false);
+ RUNCMP;
+ PG_RETURN_BOOL((res == 0) ? true : false);
}
Datum
ltree_ge(PG_FUNCTION_ARGS)
{
- RUNCMP
- PG_RETURN_BOOL((res >= 0) ? true : false);
+ RUNCMP;
+ PG_RETURN_BOOL((res >= 0) ? true : false);
}
Datum
ltree_gt(PG_FUNCTION_ARGS)
{
- RUNCMP
- PG_RETURN_BOOL((res > 0) ? true : false);
+ RUNCMP;
+ PG_RETURN_BOOL((res > 0) ? true : false);
}
Datum
ltree_ne(PG_FUNCTION_ARGS)
{
- RUNCMP
- PG_RETURN_BOOL((res != 0) ? true : false);
+ RUNCMP;
+ PG_RETURN_BOOL((res != 0) ? true : false);
}
Datum
nlevel(PG_FUNCTION_ARGS)
{
- ltree *a = PG_GETARG_LTREE(0);
+ ltree *a = PG_GETARG_LTREE_P(0);
int res = a->numlevel;
PG_FREE_IF_COPY(a, 0);
Datum
ltree_isparent(PG_FUNCTION_ARGS)
{
- ltree *c = PG_GETARG_LTREE(1);
- ltree *p = PG_GETARG_LTREE(0);
+ ltree *c = PG_GETARG_LTREE_P(1);
+ ltree *p = PG_GETARG_LTREE_P(0);
bool res = inner_isparent(c, p);
PG_FREE_IF_COPY(c, 1);
Datum
ltree_risparent(PG_FUNCTION_ARGS)
{
- ltree *c = PG_GETARG_LTREE(0);
- ltree *p = PG_GETARG_LTREE(1);
+ ltree *c = PG_GETARG_LTREE_P(0);
+ ltree *p = PG_GETARG_LTREE_P(1);
bool res = inner_isparent(c, p);
PG_FREE_IF_COPY(c, 0);
Datum
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));
PG_FREE_IF_COPY(t, 0);
Datum
subpath(PG_FUNCTION_ARGS)
{
- ltree *t = PG_GETARG_LTREE(0);
+ ltree *t = PG_GETARG_LTREE_P(0);
int32 start = PG_GETARG_INT32(1);
int32 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int32 end;
Datum
ltree_addltree(PG_FUNCTION_ARGS)
{
- ltree *a = PG_GETARG_LTREE(0);
- ltree *b = PG_GETARG_LTREE(1);
+ ltree *a = PG_GETARG_LTREE_P(0);
+ ltree *b = PG_GETARG_LTREE_P(1);
ltree *r;
r = ltree_concat(a, b);
Datum
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);
char *s;
ltree *r,
Datum
ltree_index(PG_FUNCTION_ARGS)
{
- ltree *a = PG_GETARG_LTREE(0);
- ltree *b = PG_GETARG_LTREE(1);
+ ltree *a = PG_GETARG_LTREE_P(0);
+ ltree *b = PG_GETARG_LTREE_P(1);
int start = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int i,
j;
Datum
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);
char *s;
ltree *r,
a = (ltree **) palloc(sizeof(ltree *) * fcinfo->nargs);
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);
for (i = 0; i < fcinfo->nargs; i++)
PG_FREE_IF_COPY(a[i], i);
Datum
ltree2text(PG_FUNCTION_ARGS)
{
- ltree *in = PG_GETARG_LTREE(0);
+ ltree *in = PG_GETARG_LTREE_P(0);
char *ptr;
int i;
ltree_level *curlevel;
Datum
ltxtq_out(PG_FUNCTION_ARGS)
{
- ltxtquery *query = PG_GETARG_LTXTQUERY(0);
+ ltxtquery *query = PG_GETARG_LTXTQUERY_P(0);
INFIX nrm;
if (query->size == 0)
Datum
ltxtq_exec(PG_FUNCTION_ARGS)
{
- ltree *val = PG_GETARG_LTREE(0);
- ltxtquery *query = PG_GETARG_LTXTQUERY(1);
+ ltree *val = PG_GETARG_LTREE_P(0);
+ ltxtquery *query = PG_GETARG_LTXTQUERY_P(1);
CHKVAL chkval;
bool result;
Datum
ltree_to_plpython(PG_FUNCTION_ARGS)
{
- ltree *in = PG_GETARG_LTREE(0);
+ ltree *in = PG_GETARG_LTREE_P(0);
int i;
PyObject *list;
ltree_level *curlevel;
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;
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
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;
pfree(prs.stopsel);
}
- PG_RETURN_JSONB(out);
+ PG_RETURN_JSONB_P(out);
}
Datum
}
/*
- * 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;
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;
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;
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)
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,
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;
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;
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;
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)));
}
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);
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);
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);
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);
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);
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;
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;
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;
/* 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;
* 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));
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));
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;
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;
break;
case JSONBTYPE_JSONB:
{
- Jsonb *jsonb = DatumGetJsonb(val);
+ Jsonb *jsonb = DatumGetJsonbP(val);
JsonbIterator *it;
it = JsonbIteratorInit(&jsonb->root);
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;
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); */
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); */
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;
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); */
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); */
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;
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;
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;
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;
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;
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);
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);
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);
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);
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);
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);
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);
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;
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;
{
switch (r)
{
- /* Rotation is left to JsonbHashScalarValueExtended() */
+ /* Rotation is left to JsonbHashScalarValueExtended() */
case WJB_BEGIN_ARRAY:
hash ^= ((uint64) JB_FARRAY) << 32 | JB_FARRAY;
break;
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;
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;
VARSIZE_ANY_EXHDR(key));
if (v != NULL)
- PG_RETURN_JSONB(JsonbValueToJsonb(v));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(v));
PG_RETURN_NULL();
}
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;
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;
v = getIthJsonbValueFromContainer(&jb->root, element);
if (v != NULL)
- PG_RETURN_JSONB(JsonbValueToJsonb(v));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(v));
PG_RETURN_NULL();
}
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;
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;
else
{
/* not text mode - just hand back the jsonb */
- PG_RETURN_JSONB(jb);
+ PG_RETURN_JSONB_P(jb);
}
}
else
{
/* not text mode - just hand back the jsonb */
- PG_RETURN_JSONB(res);
+ PG_RETURN_JSONB_P(res);
}
}
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,
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;
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;
{
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)
}
else
{
- Jsonb *jb = PG_GETARG_JSONB(json_arg_num);
+ Jsonb *jb = PG_GETARG_JSONB_P(json_arg_num);
jsv.val.jsonb = &jbv;
}
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;
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;
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));
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,
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);
Assert(res != NULL);
- PG_RETURN_JSONB(JsonbValueToJsonb(res));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
}
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);
errmsg("cannot delete from scalar")));
if (JB_ROOT_COUNT(in) == 0)
- PG_RETURN_JSONB(in);
+ PG_RETURN_JSONB_P(in);
it = JsonbIteratorInit(&in->root);
Assert(res != NULL);
- PG_RETURN_JSONB(JsonbValueToJsonb(res));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
}
/*
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;
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);
Assert(res != NULL);
- PG_RETURN_JSONB(JsonbValueToJsonb(res));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
}
/*
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;
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);
}
if (idx >= n)
- PG_RETURN_JSONB(in);
+ PG_RETURN_JSONB_P(in);
pushJsonbValue(&state, r, NULL);
Assert(res != NULL);
- PG_RETURN_JSONB(JsonbValueToJsonb(res));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
}
/*
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;
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);
Assert(res != NULL);
- PG_RETURN_JSONB(JsonbValueToJsonb(res));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
}
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;
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);
Assert(res != NULL);
- PG_RETURN_JSONB(JsonbValueToJsonb(res));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
}
/*
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;
&path_elems, &path_nulls, &path_len);
if (path_len == 0)
- PG_RETURN_JSONB(in);
+ PG_RETURN_JSONB_P(in);
it = JsonbIteratorInit(&in->root);
Assert(res != NULL);
- PG_RETURN_JSONB(JsonbValueToJsonb(res));
+ PG_RETURN_JSONB_P(JsonbValueToJsonb(res));
}
/*
/* 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;
/* 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;
range = make_range(typcache, &lower, &upper, false);
- PG_RETURN_RANGE(range);
+ PG_RETURN_RANGE_P(range);
}
/* Construct general range value from three arguments */
range = make_range(typcache, &lower, &upper, false);
- PG_RETURN_RANGE(range);
+ PG_RETURN_RANGE_P(range);
}
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;
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;
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);
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);
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);
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);
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);
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;
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));
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));
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));
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));
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));
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));
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));
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));
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));
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));
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));
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;
/* 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);
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");
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));
}
/*
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;
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;
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 */
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;
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;
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;
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;
range_deserialize(typcache, r, &lower, &upper, &empty);
if (empty)
- PG_RETURN_RANGE(r);
+ PG_RETURN_RANGE_P(r);
if (!lower.infinite && !lower.inclusive)
{
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;
range_deserialize(typcache, r, &lower, &upper, &empty);
if (empty)
- PG_RETURN_RANGE(r);
+ PG_RETURN_RANGE_P(r);
if (!lower.infinite && !lower.inclusive)
{
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;
range_deserialize(typcache, r, &lower, &upper, &empty);
if (empty)
- PG_RETURN_RANGE(r);
+ PG_RETURN_RANGE_P(r);
if (!lower.infinite && !lower.inclusive)
{
upper.inclusive = false;
}
- PG_RETURN_RANGE(range_serialize(typcache, &lower, &upper, false));
+ PG_RETURN_RANGE_P(range_serialize(typcache, &lower, &upper, false));
}
/*
/* 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;
}
/* 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 */
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 */
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,
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;
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)]++;
}
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);
/*
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:
/*
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:
* 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 */
{
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 */
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);
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);
}
/*
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 */
}
}
- v->spl_ldatum = RangeTypeGetDatum(left_range);
- v->spl_rdatum = RangeTypeGetDatum(right_range);
+ v->spl_ldatum = RangeTypePGetDatum(left_range);
+ v->spl_rdatum = RangeTypePGetDatum(right_range);
}
/*
*/
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;
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);
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);
}
/*
/* 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,
/*
* 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);
{
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
/* Both sides are the same range type */
typcache = range_get_typcache(fcinfo, vardata.vartype);
- constrange = DatumGetRangeType(((Const *) other)->constvalue);
+ constrange = DatumGetRangeTypeP(((Const *) other)->constvalue);
}
/*
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)
{
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;
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();
}
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);
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();
}
*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);
/* 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++;
/* 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();
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;
*/
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;
}
*/
if (strategy != RANGESTRAT_CONTAINS_ELEM)
empty = RangeIsEmpty(
- DatumGetRangeType(in->scankeys[i].sk_argument));
+ DatumGetRangeTypeP(in->scankeys[i].sk_argument));
else
empty = false;
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);
}
else
{
- range = DatumGetRangeType(in->scankeys[i].sk_argument);
+ range = DatumGetRangeTypeP(in->scankeys[i].sk_argument);
range_deserialize(typcache, range, &lower, &upper, &empty);
}
*/
if (in->traversalValue != (Datum) 0)
{
- prevCentroid = DatumGetRangeType(in->traversalValue);
+ prevCentroid = DatumGetRangeTypeP(in->traversalValue);
range_deserialize(typcache, prevCentroid,
&prevLower, &prevUpper, &prevEmpty);
}
{
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;
{
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,
break;
case RANGESTRAT_EQ:
res = range_eq_internal(typcache, leafRange,
- DatumGetRangeType(keyDatum));
+ DatumGetRangeTypeP(keyDatum));
break;
default:
elog(ERROR, "unrecognized range strategy: %d",
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)
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)
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))
{
#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.
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 */
#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;
/*
* 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 */