Skip to content

Commit

Permalink
PostgreSQL 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mochizk committed Dec 5, 2018
1 parent 7930e45 commit 38dcc0b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ include $(PGXS)
ifndef MAJORVERSION
MAJORVERSION := $(basename $(VERSION))
endif
ifeq (,$(findstring $(MAJORVERSION), 9.3 9.4 9.5 9.6 10))
$(error PostgreSQL 9.3, 9.4, 9.5, 9.6 or 10 is required to compile this extension)
ifeq (,$(findstring $(MAJORVERSION), 9.6 10 11))
$(error PostgreSQL 9.6, 10 or 11 is required to compile this extension)
endif

else
Expand Down
16 changes: 11 additions & 5 deletions deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ influxdb_deparse_target_list(StringInfo buf,
*retrieved_attrs = NIL;
for (i = 1; i <= tupdesc->natts; i++)
{
Form_pg_attribute attr = tupdesc->attrs[i - 1];
Form_pg_attribute attr = TupleDescAttr(tupdesc, i - 1);

/* Ignore dropped attributes. */
if (attr->attisdropped)
Expand Down Expand Up @@ -1243,8 +1243,11 @@ influxdb_get_column_ref(StringInfo buf, int varno, int varattno, Oid vartype,
* option, use attribute name.
*/
if (colname == NULL)
colname = get_relid_attribute_name(rte->relid, varattno);

colname = get_attname(rte->relid, varattno
#if (PG_VERSION_NUM >= 110000)
,false
#endif
);
return colname;
}

Expand Down Expand Up @@ -1288,8 +1291,11 @@ influxdb_deparse_column_ref(StringInfo buf, int varno, int varattno, Oid vartype
* option, use attribute name.
*/
if (colname == NULL)
colname = get_relid_attribute_name(rte->relid, varattno);

colname = get_attname(rte->relid, varattno
#if (PG_VERSION_NUM >= 110000)
,false
#endif
);
if (convert && vartype == BOOLOID)
{
appendStringInfo(buf, "(%s=true)", influxdb_quote_identifier(colname, QUOTE));
Expand Down
26 changes: 16 additions & 10 deletions influxdb_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,15 @@ static bool influxdbAnalyzeForeignTable(Relation relation,
static List *influxdbImportForeignSchema(ImportForeignSchemaStmt *stmt,
Oid serverOid);

static void influxdbGetForeignUpperPaths(PlannerInfo *root,
static void
influxdbGetForeignUpperPaths(PlannerInfo *root,
UpperRelationKind stage,
RelOptInfo *input_rel,
RelOptInfo *output_rel);
RelOptInfo *output_rel
#if (PG_VERSION_NUM >= 110000)
,void *extra
#endif
);


static void influxdb_to_pg_type(StringInfo str, char *typname);
Expand Down Expand Up @@ -738,9 +743,7 @@ influxdbBeginForeignScan(ForeignScanState *node, int eflags)

festate->temp_cxt = AllocSetContextCreate(estate->es_query_cxt,
"influxdb_fdw temporary data",
ALLOCSET_SMALL_MINSIZE,
ALLOCSET_SMALL_INITSIZE,
ALLOCSET_SMALL_MAXSIZE);
ALLOCSET_SMALL_SIZES);


/* Prepare for output conversion of parameters used in remote query. */
Expand Down Expand Up @@ -774,15 +777,15 @@ make_tuple_from_result_row(InfluxDBRow * result_row,
foreach(lc, retrieved_attrs)
{
int attnum = lfirst_int(lc) - 1;
Oid pgtype = tupleDescriptor->attrs[attnum]->atttypid;
int32 pgtypmod = tupleDescriptor->attrs[attnum]->atttypmod;
Oid pgtype = TupleDescAttr(tupleDescriptor, attnum)->atttypid;
int32 pgtypmod = TupleDescAttr(tupleDescriptor, attnum)->atttypmod;
int attr_idx = 0;

/*
* Get from first column of result set if attribute name is time
* column
*/
if (INFLUXDB_IS_TIME_COLUMN(tupleDescriptor->attrs[attnum]->attname.data))
if (INFLUXDB_IS_TIME_COLUMN(TupleDescAttr(tupleDescriptor, attnum)->attname.data))
{
attr_idx = 0;
}
Expand All @@ -798,7 +801,6 @@ make_tuple_from_result_row(InfluxDBRow * result_row,
row[attnum] = influxdb_convert_to_pg(pgtype, pgtypmod,
result_row->tuple, attr_idx);
}
elog(DEBUG2, "influxdb_fdw : make_tuple_from_result_row %d %d %d %d %s", attid, pgtype, attnum, attr_idx, tupleDescriptor->attrs[attnum]->attname.data);
}
}

Expand Down Expand Up @@ -1365,7 +1367,11 @@ foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel)
*/
static void
influxdbGetForeignUpperPaths(PlannerInfo *root, UpperRelationKind stage,
RelOptInfo *input_rel, RelOptInfo *output_rel)
RelOptInfo *input_rel, RelOptInfo *output_rel
#if (PG_VERSION_NUM >= 110000)
,void *extra
#endif
)
{
InfluxDBFdwRelationInfo *fpinfo;

Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export USE_PGXS=1
./init.sh && make && make install && make installcheck
./init.sh && make clean && make && make install && make installcheck

0 comments on commit 38dcc0b

Please sign in to comment.