From 3c5b1f524074768f1c84a2ded7bfad65c01b3228 Mon Sep 17 00:00:00 2001 From: Rushabh Lathia Date: Fri, 27 Sep 2019 10:21:41 +0530 Subject: [PATCH] Support PG/EPAS 12, Commit fixes the issues which caused compilation error when compiled against PG/EPAS 12. --- Makefile | 4 ++-- mongo_fdw.c | 15 +++++++++++++-- mongo_fdw.h | 4 +++- mongo_query.c | 9 +++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 16f2624..d7813ec 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/mongo_fdw.c b/mongo_fdw.c index 2d07473..9c23303 100644 --- a/mongo_fdw.c +++ b/mongo_fdw.c @@ -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" @@ -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" @@ -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" @@ -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); diff --git a/mongo_fdw.h b/mongo_fdw.h index d5dd1a7..623b0db 100644 --- a/mongo_fdw.h +++ b/mongo_fdw.h @@ -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" diff --git a/mongo_query.c b/mongo_query.c index cff6eeb..4efd61f 100644 --- a/mongo_query.c +++ b/mongo_query.c @@ -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"