DBZ-445 Made postGIS support optional.

pull/9/head
Danila Kiver 2017-11-07 18:26:20 +03:00
parent d08a75593c
commit 604aa6fe3b
2 changed files with 16 additions and 2 deletions

View File

@ -4,8 +4,13 @@ EXTENSION = decoderbufs
PROTOBUF_C_CFLAGS = $(shell pkg-config --cflags 'libprotobuf-c >= 1.0.0') PROTOBUF_C_CFLAGS = $(shell pkg-config --cflags 'libprotobuf-c >= 1.0.0')
PROTOBUF_C_LDFLAGS = $(shell pkg-config --libs 'libprotobuf-c >= 1.0.0') PROTOBUF_C_LDFLAGS = $(shell pkg-config --libs 'libprotobuf-c >= 1.0.0')
PG_CPPFLAGS += -std=c11 $(PROTOBUF_C_CFLAGS) -I/usr/local/include ifneq ($(USE_POSTGIS),false)
SHLIB_LINK += $(PROTOBUF_C_LDFLAGS) -L/usr/local/lib -llwgeom C_PARAMS = -DUSE_POSTGIS
POSTGIS_C_LDFLAGS = -L/usr/local/lib -llwgeom
endif
PG_CPPFLAGS += -std=c11 $(PROTOBUF_C_CFLAGS) -I/usr/local/include $(C_PARAMS)
SHLIB_LINK += $(PROTOBUF_C_LDFLAGS) $(POSTGIS_C_LDFLAGS)
OBJS = src/decoderbufs.o src/proto/pg_logicaldec.pb-c.o OBJS = src/decoderbufs.o src/proto/pg_logicaldec.pb-c.o

View File

@ -60,9 +60,11 @@
#error Expecting timestamps to be represented as integers, not as floating-point. #error Expecting timestamps to be represented as integers, not as floating-point.
#endif #endif
#ifdef USE_POSTGIS
/* POSTGIS version define so it doesn't redef macros */ /* POSTGIS version define so it doesn't redef macros */
#define POSTGIS_PGSQL_VERSION 94 #define POSTGIS_PGSQL_VERSION 94
#include "liblwgeom.h" #include "liblwgeom.h"
#endif
PG_MODULE_MAGIC; PG_MODULE_MAGIC;
@ -170,6 +172,7 @@ static void pg_decode_shutdown(LogicalDecodingContext *ctx) {
/* BEGIN callback */ /* BEGIN callback */
static void pg_decode_begin_txn(LogicalDecodingContext *ctx, static void pg_decode_begin_txn(LogicalDecodingContext *ctx,
ReorderBufferTXN *txn) { ReorderBufferTXN *txn) {
#ifdef USE_POSTGIS
// set PostGIS geometry type id (these are dynamic) // set PostGIS geometry type id (these are dynamic)
// TODO: Figure out how to make sure we get the typid's from postgis extension namespace // TODO: Figure out how to make sure we get the typid's from postgis extension namespace
if (geometry_oid == InvalidOid) { if (geometry_oid == InvalidOid) {
@ -184,6 +187,7 @@ static void pg_decode_begin_txn(LogicalDecodingContext *ctx,
elog(DEBUG1, "PostGIS geometry type detected: %u", geography_oid); elog(DEBUG1, "PostGIS geometry type detected: %u", geography_oid);
} }
} }
#endif
} }
/* COMMIT callback */ /* COMMIT callback */
@ -366,6 +370,7 @@ static double numeric_to_double_no_overflow(Numeric num) {
static bool geography_point_as_decoderbufs_point(Datum datum, static bool geography_point_as_decoderbufs_point(Datum datum,
Decoderbufs__Point *p) { Decoderbufs__Point *p) {
#ifdef USE_POSTGIS
GSERIALIZED *geom; GSERIALIZED *geom;
LWGEOM *lwgeom; LWGEOM *lwgeom;
LWPOINT *point = NULL; LWPOINT *point = NULL;
@ -393,6 +398,10 @@ static bool geography_point_as_decoderbufs_point(Datum datum,
} }
return true; return true;
#else
elog(DEBUG1, "PostGIS support is off, recompile decoderbufs with USE_POSTGIS option!");
return false;
#endif
} }
/* set a datum value based on its OID specified by typid */ /* set a datum value based on its OID specified by typid */