Skip to content

Commit

Permalink
Support REL_11_STABLE.
Browse files Browse the repository at this point in the history
get_relid_attribute_name() is gone and is replaced by
get_attname().

ExplainPropertyFloat() requires a new "unit" argument.

Move old-style tuple descriptor usage and access to its attributes
to the "new" TupleDescAttr() macro. We are encouraged to do so since a while.

Since TupleDescAttr() is backpatched to 9.3 and appears first in 9.3.19,
we need to make sure we use the correct definition depending on the
PostgreSQL version we build against.

This makes it important to use a correct build of the informix_fdw.so
library against 9.3 instances.
  • Loading branch information
Bernd Helmle committed Aug 23, 2018
1 parent 3afb89d commit d4b4ce2
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions ifx_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,38 @@ PG_FUNCTION_INFO_V1(ifxCloseConnection);
#define RTE_UPDATED_COLS(a) (a)->modifiedCols
#endif

/*
* get_relid_attribute_name() is dead as of REL_11_STABLE
* (see commit 8237f27b504ff1d1e2da7ae4c81a7f72ea0e0e3e in the
* pg repository). Use get_attname() instead. Wrap this into a
* compatibility macro, to safe further ifdef's...
*/
#if PG_VERSION_NUM >= 110000
#define pg_attname_by_relid(relid, attnum, missing_ok) \
get_attname((relid), (attnum), (missing_ok))
#else
#define pg_attname_by_relid(relid, attnum, missing_ok) \
get_relid_attribute_name((relid), (attnum))
#endif

/*
* PostgreSQL 9.3 introduced TupleDescrAttr() to access
* attributes stored in a tuple descriptor. Use that instead
* of directly accessing the tupdesc attribute array, if available.
*
* CAUTION: This macro was introduced in REL9_3_19 with
* commit 5b286cae3cc1c43d6eedf6cf1181d41f653c6a93,
* so we cannot make it available for all previous
* versions for REL9_3_STABLE.
*/
#if PG_VERSION_NUM >= 90319
#define TUPDESC_GET_ATTR(desc, index) \
TupleDescAttr((desc), (index))
#else
#define TUPDESC_GET_ATTR(desc, index) \
((desc)->attrs[(index)])
#endif

/*******************************************************************************
* FDW helper functions.
*/
Expand Down Expand Up @@ -1176,7 +1208,7 @@ char *dispatchColumnIdentifier(int varno, int varattno, PlannerInfo *root)
* was found.
*/
if (ident == NULL)
ident = get_relid_attribute_name(rte->relid, varattno);
ident = pg_attname_by_relid(rte->relid, varattno, false);

return ident;
}
Expand Down Expand Up @@ -1889,7 +1921,7 @@ static void ifxPrepareParamsForModify(IfxFdwExecutionState *state,
*/
for (attnum = 1; attnum <= tupdesc->natts; attnum++)
{
Form_pg_attribute pgattr = tupdesc->attrs[attnum - 1];
Form_pg_attribute pgattr = TUPDESC_GET_ATTR(tupdesc, attnum - 1);

state->affectedAttrNums = lappend_int(state->affectedAttrNums,
pgattr->attnum);
Expand Down Expand Up @@ -5165,7 +5197,11 @@ ifxExplainForeignScan(ForeignScanState *node, ExplainState *es)
/* Give some possibly useful info about startup costs */
if (es->costs)
{
#if PG_VERSION_NUM >= 110000
ExplainPropertyFloat("Informix costs", NULL, planData.costs, 2, es);
#else
ExplainPropertyFloat("Informix costs", planData.costs, 2, es);
#endif

/* print planned foreign query */
ExplainPropertyText("Informix query", festate->stmt_info.query, es);
Expand Down

0 comments on commit d4b4ce2

Please sign in to comment.