Skip to content

Commit

Permalink
Merge pull request #27 from adjust/pg16-compatibility
Browse files Browse the repository at this point in the history
modifications for pg16
  • Loading branch information
PerikAdjust authored Aug 9, 2024
2 parents 6d3a0a6 + f2a541a commit 494ff0b
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
test:
strategy:
matrix:
pg: [15, 14, 13, 12, 11, 10]
pg: [16, 15, 14, 13, 12, 11, 10]
name: 🐘 PostgreSQL ${{ matrix.pg }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
results
regression.diffs
regression.out


*.dylib
8 changes: 6 additions & 2 deletions _ltree_gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "access/skey.h"
#include "crc32.h"
#include "ltree.h"
#if PG_VERSION_NUM >= 160000
#include "varatt.h"
#include "utils/array.h"
#endif


PG_FUNCTION_INFO_V1(_ltree_compress);
Expand Down Expand Up @@ -378,7 +382,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
_j = GETENTRY(entryvec, j);
size_alpha = hemdist(datum_l, _j);
size_beta = hemdist(datum_r, _j);
costvector[j - 1].cost = Abs(size_alpha - size_beta);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);

Expand Down Expand Up @@ -556,7 +560,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); */
Expand Down
4 changes: 4 additions & 0 deletions _ltree_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* Teodor Sigaev <[email protected]>
*/
#include "postgres.h"
#if PG_VERSION_NUM >= 160000
#include "utils/array.h"
#endif


#include <ctype.h>

Expand Down
3 changes: 3 additions & 0 deletions lquery_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "catalog/pg_collation.h"
#include "utils/formatting.h"
#include "ltree.h"
#if PG_VERSION_NUM >= 160000
#include "utils/array.h"
#endif

PG_FUNCTION_INFO_V1(ltq_regex);
PG_FUNCTION_INFO_V1(ltq_rregex);
Expand Down
20 changes: 14 additions & 6 deletions ltree.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,20 @@ 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))))
#define DatumGetLtreeP(X) ((ltree *) PG_DETOAST_DATUM(X))
#define DatumGetLtreePCopy(X) ((ltree *) PG_DETOAST_DATUM_COPY(X))
#define PG_GETARG_LTREE(n) DatumGetLtreeP(PG_GETARG_DATUM(n))
#define PG_GETARG_LTREE_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(n) DatumGetLqueryP(PG_GETARG_DATUM(n))
#define PG_GETARG_LQUERY_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(n) DatumGetLtxtqueryP(PG_GETARG_DATUM(n))
#define PG_GETARG_LTXTQUERY_COPY(n) DatumGetLtxtqueryPCopy(PG_GETARG_DATUM(n))

/* GiST support for ltree */

Expand Down
11 changes: 8 additions & 3 deletions ltree_gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include "crc32.h"
#include "ltree.h"

#if PG_VERSION_NUM >= 160000
#include "varatt.h"
#include "utils/array.h"
#endif

#define NEXTVAL(x) ( (lquery*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )

PG_FUNCTION_INFO_V1(ltree_gist_in);
Expand Down Expand Up @@ -69,7 +74,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);
int4 len = LTG_HDRSIZE + VARSIZE(val);

key = (ltree_gist *) palloc(len);
Expand All @@ -89,7 +94,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)
{
Expand Down Expand Up @@ -707,7 +712,7 @@ ltree_consistent(PG_FUNCTION_ARGS)
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)),
Expand Down
4 changes: 4 additions & 0 deletions ltree_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "ltree.h"
#include "crc32.h"

#if PG_VERSION_NUM >= 160000
#include "varatt.h"
#endif

PG_FUNCTION_INFO_V1(ltree_in);
Datum ltree_in(PG_FUNCTION_ARGS);

Expand Down
3 changes: 3 additions & 0 deletions ltree_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "utils/lsyscache.h"
#include "utils/selfuncs.h"
#include "ltree.h"
#if PG_VERSION_NUM >= 160000
#include "varatt.h"
#endif

PG_MODULE_MAGIC;

Expand Down
3 changes: 3 additions & 0 deletions ltxtquery_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#include "crc32.h"
#include "ltree.h"
#if PG_VERSION_NUM >= 160000
#include "varatt.h"
#endif

PG_FUNCTION_INFO_V1(ltxtq_in);
Datum ltxtq_in(PG_FUNCTION_ARGS);
Expand Down
Binary file added wltree.dylib
Binary file not shown.

0 comments on commit 494ff0b

Please sign in to comment.