Skip to content

Commit

Permalink
Merge pull request #89 from CartoDB/tupleDesc
Browse files Browse the repository at this point in the history
Use TupleDescAttr instead of its internal representation
  • Loading branch information
Algunenano authored Oct 29, 2018
2 parents 9569b46 + 3299f56 commit 41743d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ test/expected/*_installation*
test/config/*.config
!test/config/config.sample.config
test/config/*.tar

# JIT
**/*.bc
19 changes: 9 additions & 10 deletions odbc_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
#include "optimizer/restrictinfo.h"
#include "optimizer/planmain.h"

#include "access/tupdesc.h"

/* TupleDescAttr was backported into 9.5.9 and 9.6.5 but we support any 9.5.X */
#ifndef TupleDescAttr
#define TupleDescAttr(tupdesc, i) ((tupdesc)->attrs[(i)])
#endif

#include "executor/spi.h"

#include <stdio.h>
Expand Down Expand Up @@ -1129,11 +1136,7 @@ odbcGetQual(Node *node, TupleDesc tupdesc, List *col_mapping_list, char **key, c
StringInfoData buf;
initStringInfo(&buf);
/* And get the column and value... */
#if PG_VERSION_NUM >= 110000
*key = NameStr(tupdesc->attrs[varattno - 1].attname);
#else
*key = NameStr(tupdesc->attrs[varattno - 1]->attname);
#endif
*key = NameStr(TupleDescAttr(tupdesc, varattno - 1)->attname);

if (((Const *) right)->consttype == PROCID_TEXTCONST)
*value = TextDatumGetCString(((Const *) right)->constvalue);
Expand Down Expand Up @@ -1365,11 +1368,7 @@ odbcBeginForeignScan(ForeignScanState *node, int eflags)

/* retrieve the column name */
initStringInfo(&col);
#if PG_VERSION_NUM >= 110000
appendStringInfo(&col, "%s", NameStr(rel->rd_att->attrs[i].attname));
#else
appendStringInfo(&col, "%s", NameStr(rel->rd_att->attrs[i]->attname));
#endif
appendStringInfo(&col, "%s", NameStr(TupleDescAttr(rel->rd_att,i)->attname));
mapped = false;

/* check if the column name is mapping to a different name in remote table */
Expand Down

0 comments on commit 41743d3

Please sign in to comment.