Skip to content

Commit

Permalink
Support PG/EPAS 12.
Browse files Browse the repository at this point in the history
Earlier commit missed to change the Makefile.meta and .legacy
for the v12 support.  So this commit fix the same as well as
fix few other warning due to v12 API changes.
  • Loading branch information
rblathia committed Sep 27, 2019
1 parent 3c5b1f5 commit 272b293
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile.legacy
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
4 changes: 2 additions & 2 deletions Makefile.meta
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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
13 changes: 9 additions & 4 deletions mongo_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,6 @@ MongoAcquireSampleRows(Relation relation, int errorLevel,
bool *columnNulls = NULL;
Oid foreignTableId = InvalidOid;
TupleDesc tupleDescriptor = NULL;
Form_pg_attribute *attributesPtr = NULL;
AttrNumber columnCount = 0;
AttrNumber columnId = 0;
HTAB *columnMappingHash = NULL;
Expand All @@ -2035,16 +2034,22 @@ MongoAcquireSampleRows(Relation relation, int errorLevel,
/* create list of columns in the relation */
tupleDescriptor = RelationGetDescr(relation);
columnCount = tupleDescriptor->natts;
attributesPtr = tupleDescriptor->attrs;

for (columnId = 1; columnId <= columnCount; columnId++)
{
Var *column = (Var *) palloc0(sizeof(Var));
#if PG_VERSION_NUM >= 120000
Form_pg_attribute attr = TupleDescAttr(tupleDescriptor, columnId-1);

column->varattno = columnId;
column->vartype = attr->atttypid;
column->vartypmod = attr->atttypmod;
#else
/* only assign required fields for column mapping hash */
column->varattno = columnId;
column->vartype = attributesPtr[columnId-1]->atttypid;
column->vartypmod = attributesPtr[columnId-1]->atttypmod;
column->vartype = tupleDescriptor->attrs[columnId-1]->atttypid;
column->vartypmod = tupleDescriptor->attrs[columnId-1]->atttypmod;
#endif

columnList = lappend(columnList, column);
}
Expand Down

0 comments on commit 272b293

Please sign in to comment.