diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/btree_gist/btree_text.c | 2 | ||||
-rw-r--r-- | contrib/btree_gist/btree_utils_var.c | 6 | ||||
-rw-r--r-- | contrib/cube/cube.c | 151 | ||||
-rw-r--r-- | contrib/cube/cubedata.h | 6 | ||||
-rw-r--r-- | contrib/hstore/hstore.h | 2 | ||||
-rw-r--r-- | contrib/hstore/hstore_gin.c | 4 | ||||
-rw-r--r-- | contrib/hstore/hstore_gist.c | 2 | ||||
-rw-r--r-- | contrib/hstore/hstore_io.c | 14 | ||||
-rw-r--r-- | contrib/hstore/hstore_op.c | 50 | ||||
-rw-r--r-- | contrib/hstore_plperl/hstore_plperl.c | 2 | ||||
-rw-r--r-- | contrib/hstore_plpython/hstore_plpython.c | 2 | ||||
-rw-r--r-- | contrib/ltree/_ltree_gist.c | 2 | ||||
-rw-r--r-- | contrib/ltree/_ltree_op.c | 16 | ||||
-rw-r--r-- | contrib/ltree/lquery_op.c | 6 | ||||
-rw-r--r-- | contrib/ltree/ltree.h | 21 | ||||
-rw-r--r-- | contrib/ltree/ltree_gist.c | 26 | ||||
-rw-r--r-- | contrib/ltree/ltree_io.c | 4 | ||||
-rw-r--r-- | contrib/ltree/ltree_op.c | 68 | ||||
-rw-r--r-- | contrib/ltree/ltxtquery_io.c | 2 | ||||
-rw-r--r-- | contrib/ltree/ltxtquery_op.c | 4 | ||||
-rw-r--r-- | contrib/ltree_plpython/ltree_plpython.c | 2 |
21 files changed, 201 insertions, 191 deletions
diff --git a/contrib/btree_gist/btree_text.c b/contrib/btree_gist/btree_text.c index 090c8494701..02cc0a45b1d 100644 --- a/contrib/btree_gist/btree_text.c +++ b/contrib/btree_gist/btree_text.c @@ -171,7 +171,7 @@ Datum 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); */ diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index 586de63a4d3..a43d81a1651 100644 --- a/contrib/btree_gist/btree_utils_var.c +++ b/contrib/btree_gist/btree_utils_var.c @@ -37,7 +37,7 @@ Datum 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)) { @@ -159,7 +159,7 @@ gbt_var_node_cp_len(const GBT_VARKEY *node, const gbtree_vinfo *tinfo) l--; i++; } - return ml; /* lower == upper */ + return ml; /* lower == upper */ } @@ -307,7 +307,7 @@ Datum 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; diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index 1032b997f97..b7702716fed 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -126,7 +126,7 @@ cube_in(PG_FUNCTION_ARGS) cube_scanner_finish(); - PG_RETURN_NDBOX(result); + PG_RETURN_NDBOX_P(result); } @@ -187,7 +187,7 @@ cube_a_f8_f8(PG_FUNCTION_ARGS) else SET_POINT_BIT(result); - PG_RETURN_NDBOX(result); + PG_RETURN_NDBOX_P(result); } /* @@ -221,13 +221,13 @@ cube_a_f8(PG_FUNCTION_ARGS) 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, @@ -263,13 +263,13 @@ cube_subset(PG_FUNCTION_ARGS) } 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; @@ -316,7 +316,7 @@ Datum 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); */ @@ -331,10 +331,10 @@ g_cube_consistent(PG_FUNCTION_ARGS) * 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); @@ -355,7 +355,7 @@ g_cube_union(PG_FUNCTION_ARGS) NDBOX *tmp; int i; - tmp = DatumGetNDBOX(entryvec->vector[0].key); + tmp = DatumGetNDBOXP(entryvec->vector[0].key); /* * sizep = sizeof(NDBOX); -- NDBOX has variable size @@ -365,7 +365,7 @@ g_cube_union(PG_FUNCTION_ARGS) 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; } @@ -388,9 +388,9 @@ Datum 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)); @@ -417,10 +417,10 @@ g_cube_penalty(PG_FUNCTION_ARGS) 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); @@ -473,17 +473,18 @@ g_cube_picksplit(PG_FUNCTION_ARGS) 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; @@ -506,10 +507,10 @@ g_cube_picksplit(PG_FUNCTION_ARGS) 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); @@ -548,7 +549,7 @@ g_cube_picksplit(PG_FUNCTION_ARGS) } /* 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); @@ -584,8 +585,8 @@ g_cube_picksplit(PG_FUNCTION_ARGS) 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) @@ -593,7 +594,7 @@ g_cube_same(PG_FUNCTION_ARGS) else *result = FALSE; - PG_RETURN_NDBOX(result); + PG_RETURN_NDBOX_P(result); } /* @@ -735,23 +736,23 @@ cube_union_v0(NDBOX *a, NDBOX *b) 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; @@ -823,14 +824,14 @@ cube_inter(PG_FUNCTION_ARGS) /* * 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); @@ -948,8 +949,8 @@ cube_cmp_v0(NDBOX *a, NDBOX *b) 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); @@ -963,8 +964,8 @@ cube_cmp(PG_FUNCTION_ARGS) 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); @@ -978,8 +979,8 @@ cube_eq(PG_FUNCTION_ARGS) 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); @@ -993,8 +994,8 @@ cube_ne(PG_FUNCTION_ARGS) 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); @@ -1008,8 +1009,8 @@ cube_lt(PG_FUNCTION_ARGS) 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); @@ -1023,8 +1024,8 @@ cube_gt(PG_FUNCTION_ARGS) 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); @@ -1038,8 +1039,8 @@ cube_le(PG_FUNCTION_ARGS) 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); @@ -1093,8 +1094,8 @@ cube_contains_v0(NDBOX *a, NDBOX *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); @@ -1109,8 +1110,8 @@ cube_contains(PG_FUNCTION_ARGS) 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); @@ -1164,8 +1165,8 @@ cube_overlap_v0(NDBOX *a, NDBOX *b) 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); @@ -1184,8 +1185,8 @@ cube_overlap(PG_FUNCTION_ARGS) 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; @@ -1233,8 +1234,8 @@ cube_distance(PG_FUNCTION_ARGS) 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; @@ -1277,8 +1278,8 @@ distance_taxicab(PG_FUNCTION_ARGS) 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; @@ -1331,7 +1332,7 @@ g_cube_distance(PG_FUNCTION_ARGS) { 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) @@ -1348,7 +1349,7 @@ g_cube_distance(PG_FUNCTION_ARGS) } else { - NDBOX *query = PG_GETARG_NDBOX(1); + NDBOX *query = PG_GETARG_NDBOX_P(1); switch (strategy) { @@ -1392,7 +1393,7 @@ distance_1D(double a1, double a2, double b1, double b2) 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); @@ -1427,7 +1428,7 @@ cube_is_point_internal(NDBOX *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); @@ -1438,7 +1439,7 @@ cube_dim(PG_FUNCTION_ARGS) 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; @@ -1455,7 +1456,7 @@ cube_ll_coord(PG_FUNCTION_ARGS) 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; @@ -1476,7 +1477,7 @@ cube_ur_coord(PG_FUNCTION_ARGS) 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)) @@ -1504,7 +1505,7 @@ cube_coord(PG_FUNCTION_ARGS) 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)) @@ -1534,7 +1535,7 @@ cube_coord_llur(PG_FUNCTION_ARGS) 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; @@ -1592,7 +1593,7 @@ cube_enlarge(PG_FUNCTION_ARGS) } 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 */ @@ -1610,7 +1611,7 @@ cube_f8(PG_FUNCTION_ARGS) SET_POINT_BIT(result); result->x[0] = x; - PG_RETURN_NDBOX(result); + PG_RETURN_NDBOX_P(result); } /* Create a one dimensional box */ @@ -1641,7 +1642,7 @@ cube_f8_f8(PG_FUNCTION_ARGS) 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 @@ -1649,7 +1650,7 @@ cube_f8_f8(PG_FUNCTION_ARGS) 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; @@ -1682,14 +1683,14 @@ cube_c_f8(PG_FUNCTION_ARGS) } 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; @@ -1723,5 +1724,5 @@ cube_c_f8_f8(PG_FUNCTION_ARGS) } PG_FREE_IF_COPY(cube, 0); - PG_RETURN_NDBOX(result); + PG_RETURN_NDBOX_P(result); } diff --git a/contrib/cube/cubedata.h b/contrib/cube/cubedata.h index 6e6ddfd3d75..dbe7d4f7429 100644 --- a/contrib/cube/cubedata.h +++ b/contrib/cube/cubedata.h @@ -49,9 +49,9 @@ typedef struct NDBOX #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 /* ~> */ diff --git a/contrib/hstore/hstore.h b/contrib/hstore/hstore.h index c4862a82e17..bf4a565ed9b 100644 --- a/contrib/hstore/hstore.h +++ b/contrib/hstore/hstore.h @@ -151,7 +151,7 @@ extern HStore *hstoreUpgrade(Datum orig); #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)) /* diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c index d98fb384583..4c3a422643d 100644 --- a/contrib/hstore/hstore_gin.c +++ b/contrib/hstore/hstore_gin.c @@ -43,7 +43,7 @@ makeitem(char *str, int len, char flag) 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); @@ -155,7 +155,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS) 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); */ diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c index f8f5934e404..3a61342019b 100644 --- a/contrib/hstore/hstore_gist.c +++ b/contrib/hstore/hstore_gist.c @@ -518,7 +518,7 @@ ghstore_consistent(PG_FUNCTION_ARGS) 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); diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c index a44c1b22353..6363c321c5d 100644 --- a/contrib/hstore/hstore_io.c +++ b/contrib/hstore/hstore_io.c @@ -962,7 +962,7 @@ hstore_populate_record(PG_FUNCTION_ARGS) tupTypmod = HeapTupleHeaderGetTypMod(rec); } - hs = PG_GETARG_HS(1); + hs = PG_GETARG_HSTORE_P(1); entries = ARRPTR(hs); ptr = STRPTR(hs); @@ -1127,7 +1127,7 @@ PG_FUNCTION_INFO_V1(hstore_out); 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); @@ -1198,7 +1198,7 @@ PG_FUNCTION_INFO_V1(hstore_send); 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); @@ -1244,7 +1244,7 @@ PG_FUNCTION_INFO_V1(hstore_to_json_loose); 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); @@ -1299,7 +1299,7 @@ PG_FUNCTION_INFO_V1(hstore_to_json); 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); @@ -1344,7 +1344,7 @@ PG_FUNCTION_INFO_V1(hstore_to_jsonb); 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); @@ -1387,7 +1387,7 @@ PG_FUNCTION_INFO_V1(hstore_to_jsonb_loose); 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); diff --git a/contrib/hstore/hstore_op.c b/contrib/hstore/hstore_op.c index 612be23a74f..8f9277f8da2 100644 --- a/contrib/hstore/hstore_op.c +++ b/contrib/hstore/hstore_op.c @@ -130,7 +130,7 @@ PG_FUNCTION_INFO_V1(hstore_fetchval); 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; @@ -151,7 +151,7 @@ PG_FUNCTION_INFO_V1(hstore_exists); 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)); @@ -164,7 +164,7 @@ PG_FUNCTION_INFO_V1(hstore_exists_any); 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); @@ -198,7 +198,7 @@ PG_FUNCTION_INFO_V1(hstore_exists_all); 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); @@ -232,7 +232,7 @@ PG_FUNCTION_INFO_V1(hstore_defined); 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, @@ -247,7 +247,7 @@ PG_FUNCTION_INFO_V1(hstore_delete); 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); @@ -294,7 +294,7 @@ PG_FUNCTION_INFO_V1(hstore_delete_array); 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, @@ -373,8 +373,8 @@ PG_FUNCTION_INFO_V1(hstore_delete_hstore); 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); @@ -473,8 +473,8 @@ PG_FUNCTION_INFO_V1(hstore_concat); 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, @@ -571,7 +571,7 @@ PG_FUNCTION_INFO_V1(hstore_slice_to_array); 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); @@ -634,7 +634,7 @@ PG_FUNCTION_INFO_V1(hstore_slice_to_hstore); 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); @@ -696,7 +696,7 @@ PG_FUNCTION_INFO_V1(hstore_akeys); 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); @@ -731,7 +731,7 @@ PG_FUNCTION_INFO_V1(hstore_avals); 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; @@ -827,7 +827,7 @@ PG_FUNCTION_INFO_V1(hstore_to_array); 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); @@ -837,7 +837,7 @@ PG_FUNCTION_INFO_V1(hstore_to_matrix); 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); @@ -891,7 +891,7 @@ hstore_skeys(PG_FUNCTION_ARGS) if (SRF_IS_FIRSTCALL()) { - hs = PG_GETARG_HS(0); + hs = PG_GETARG_HSTORE_P(0); funcctx = SRF_FIRSTCALL_INIT(); setup_firstcall(funcctx, hs, NULL); } @@ -925,7 +925,7 @@ hstore_svals(PG_FUNCTION_ARGS) if (SRF_IS_FIRSTCALL()) { - hs = PG_GETARG_HS(0); + hs = PG_GETARG_HSTORE_P(0); funcctx = SRF_FIRSTCALL_INIT(); setup_firstcall(funcctx, hs, NULL); } @@ -967,8 +967,8 @@ PG_FUNCTION_INFO_V1(hstore_contains); 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); @@ -1032,7 +1032,7 @@ hstore_each(PG_FUNCTION_ARGS) if (SRF_IS_FIRSTCALL()) { - hs = PG_GETARG_HS(0); + hs = PG_GETARG_HSTORE_P(0); funcctx = SRF_FIRSTCALL_INIT(); setup_firstcall(funcctx, hs, fcinfo); } @@ -1087,8 +1087,8 @@ PG_FUNCTION_INFO_V1(hstore_cmp); 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; @@ -1235,7 +1235,7 @@ PG_FUNCTION_INFO_V1(hstore_hash); 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); diff --git a/contrib/hstore_plperl/hstore_plperl.c b/contrib/hstore_plperl/hstore_plperl.c index cc46a525f6f..6bc3bb37fc3 100644 --- a/contrib/hstore_plperl/hstore_plperl.c +++ b/contrib/hstore_plperl/hstore_plperl.c @@ -68,7 +68,7 @@ Datum 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); diff --git a/contrib/hstore_plpython/hstore_plpython.c b/contrib/hstore_plpython/hstore_plpython.c index b184324ebf0..22366bd40f7 100644 --- a/contrib/hstore_plpython/hstore_plpython.c +++ b/contrib/hstore_plpython/hstore_plpython.c @@ -85,7 +85,7 @@ PG_FUNCTION_INFO_V1(hstore_to_plpython); 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); diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c index a387f5b899e..23952df4afe 100644 --- a/contrib/ltree/_ltree_gist.c +++ b/contrib/ltree/_ltree_gist.c @@ -545,7 +545,7 @@ Datum _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); */ diff --git a/contrib/ltree/_ltree_op.c b/contrib/ltree/_ltree_op.c index fdf6ebb43b1..9bb6bcaeffa 100644 --- a/contrib/ltree/_ltree_op.c +++ b/contrib/ltree/_ltree_op.c @@ -71,7 +71,7 @@ Datum _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); @@ -92,7 +92,7 @@ Datum _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); @@ -113,7 +113,7 @@ Datum _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); @@ -178,7 +178,7 @@ Datum _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); @@ -200,7 +200,7 @@ Datum _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; @@ -223,7 +223,7 @@ Datum _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; @@ -246,7 +246,7 @@ Datum _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; @@ -269,7 +269,7 @@ Datum _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; diff --git a/contrib/ltree/lquery_op.c b/contrib/ltree/lquery_op.c index 229ddd0ae3d..b6d2deb1af4 100644 --- a/contrib/ltree/lquery_op.c +++ b/contrib/ltree/lquery_op.c @@ -302,8 +302,8 @@ checkCond(lquery_level *curq, int query_numlevel, ltree_level *curt, int tree_nu 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) @@ -338,7 +338,7 @@ ltq_rregex(PG_FUNCTION_ARGS) 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; diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h index fd86323ffe0..e4b8c84fa62 100644 --- a/contrib/ltree/ltree.h +++ b/contrib/ltree/ltree.h @@ -165,12 +165,21 @@ bool compare_subnode(ltree_level *t, char *q, int len, 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 */ diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c index 70e78a672ac..ecfd9d84d76 100644 --- a/contrib/ltree/ltree_gist.c +++ b/contrib/ltree/ltree_gist.c @@ -53,7 +53,7 @@ ltree_compress(PG_FUNCTION_ARGS) 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); @@ -73,7 +73,7 @@ Datum 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) { @@ -621,18 +621,18 @@ ltree_consistent(PG_FUNCTION_ARGS) 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 @@ -643,25 +643,25 @@ ltree_consistent(PG_FUNCTION_ARGS) ); 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) : @@ -669,7 +669,7 @@ ltree_consistent(PG_FUNCTION_ARGS) 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)), @@ -680,18 +680,18 @@ ltree_consistent(PG_FUNCTION_ARGS) 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)), diff --git a/contrib/ltree/ltree_io.c b/contrib/ltree/ltree_io.c index 34ca597a484..f54f0374436 100644 --- a/contrib/ltree/ltree_io.c +++ b/contrib/ltree/ltree_io.c @@ -149,7 +149,7 @@ ltree_in(PG_FUNCTION_ARGS) Datum ltree_out(PG_FUNCTION_ARGS) { - ltree *in = PG_GETARG_LTREE(0); + ltree *in = PG_GETARG_LTREE_P(0); char *buf, *ptr; int i; @@ -521,7 +521,7 @@ lquery_in(PG_FUNCTION_ARGS) Datum lquery_out(PG_FUNCTION_ARGS) { - lquery *in = PG_GETARG_LQUERY(0); + lquery *in = PG_GETARG_LQUERY_P(0); char *buf, *ptr; int i, diff --git a/contrib/ltree/ltree_op.c b/contrib/ltree/ltree_op.c index aa1e9918bef..d62ca02521b 100644 --- a/contrib/ltree/ltree_op.c +++ b/contrib/ltree/ltree_op.c @@ -67,65 +67,65 @@ ltree_compare(const ltree *a, const ltree *b) } #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); @@ -159,8 +159,8 @@ inner_isparent(const ltree *c, const ltree *p) 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); @@ -171,8 +171,8 @@ ltree_isparent(PG_FUNCTION_ARGS) 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); @@ -223,7 +223,7 @@ inner_subltree(ltree *t, int32 startpos, int32 endpos) 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); @@ -233,7 +233,7 @@ subltree(PG_FUNCTION_ARGS) 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; @@ -282,8 +282,8 @@ ltree_concat(ltree *a, ltree *b) 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); @@ -295,7 +295,7 @@ ltree_addltree(PG_FUNCTION_ARGS) 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, @@ -320,8 +320,8 @@ ltree_addtext(PG_FUNCTION_ARGS) 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; @@ -380,7 +380,7 @@ ltree_index(PG_FUNCTION_ARGS) 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, @@ -476,7 +476,7 @@ lca(PG_FUNCTION_ARGS) 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); @@ -508,7 +508,7 @@ text2ltree(PG_FUNCTION_ARGS) 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; diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c index 9ca19942491..56bf39d145b 100644 --- a/contrib/ltree/ltxtquery_io.c +++ b/contrib/ltree/ltxtquery_io.c @@ -515,7 +515,7 @@ infix(INFIX *in, bool first) 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) diff --git a/contrib/ltree/ltxtquery_op.c b/contrib/ltree/ltxtquery_op.c index 6e9dbc46906..dc0ee82bb6e 100644 --- a/contrib/ltree/ltxtquery_op.c +++ b/contrib/ltree/ltxtquery_op.c @@ -86,8 +86,8 @@ checkcondition_str(void *checkval, ITEM *val) 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; diff --git a/contrib/ltree_plpython/ltree_plpython.c b/contrib/ltree_plpython/ltree_plpython.c index bdd462a91b9..ae9b90dd10b 100644 --- a/contrib/ltree_plpython/ltree_plpython.c +++ b/contrib/ltree_plpython/ltree_plpython.c @@ -40,7 +40,7 @@ PG_FUNCTION_INFO_V1(ltree_to_plpython); 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; |