Skip to content

Commit

Permalink
make tests work from 9.4 to 10 to 11
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cui committed Jul 22, 2018
1 parent 5557e2f commit dd5b8ad
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pg_thrift.c
Expand Up @@ -1117,7 +1117,11 @@ Datum jsonb_to_thrift_binary_helper(char* type, JsonbValue jbv) {
if (r == WJB_BEGIN_ARRAY || r == WJB_END_ARRAY) continue;
size += 1;
JsonbValue element_copy = element;
#if PG_VERSION_NUM < 110000
Datum thrift_datum = DirectFunctionCall1(jsonb_to_thrift_binary, JsonbGetDatum(JsonbValueToJsonb(&element_copy)));
#else
Datum thrift_datum = DirectFunctionCall1(jsonb_to_thrift_binary, JsonbPGetDatum(JsonbValueToJsonb(&element_copy)));
#endif
bytea* one_element_bytea = DatumGetByteaP(thrift_datum);
if (target_type == -1) {
*(list + PG_THRIFT_TYPE_LEN) = *VARDATA(one_element_bytea);
Expand Down Expand Up @@ -1151,7 +1155,11 @@ Datum jsonb_to_thrift_binary_helper(char* type, JsonbValue jbv) {
if (r == WJB_BEGIN_ARRAY || r == WJB_END_ARRAY) continue;
size += 1;
JsonbValue element_copy = element;
#if PG_VERSION_NUM < 110000
Datum thrift_datum = DirectFunctionCall1(jsonb_to_thrift_binary, JsonbGetDatum(JsonbValueToJsonb(&element_copy)));
#else
Datum thrift_datum = DirectFunctionCall1(jsonb_to_thrift_binary, JsonbPGetDatum(JsonbValueToJsonb(&element_copy)));
#endif
bytea* one_element_bytea = DatumGetByteaP(thrift_datum);
if (size == 1) {
*(list + PG_THRIFT_TYPE_LEN) = *VARDATA(one_element_bytea);
Expand Down Expand Up @@ -1198,7 +1206,11 @@ Datum jsonb_to_thrift_binary_helper(char* type, JsonbValue jbv) {
field_id += 1;
} else if (r == WJB_VALUE) {
JsonbValue element_copy = element;
#if PG_VERSION_NUM < 110000
Datum thrift_datum = DirectFunctionCall1(jsonb_to_thrift_binary, JsonbGetDatum(JsonbValueToJsonb(&element_copy)));
#else
Datum thrift_datum = DirectFunctionCall1(jsonb_to_thrift_binary, JsonbPGetDatum(JsonbValueToJsonb(&element_copy)));
#endif
bytea* one_field = DatumGetByteaP(thrift_datum);
pData = repalloc(pData, current_len + VARSIZE(one_field) - VARHDRSZ + FIELD_LEN);
*(pData + current_len) = *VARDATA(one_field);
Expand All @@ -1224,7 +1236,11 @@ Datum jsonb_to_thrift_binary_helper(char* type, JsonbValue jbv) {
}

Datum jsonb_to_thrift_binary(PG_FUNCTION_ARGS) {
#if PG_VERSION_NUM < 110000
Jsonb* jsonb = PG_GETARG_JSONB(0);
#else
Jsonb* jsonb = PG_GETARG_JSONB_P(0);
#endif
JsonbIterator* it = JsonbIteratorInit(&jsonb->root);
JsonbValue v, jbv;
int key_count = 0, value_count = 0;
Expand Down

0 comments on commit dd5b8ad

Please sign in to comment.