Skip to content

Commit

Permalink
Adapt parquet_fdw for postgres 12
Browse files Browse the repository at this point in the history
  • Loading branch information
zilder committed Oct 23, 2019
1 parent 911ae69 commit b7241d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion parquet_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ parquet_fdw_validator(PG_FUNCTION_ARGS)

if (stat(defGetString(def), &stat_buf) != 0)
{
int e = errno;

ereport(ERROR,
(errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
errmsg("parquet_fdw: %s", strerror(errno))));
errmsg("parquet_fdw: %s", strerror(e))));
}
filename_provided = true;
}
Expand Down
22 changes: 19 additions & 3 deletions parquet_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ extern "C"
#include "nodes/execnodes.h"
#include "nodes/nodeFuncs.h"
#include "nodes/makefuncs.h"
#include "nodes/relation.h"
#include "optimizer/cost.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/var.h"
#include "parser/parse_coerce.h"
#include "parser/parse_oper.h"
#include "utils/builtins.h"
Expand All @@ -48,6 +46,15 @@ extern "C"
#include "utils/rel.h"
#include "utils/timestamp.h"
#include "utils/typcache.h"

#if PG_VERSION_NUM < 120000
#include "nodes/relation.h"
#include "optimizer/var.h"
#else
#include "access/table.h"
#include "access/relation.h"
#include "optimizer/optimizer.h"
#endif
}

#define SEGMENT_SIZE (1024 * 1024)
Expand Down Expand Up @@ -1663,7 +1670,12 @@ parquetAcquireSampleRowsFunc(Relation relation, int elevel,
for (int i = 0; i < meta->num_row_groups(); ++i)
festate->rowgroups.push_back(i);

#if PG_VERSION_NUM < 120000
slot = MakeSingleTupleTableSlot(tupleDesc);
#else
slot = MakeSingleTupleTableSlot(tupleDesc, &TTSOpsHeapTuple);
#endif

initialize_castfuncs(festate, tupleDesc);

while (true)
Expand Down Expand Up @@ -1985,9 +1997,13 @@ parquetImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)

d = AllocateDir(stmt->remote_schema);
if (!d)
{
int e = errno;

elog(ERROR, "parquet_fdw: failed to open directory '%s': %s",
stmt->remote_schema,
strerror(errno));
strerror(e));
}

while ((f = readdir(d)) != NULL)
{
Expand Down

0 comments on commit b7241d7

Please sign in to comment.