Skip to content

Commit d72f0bb

Browse files
author
Vladlen Popolitov
committed
Compatibility with PG v10-13 fixed
1 parent 9a90b42 commit d72f0bb

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed

anyarray--2.0.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,27 @@ CREATE OPERATOR - (
8585
PROCEDURE = array_remove
8686
);
8787

88+
/* PG 13 and lower */
89+
/*
90+
CREATE OPERATOR + (
91+
LEFTARG = anyarray,
92+
RIGHTARG = anyelement,
93+
PROCEDURE = array_append
94+
);
95+
96+
CREATE OPERATOR + (
97+
LEFTARG = anyarray,
98+
RIGHTARG = anyarray,
99+
PROCEDURE = array_cat
100+
);
101+
102+
CREATE OPERATOR - (
103+
LEFTARG = anyarray,
104+
RIGHTARG = anyelement,
105+
PROCEDURE = array_remove
106+
);
107+
*/
108+
88109
CREATE FUNCTION subtract_array(anyarray, anyarray)
89110
RETURNS anyarray
90111
AS 'MODULE_PATHNAME', 'aa_subtract_array'

anyarray.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121

2222
#include <catalog/pg_collation.h>
2323
#include <utils/builtins.h>
24+
#if PG_VERSION_NUM >= 120000
2425
#include <utils/float.h>
25-
26+
#endif
2627

2728
#define CMP(a, b, cmpFunc) \
2829
DatumGetInt32(FunctionCall2Coll((cmpFunc), DEFAULT_COLLATION_OID, (a), (b)))

anyarray_gin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*-------------------------------------------------------------------------
1717
*/
1818

19+
#include <math.h>
1920

2021
#include "postgres.h"
2122

anyarray_gist.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
#include "anyarray.h"
2323
#include "access/gist.h"
2424
#include "access/skey.h"
25+
#if PG_VERSION_NUM >= 130000
2526
#include "access/heaptoast.h"
26-
27+
#else
28+
#include "access/tuptoaster.h"
29+
#endif
2730
PG_FUNCTION_INFO_V1(ganyarrayin);
2831
PG_FUNCTION_INFO_V1(ganyarrayout);
2932
PG_FUNCTION_INFO_V1(ganyarray_consistent);

anyarray_rum.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@
1616
#include <math.h>
1717
#if PG_VERSION_NUM >= 120000
1818
#include "utils/float.h"
19+
#else
20+
static inline float8
21+
get_float8_infinity(void)
22+
{
23+
#ifdef INFINITY
24+
/* C99 standard way */
25+
return (float8) INFINITY;
26+
#else
27+
28+
/*
29+
* On some platforms, HUGE_VAL is an infinity, elsewhere it's just the
30+
* largest normal float8. We assume forcing an overflow will get us a
31+
* true infinity.
32+
*/
33+
return (float8) (HUGE_VAL * HUGE_VAL);
34+
#endif
35+
}
36+
#endif
37+
#if PG_VERSION_NUM < 130000
38+
/* definition of INT4OID in early PG versions */
39+
#include "catalog/pg_type.h"
1940
#endif
2041

2142
#include "anyarray.h"

anyarray_util.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232

3333
PG_MODULE_MAGIC;
3434

35+
#if PG_VERSION_NUM < 110000
36+
#define HASHSTANDARD_PROC HASHPROC
37+
#endif
38+
3539
static Oid
3640
getAMProc(Oid amOid, Oid typid)
3741
{
@@ -54,9 +58,14 @@ getAMProc(Oid amOid, Oid typid)
5458
/*
5559
* Search binary-coercible type
5660
*/
61+
#if PG_VERSION_NUM >= 110000
5762
catlist = SearchSysCacheList(CASTSOURCETARGET,
5863
ObjectIdGetDatum(typid),
5964
0, 0, 0);
65+
#else
66+
catlist = SearchSysCacheList1(CASTSOURCETARGET,
67+
ObjectIdGetDatum(typid));
68+
#endif
6069
for (i = 0; i < catlist->n_members; i++)
6170
{
6271
HeapTuple tuple = &catlist->members[i]->tuple;

0 commit comments

Comments
 (0)