Skip to content

Commit

Permalink
Fix for issue #99, Prepare to release for 5.1
Browse files Browse the repository at this point in the history
    Change version in control file
    Add sql file for 1.1 & sql file to upgrade from 1.0 to 1.1
    Add new sql files in Makefile
    Add a function to get .so version
            select mongo_fdw_version();
             mongo_fdw_version
            -------------------
                         50100
            (1 row)
  • Loading branch information
gabbasb committed Mar 13, 2018
1 parent ba88931 commit 84d1638
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions mongo_fdw--1.0--1.1.sql
Original file line number Diff line number Diff line change
@@ -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;

25 changes: 25 additions & 0 deletions mongo_fdw--1.1.sql
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 13 additions & 0 deletions mongo_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2137,3 +2144,9 @@ MongoAcquireSampleRows(Relation relation, int errorLevel,

return sampleRowCount;
}

Datum
mongo_fdw_version(PG_FUNCTION_ARGS)
{
PG_RETURN_INT32(CODE_VERSION);
}
2 changes: 1 addition & 1 deletion mongo_fdw.control
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 84d1638

Please sign in to comment.