diff --git a/Makefile b/Makefile index 482b176..b614f11 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ PG_CPPFLAGS = --std=c99 -I$(MONGO_PATH) -I$(LIBJSON) OBJS = connection.o option.o mongo_wrapper.o mongo_fdw.o mongo_query.o $(MONGO_OBJS) $(LIBJSON_OBJS) EXTENSION = mongo_fdw -DATA = mongo_fdw--1.0.sql +DATA = mongo_fdw--1.0.sql mongo_fdw--1.1.sql mongo_fdw--1.0--1.1.sql REGRESS = mongo_fdw REGRESS_OPTS = --load-extension=$(EXTENSION) diff --git a/README.md b/README.md index 48e9876..9a08624 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This [MongoDB][1] extension implements the PostgreSQL's Foreign Data Wrapper. -Please note that this version of mongo_fdw works with PostgreSQL and EDB Postgres Advanced Server 9.3, 9.4, 9.5 and 9.6. +Please note that this version of mongo_fdw works with PostgreSQL and EDB Postgres Advanced Server 9.3, 9.4, 9.5, 9.6 and 10. Installation ------------ @@ -176,6 +176,13 @@ EXPLAIN SELECT * FROM warehouse WHERE warehouse_id = 1; -- collect data distribution statistics` ANALYZE warehouse; +select mongo_fdw_version(); + mongo_fdw_version +------------------- + 50100 +(1 row) + + ``` Limitations diff --git a/mongo_fdw--1.0--1.1.sql b/mongo_fdw--1.0--1.1.sql new file mode 100644 index 0000000..781155d --- /dev/null +++ b/mongo_fdw--1.0--1.1.sql @@ -0,0 +1,6 @@ +/* mongo_fdw/mongo_fdw--1.0--1.1.sql */ + +CREATE OR REPLACE FUNCTION mongo_fdw_version() + RETURNS pg_catalog.int4 STRICT + AS 'MODULE_PATHNAME' LANGUAGE C; + diff --git a/mongo_fdw--1.1.sql b/mongo_fdw--1.1.sql new file mode 100644 index 0000000..38da196 --- /dev/null +++ b/mongo_fdw--1.1.sql @@ -0,0 +1,25 @@ +/* mongo_fdw/mongo_fdw--1.1.sql */ + +-- Portions Copyright © 2004-2014, EnterpriseDB Corporation. +-- Portions Copyright © 2012–2014 Citus Data, Inc. + +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION mongo_fdw" to load this file. \quit + +CREATE FUNCTION mongo_fdw_handler() +RETURNS fdw_handler +AS 'MODULE_PATHNAME' +LANGUAGE C STRICT; + +CREATE FUNCTION mongo_fdw_validator(text[], oid) +RETURNS void +AS 'MODULE_PATHNAME' +LANGUAGE C STRICT; + +CREATE FOREIGN DATA WRAPPER mongo_fdw + HANDLER mongo_fdw_handler + VALIDATOR mongo_fdw_validator; + +CREATE OR REPLACE FUNCTION mongo_fdw_version() + RETURNS pg_catalog.int4 STRICT + AS 'MODULE_PATHNAME' LANGUAGE C; diff --git a/mongo_fdw.c b/mongo_fdw.c index 97fd944..43862eb 100644 --- a/mongo_fdw.c +++ b/mongo_fdw.c @@ -69,6 +69,12 @@ #include "access/htup_details.h" #endif +/* + * In PG 9.5.1 the number will be 90501, + * our version is 5.1.0 so number will be 50100 + */ +#define CODE_VERSION 50100 + /* Local functions forward declarations */ static void MongoGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, @@ -164,6 +170,7 @@ static JsonSemAction nullSemAction = PG_MODULE_MAGIC; PG_FUNCTION_INFO_V1(mongo_fdw_handler); +PG_FUNCTION_INFO_V1(mongo_fdw_version); /* * Library load-time initalization, sets on_proc_exit() callback for @@ -2137,3 +2144,9 @@ MongoAcquireSampleRows(Relation relation, int errorLevel, return sampleRowCount; } + +Datum +mongo_fdw_version(PG_FUNCTION_ARGS) +{ + PG_RETURN_INT32(CODE_VERSION); +} diff --git a/mongo_fdw.control b/mongo_fdw.control index a457792..57dfad9 100644 --- a/mongo_fdw.control +++ b/mongo_fdw.control @@ -4,6 +4,6 @@ # Portions Copyright © 2012–2014 Citus Data, Inc. # comment = 'foreign data wrapper for MongoDB access' -default_version = '1.0' +default_version = '1.1' module_pathname = '$libdir/mongo_fdw' relocatable = true