diff --git a/jsonb_gin_ops.c b/jsonb_gin_ops.c index eef8a0d..32d1e92 100644 --- a/jsonb_gin_ops.c +++ b/jsonb_gin_ops.c @@ -732,7 +732,7 @@ gin_extract_jsonb_value_path_internal(Jsonb *jb, int32 *nentries, uint32 **bloom Datum gin_extract_jsonb_value_path(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); PG_RETURN_POINTER(gin_extract_jsonb_value_path_internal(jb, nentries, NULL)); @@ -770,12 +770,12 @@ gin_extract_jsonb_query_value_path(PG_FUNCTION_ARGS) switch(strategy) { case JsonbContainsStrategyNumber: - jb = PG_GETARG_JSONB(0); + jb = PG_GETARG_JSONB_P(0); entries = gin_extract_jsonb_value_path_internal(jb, nentries, NULL); break; case JsonbNestedContainsStrategyNumber: - jb = PG_GETARG_JSONB(0); + jb = PG_GETARG_JSONB_P(0); entries = gin_extract_jsonb_value_path_internal(jb, nentries, &bloom); n = *nentries; @@ -867,7 +867,7 @@ gin_triconsistent_jsonb_value_path(PG_FUNCTION_ARGS) { GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); - /* Jsonb *query = PG_GETARG_JSONB(2); */ + /* Jsonb *query = PG_GETARG_JSONB_P(2); */ int32 nkeys = PG_GETARG_INT32(3); Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); GinTernaryValue res = GIN_TRUE; @@ -1171,7 +1171,7 @@ gin_extract_jsonb_path_value_internal(Jsonb *jb, int32 *nentries) Datum gin_extract_jsonb_path_value(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); int32 *nentries = (int32 *) PG_GETARG_POINTER(1); PG_RETURN_POINTER(gin_extract_jsonb_path_value_internal(jb, nentries)); @@ -1209,7 +1209,7 @@ gin_extract_jsonb_query_path_value(PG_FUNCTION_ARGS) switch(strategy) { case JsonbContainsStrategyNumber: - jb = PG_GETARG_JSONB(0); + jb = PG_GETARG_JSONB_P(0); entries = gin_extract_jsonb_path_value_internal(jb, nentries); break; @@ -1250,7 +1250,7 @@ gin_consistent_jsonb_path_value(PG_FUNCTION_ARGS) { bool *check = (bool *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); - /* Jsonb *query = PG_GETARG_JSONB(2); */ + /* Jsonb *query = PG_GETARG_JSONB_P(2); */ int32 nkeys = PG_GETARG_INT32(3); Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); bool *recheck = (bool *) PG_GETARG_POINTER(5); @@ -1291,7 +1291,7 @@ gin_triconsistent_jsonb_path_value(PG_FUNCTION_ARGS) { GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0); StrategyNumber strategy = PG_GETARG_UINT16(1); - /* Jsonb *query = PG_GETARG_JSONB(2); */ + /* Jsonb *query = PG_GETARG_JSONB_P(2); */ int32 nkeys = PG_GETARG_INT32(3); Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); GinTernaryValue res = GIN_TRUE; diff --git a/jsquery.h b/jsquery.h index fbfc5c5..99855b0 100644 --- a/jsquery.h +++ b/jsquery.h @@ -248,4 +248,12 @@ bool queryNeedRecheck(ExtractedNode *node); bool execRecursive(ExtractedNode *node, bool *check); bool execRecursiveTristate(ExtractedNode *node, GinTernaryValue *check); +#ifndef PG_RETURN_JSONB_P +#define PG_RETURN_JSONB_P(x) PG_RETURN_JSONB(x) +#endif + +#ifndef PG_GETARG_JSONB_P +#define PG_GETARG_JSONB_P(x) PG_GETARG_JSONB(x) +#endif + #endif diff --git a/jsquery_extract.c b/jsquery_extract.c index bee9ea4..8f80b30 100644 --- a/jsquery_extract.c +++ b/jsquery_extract.c @@ -868,7 +868,7 @@ execRecursiveTristate(ExtractedNode *node, GinTernaryValue *check) res = GIN_TRUE; for (i = 0; i < node->args.count; i++) { - v = execRecursive(node->args.items[i], check); + v = execRecursive(node->args.items[i], (bool *) check); if (v == GIN_FALSE) return GIN_FALSE; else if (v == GIN_MAYBE) @@ -879,7 +879,7 @@ execRecursiveTristate(ExtractedNode *node, GinTernaryValue *check) res = GIN_FALSE; for (i = 0; i < node->args.count; i++) { - v = execRecursive(node->args.items[i], check); + v = execRecursive(node->args.items[i], (bool *) check); if (v == GIN_TRUE) return GIN_TRUE; else if (v == GIN_MAYBE) diff --git a/jsquery_op.c b/jsquery_op.c index b023de0..4c1def3 100644 --- a/jsquery_op.c +++ b/jsquery_op.c @@ -780,7 +780,7 @@ Datum jsquery_json_exec(PG_FUNCTION_ARGS) { JsQuery *jq = PG_GETARG_JSQUERY(0); - Jsonb *jb = PG_GETARG_JSONB(1); + Jsonb *jb = PG_GETARG_JSONB_P(1); bool res; JsonbValue jbv; JsQueryItem jsq; @@ -803,7 +803,7 @@ PG_FUNCTION_INFO_V1(json_jsquery_exec); Datum json_jsquery_exec(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); JsQuery *jq = PG_GETARG_JSQUERY(1); bool res; JsonbValue jbv; @@ -827,7 +827,7 @@ PG_FUNCTION_INFO_V1(json_jsquery_filter); Datum json_jsquery_filter(PG_FUNCTION_ARGS) { - Jsonb *jb = PG_GETARG_JSONB(0); + Jsonb *jb = PG_GETARG_JSONB_P(0); JsQuery *jq = PG_GETARG_JSQUERY(1); Jsonb *res = NULL; JsonbValue jbv; @@ -854,9 +854,9 @@ json_jsquery_filter(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(jq, 1); if (res) - PG_RETURN_JSONB(res); - else - PG_RETURN_NULL(); + PG_RETURN_JSONB_P(res); + + PG_RETURN_NULL(); }