Skip to content

Commit

Permalink
Support PG/EPAS 12,
Browse files Browse the repository at this point in the history
Commit fixes the issues which caused compilation error when compiled
against PG/EPAS 12.
  • Loading branch information
rblathia committed Sep 27, 2019
1 parent 5fe371a commit 3c5b1f5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ ifndef MAJORVERSION
MAJORVERSION := $(basename $(VERSION))
endif

ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10.0 11.0))
$(error PostgreSQL 9.3, 9.4, 9.5, 9.6 10.0 or 11.0 is required to compile this extension)
ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10.0 11.0 12.0))
$(error PostgreSQL 9.3, 9.4, 9.5, 9.6 10.0 11.0 or 12.0 is required to compile this extension)
endif
15 changes: 13 additions & 2 deletions mongo_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "mongo_query.h"

#include "access/reloptions.h"
#if PG_VERSION_NUM >= 120000
#include "access/table.h"
#endif
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "commands/explain.h"
Expand All @@ -30,6 +33,9 @@
#include "foreign/foreign.h"
#include "nodes/makefuncs.h"
#include "optimizer/cost.h"
#if PG_VERSION_NUM >= 120000
#include "optimizer/optimizer.h"
#endif
#include "optimizer/pathnode.h"
#include "optimizer/plancat.h"
#include "optimizer/planmain.h"
Expand Down Expand Up @@ -57,7 +63,9 @@
#include "optimizer/planmain.h"
#include "optimizer/prep.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/var.h"
#if PG_VERSION_NUM < 120000
#include "optimizer/var.h"
#endif
#include "parser/parsetree.h"
#include "utils/builtins.h"
#include "utils/guc.h"
Expand Down Expand Up @@ -646,8 +654,11 @@ MongoPlanForeignModify(PlannerInfo *root,
* Core code already has some lock on each rel being planned, so we can
* use NoLock here.
*/
#if PG_VERSION_NUM < 120000
rel = heap_open(rte->relid, NoLock);

#else
rel = table_open(rte->relid, NoLock);
#endif
if (operation == CMD_INSERT)
{
TupleDesc tupdesc = RelationGetDescr(rel);
Expand Down
4 changes: 3 additions & 1 deletion mongo_fdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#include "catalog/pg_foreign_table.h"
#include "utils/datetime.h"
#include "nodes/pg_list.h"
#include "nodes/relation.h"
#if PG_VERSION_NUM < 120000
#include "nodes/relation.h"
#endif
#include "utils/timestamp.h"
#include "access/reloptions.h"
#include "catalog/pg_type.h"
Expand Down
9 changes: 7 additions & 2 deletions mongo_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@

#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/relation.h"
#include "optimizer/var.h"
#if PG_VERSION_NUM < 120000
#include "nodes/relation.h"
#include "optimizer/var.h"
#endif
#if PG_VERSION_NUM >= 120000
#include "optimizer/optimizer.h"
#endif
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/date.h"
Expand Down

1 comment on commit 3c5b1f5

@mithuncy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think heap_close(rel, NoLock); can also be changed to table_close similar to changes about heap_open()

Please sign in to comment.