Skip to content

Commit

Permalink
Fix v15 build (#90)
Browse files Browse the repository at this point in the history
* Fix creation of the "custom_objects_cache" hash table

The hash table was declared as hashing strings, but is used for OIDs.
This bug was brought to light by PostgreSQL commit b3817f5f77, which
made it compulsory to specify the kind of objects that was hashed.

* Remove reference to the "Value" node

PostgreSQL commit 639a86e36a removed "Value", so use "Node" instead.

* Adapt to PostgreSQL commit a49d081235

That commit got rid of FirstBootstrapObjectId and
introduced FirstUnpinnedObjectId instead.
  • Loading branch information
laurenz committed Sep 29, 2022
1 parent ff6cc49 commit 9b682a5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/custom_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ create_custom_objects_cache(void)
ctl.keysize = sizeof(Oid);
ctl.entrysize = sizeof(CustomObjectDef);

return hash_create("clickhouse_fdw custom functions", 20, &ctl, HASH_ELEM);
return hash_create("clickhouse_fdw custom functions", 20, &ctl, HASH_ELEM | HASH_BLOBS);
}

static void
Expand Down
4 changes: 4 additions & 0 deletions src/include/clickhousedb_fdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "nodes/pathnodes.h"
#endif

#if PG_VERSION_NUM < 150000
#define FirstUnpinnedObjectId FirstBootstrapObjectId
#endif

/* libclickhouse_link.c */
typedef struct ch_cursor ch_cursor;
typedef struct ch_cursor
Expand Down
2 changes: 1 addition & 1 deletion src/pglink.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ chfdw_construct_create_tables(ImportForeignSchemaStmt *stmt, ForeignServer *serv
appendStringInfoString(&buf, " OPTIONS (");
foreach(lc, options)
{
Value *val = lfirst(lc);
Node *val = lfirst(lc);
if (IsA(val, Integer))
{
if (!first)
Expand Down
4 changes: 2 additions & 2 deletions src/shipable.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ lookup_shippable(Oid objectId, Oid classId, CHFdwRelationInfo *fpinfo)
/*
* Return true if given object is one of PostgreSQL's built-in objects.
*
* We use FirstBootstrapObjectId as the cutoff, so that we only consider
* We use FirstUnpinnedObjectId as the cutoff, so that we only consider
* objects with hand-assigned OIDs to be "built in", not for instance any
* function or type defined in the information_schema.
*
Expand All @@ -151,7 +151,7 @@ lookup_shippable(Oid objectId, Oid classId, CHFdwRelationInfo *fpinfo)
bool
chfdw_is_builtin(Oid objectId)
{
return (objectId < FirstBootstrapObjectId);
return (objectId < FirstUnpinnedObjectId);
}

/*
Expand Down

0 comments on commit 9b682a5

Please sign in to comment.