Skip to content

Commit

Permalink
Remove support for PG version 12 (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanzimanyi committed Sep 5, 2024
1 parent 288c6e8 commit 3a0e715
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 199 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pgversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
strategy:
fail-fast: false
matrix:
psql: [12,13,14,15,16]
psql: [13,14,15,16]
postgis: [3]
os: [ubuntu-latest]
coverage: [0]
include:
- psql: 15
- psql: 16
postgis: 3
os: ubuntu-latest
coverage: 1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Requirements

* Linux (other UNIX-like systems may work, but remain untested)
* CMake >= 3.7
* PostgreSQL >= 12
* PostgreSQL >= 13
* PostGIS >= 3.0
* GEOS >= 3.8
* PROJ4 >= 6.1
Expand Down
8 changes: 2 additions & 6 deletions meos/src/general/meos_catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@
#include <limits.h>
/* PostgreSQL */
#include <postgres.h>
#if POSTGRESQL_VERSION_NUMBER >= 130000
#include <common/hashfn.h>
#else
#include <access/hash.h>
#endif
#include <common/hashfn.h>
/* MEOS */
#include <meos.h>
#include "general/doublen.h"
Expand Down Expand Up @@ -189,7 +185,7 @@ static const char *MEOS_TEMPSUBTYPE_NAMES[] =

/**
* @brief Global constant array containing the interpolation names
* @brief Global constant array containing the interpolation names
* corresponding to the enumeration interpType defined in file `meos_catalog.h`
* @note The names are in lowercase since they are used in error messages
*/
Expand Down
108 changes: 6 additions & 102 deletions meos/src/general/pg_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@
#include <utils/datetime.h>
#include <utils/float.h>
#include "utils/formatting.h"
#if POSTGRESQL_VERSION_NUMBER >= 130000
#include <common/hashfn.h>
#else
#include <access/hash.h>
#endif
#include <common/hashfn.h>
#if POSTGRESQL_VERSION_NUMBER >= 160000
#include "varatt.h"
#endif
Expand Down Expand Up @@ -82,10 +78,8 @@

/* Definition in numutils.c */
extern int32 pg_strtoint32(const char *s);
#if POSTGRESQL_VERSION_NUMBER >= 130000
extern int pg_ultoa_n(uint32 value, char *a);
extern int pg_ulltoa_n(uint64 l, char *a);
#endif /* POSTGRESQL_VERSION_NUMBER >= 130000 */
extern int pg_ultoa_n(uint32 value, char *a);
extern int pg_ulltoa_n(uint64 l, char *a);

/* To avoid including varlena.h */
extern int varstr_cmp(const char *arg1, int len1, const char *arg2, int len2,
Expand Down Expand Up @@ -248,7 +242,6 @@ int4_in(const char *str)
return pg_strtoint32(str);
}

#if POSTGRESQL_VERSION_NUMBER >= 130000
/*
* pg_ltoa: converts a signed 32-bit integer to its string representation and
* returns strlen(a).
Expand All @@ -275,7 +268,6 @@ mobdb_ltoa(int32 value, char *a)
a[len] = '\0';
return len;
}
#endif /* POSTGRESQL_VERSION_NUMBER >= 130000 */

/**
* @brief Return a string from an int4
Expand All @@ -285,11 +277,7 @@ char *
int4_out(int32 val)
{
char *result = palloc(MAXINT4LEN); /* sign, 10 digits, '\0' */
#if POSTGRESQL_VERSION_NUMBER >= 130000
mobdb_ltoa(val, result);
#else
snprintf(result, MAXINT4LEN, "%d", val);
#endif
return result;
}

Expand Down Expand Up @@ -317,7 +305,6 @@ int8_in(const char *str)
return result;
}

#if POSTGRESQL_VERSION_NUMBER >= 130000
/*
* pg_lltoa: converts a signed 64-bit integer to its string representation and
* returns strlen(a).
Expand All @@ -344,7 +331,6 @@ mobdb_lltoa(int64 value, char *a)
a[len] = '\0';
return len;
}
#endif /* POSTGRESQL_VERSION_NUMBER >= 130000 */

/**
* @brief Return a string from an @p int8
Expand All @@ -354,7 +340,6 @@ char *
int8_out(int64 val)
{
char *result;
#if POSTGRESQL_VERSION_NUMBER >= 130000
char buf[MAXINT8LEN + 1];
int len = mobdb_lltoa(val, buf) + 1;
/*
Expand All @@ -363,10 +348,6 @@ int8_out(int64 val)
*/
result = palloc(len);
memcpy(result, buf, len);
#else
result = palloc(MAXINT8LEN + 1);
snprintf(result, MAXINT8LEN + 1, "%ld", val);
#endif
return result;
}

Expand Down Expand Up @@ -799,7 +780,7 @@ pg_date_out(DateADT d)
}
#endif /* MEOS */

#if MEOS || POSTGRESQL_VERSION_NUMBER < 130000
#if MEOS
/*
* Promote date to timestamp with time zone.
*
Expand Down Expand Up @@ -884,7 +865,7 @@ date2timestamptz_opt_overflow(DateADT dateVal, int *overflow)
}
return result;
}
#endif /* MEOS || POSTGRESQL_VERSION_NUMBER < 130000 */
#endif /* MEOS */

/**
* @ingroup meos_pg_types
Expand Down Expand Up @@ -1953,7 +1934,7 @@ Interval *
add_interval_interval(const Interval *interv1, const Interval *interv2)
{
/* Ensure validity of the arguments */
if (! ensure_not_null((void *) interv1) ||
if (! ensure_not_null((void *) interv1) ||
! ensure_not_null((void *) interv2))
return NULL;

Expand Down Expand Up @@ -2495,83 +2476,6 @@ datum_initcap(Datum value)
* Functions adapted from hashfn.h and hashfn.c
*****************************************************************************/

#if POSTGRESQL_VERSION_NUMBER < 130000

/* Rotate a uint32 value left by k bits - note multiple evaluation! */
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))

#define mix(a,b,c) \
{ \
a -= c; a ^= rot(c, 4); c += b; \
b -= a; b ^= rot(a, 6); a += c; \
c -= b; c ^= rot(b, 8); b += a; \
a -= c; a ^= rot(c,16); c += b; \
b -= a; b ^= rot(a,19); a += c; \
c -= b; c ^= rot(b, 4); b += a; \
}

#define final(a,b,c) \
{ \
c ^= b; c -= rot(b,14); \
a ^= c; a -= rot(c,11); \
b ^= a; b -= rot(a,25); \
c ^= b; c -= rot(b,16); \
a ^= c; a -= rot(c, 4); \
b ^= a; b -= rot(a,14); \
c ^= b; c -= rot(b,24); \
}

/*
* hash_bytes_uint32() -- hash a 32-bit value to a 32-bit value
*
* This has the same result as
* hash_bytes(&k, sizeof(uint32))
* but is faster and doesn't force the caller to store k into memory.
*/
uint32
hash_bytes_uint32(uint32 k)
{
uint32 a,
b,
c;

a = b = c = 0x9e3779b9 + (uint32) sizeof(uint32) + 3923095;
a += k;

final(a, b, c);

/* report the result */
return c;
}

/*
* hash_bytes_uint32_extended() -- hash 32-bit value to 64-bit value, with seed
*
* Like hash_bytes_uint32, this is a convenience function.
*/
uint64
hash_bytes_uint32_extended(uint32 k, uint64 seed)
{
uint32 a, b, c;
a = b = c = 0x9e3779b9 + (uint32) sizeof(uint32) + 3923095;

if (seed != 0)
{
a += (uint32) (seed >> 32);
b += (uint32) seed;
mix(a, b, c);
}

a += k;

final(a, b, c);

/* report the result */
return ((uint64) b << 32) | c;
}

#endif /* POSTGRESQL_VERSION_NUMBER < 130000 */

/**
* @brief Get the 32-bit hash value of an int64 value.
* @note PostgreSQL function: @p hashint8(PG_FUNCTION_ARGS)
Expand Down
6 changes: 1 addition & 5 deletions meos/src/general/span.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@
#include <limits.h>
/* PostgreSQL */
#include <utils/timestamp.h>
#if POSTGRESQL_VERSION_NUMBER >= 130000
#include <common/hashfn.h>
#else
#include <access/hash.h>
#endif
#include <common/hashfn.h>
/* MEOS */
#include <meos.h>
#include <meos_internal.h>
Expand Down
18 changes: 7 additions & 11 deletions meos/src/general/temporal_restrict.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@
#include <postgres.h>
#include <utils/float.h>
#include <utils/timestamp.h>
#if POSTGRESQL_VERSION_NUMBER >= 130000
#include <common/hashfn.h>
#else
#include <access/hash.h>
#endif
#include <common/hashfn.h>
#if POSTGRESQL_VERSION_NUMBER >= 160000
#include "varatt.h"
#endif
Expand Down Expand Up @@ -291,7 +287,7 @@ tnumber_restrict_span(const Temporal *temp, const Span *s, bool atfunc)
assert(temptype_subtype(temp->subtype));
switch (temp->subtype)
{
case TINSTANT:
case TINSTANT:
return (Temporal *) tnumberinst_restrict_span((TInstant *) temp,
s, atfunc);
case TSEQUENCE:
Expand Down Expand Up @@ -505,7 +501,7 @@ temporal_restrict_tstzset(const Temporal *temp, const Set *s, bool atfunc)
Temporal *
temporal_restrict_tstzspan(const Temporal *temp, const Span *s, bool atfunc)
{
assert(temp); assert(s);
assert(temp); assert(s);
assert(temptype_subtype(temp->subtype));
switch (temp->subtype)
{
Expand Down Expand Up @@ -1791,7 +1787,7 @@ bool
tdiscseq_value_at_timestamptz(const TSequence *seq, TimestampTz t,
Datum *result)
{
assert(seq); assert(result);
assert(seq); assert(result);
assert(MEOS_FLAGS_GET_INTERP(seq->flags) == DISCRETE);
int loc = tdiscseq_find_timestamptz(seq, t);
if (loc < 0)
Expand Down Expand Up @@ -2207,7 +2203,7 @@ tcontseq_at_tstzset(const TSequence *seq, const Set *s)
assert(seq); assert(s);
assert(MEOS_FLAGS_GET_INTERP(seq->flags) != DISCRETE);

TInstant *inst;
TInstant *inst;

/* Singleton timestamp set */
if (s->count == 1)
Expand Down Expand Up @@ -2391,7 +2387,7 @@ tcontseq_minus_tstzset_iter(const TSequence *seq, const Set *s,
TSequenceSet *
tcontseq_minus_tstzset(const TSequence *seq, const Set *s)
{
assert(seq); assert(s);
assert(seq); assert(s);
assert(MEOS_FLAGS_GET_INTERP(seq->flags) != DISCRETE);
TSequence **sequences = palloc0(sizeof(TSequence *) * (s->count + 1));
int count = tcontseq_minus_tstzset_iter(seq, s, sequences);
Expand Down Expand Up @@ -2568,7 +2564,7 @@ int
tcontseq_at_tstzspanset1(const TSequence *seq, const SpanSet *ss,
TSequence **result)
{
assert(seq); assert(ss); assert(result);
assert(seq); assert(ss); assert(result);
assert(MEOS_FLAGS_GET_INTERP(seq->flags) != DISCRETE);

/* Singleton span set */
Expand Down
6 changes: 1 addition & 5 deletions meos/src/general/tinstant.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@
/* PostgreSQL */
#include <postgres.h>
#include <utils/timestamp.h>
#if POSTGRESQL_VERSION_NUMBER >= 130000
#include <common/hashfn.h>
#else
#include <access/hash.h>
#endif
#include <common/hashfn.h>
#if POSTGRESQL_VERSION_NUMBER >= 160000
#include "varatt.h"
#endif
Expand Down
6 changes: 1 addition & 5 deletions meos/src/general/tsequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@
#include <postgres.h>
#include <utils/float.h>
#include <utils/timestamp.h>
#if POSTGRESQL_VERSION_NUMBER >= 130000
#include <common/hashfn.h>
#else
#include "general/pg_types.h"
#endif
#include <common/hashfn.h>
#if POSTGRESQL_VERSION_NUMBER >= 160000
#include "varatt.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion mobilitydb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ endif()
#-------------------------------------

# Find PostgreSQL
set(PG_MIN_MAJOR_VERSION "12")
set(PG_MIN_MAJOR_VERSION "13")
set(PG_MAX_MAJOR_VERSION "14")
find_package(POSTGRESQL ${PG_MIN_MAJOR_VERSION} REQUIRED)
if(NOT POSTGRES_VERSION VERSION_LESS PG_MAX_MAJOR_VERSION)
Expand Down
Loading

0 comments on commit 3a0e715

Please sign in to comment.