Skip to content

Commit 7e36809

Browse files
authored
Merge pull request #14 from ildus/master
Add compability with pg11
2 parents 26471d8 + 2f772b5 commit 7e36809

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

zson.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ PG_FUNCTION_INFO_V1(jsonb_to_zson);
3030
PG_FUNCTION_INFO_V1(zson_info);
3131
PG_FUNCTION_INFO_V1(debug_dump_jsonb);
3232

33+
/* In version 11 these macros have been changed */
34+
#if PG_VERSION_NUM < 110000
35+
#define PG_GETARG_JSONB_P(v) PG_GETARG_JSONB(v)
36+
#define PG_RETURN_JSONB_P(v) PG_RETURN_JSONB(v)
37+
#endif
38+
3339
#define ZSON_CURRENT_VERSION 0
3440

3541
#define ZSON_HEADER_SIZE (sizeof(uint8) + sizeof(uint32)*2)
@@ -477,7 +483,7 @@ zson_fastdecompress(const Dict* pdict,
477483
Datum
478484
jsonb_to_zson(PG_FUNCTION_ARGS)
479485
{
480-
Jsonb *jsonb = PG_GETARG_JSONB(0);
486+
Jsonb *jsonb = PG_GETARG_JSONB_P(0);
481487
uint8* jsonb_data = (uint8*)VARDATA(jsonb);
482488
Size jsonb_data_size = VARSIZE(jsonb) - VARHDRSZ;
483489
uint8 *encoded_buff, *encoded_header, *encoded_data;
@@ -580,7 +586,7 @@ zson_to_jsonb(PG_FUNCTION_ARGS)
580586

581587
decoded_size += VARHDRSZ;
582588
SET_VARSIZE(jsonb, decoded_size);
583-
PG_RETURN_JSONB(jsonb);
589+
PG_RETURN_JSONB_P(jsonb);
584590
}
585591

586592
// zson -> "size, encoded size, other info"

0 commit comments

Comments
 (0)