Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.
Merged

PG17 #115

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ jobs:
strategy:
fail-fast: false
matrix:
pg: [14, 13, 12, 11]
pg: [17, 16, 15, 14, 13, 12, 11]
check_code: ["false", "clang"]
exclude:
- pg: 16
check_code: "false"
- pg: 17
check_code: "false"

name: Test clickhouse_fdw
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Pull `clickhouse`
run: docker compose pull clickhouse
- name: Run `clickhouse`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The `clickhouse_fdw` is open-source. It is a Foreign Data Wrapper (FDW) for `Cli
Supported PostgreSQL Versions
------------------------------

PostgreSQL 11-14
PostgreSQL 11-17

Installation
----------------
Expand Down
8 changes: 8 additions & 0 deletions src/binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ static void * exc_palloc(Size size)

context->isReset = false;

#if PG_VERSION_NUM >= 170000
ret = context->methods->alloc(context, size, 0);
#else
ret = context->methods->alloc(context, size);
#endif
if (unlikely(ret == NULL))
throw std::bad_alloc();

Expand All @@ -87,7 +91,11 @@ void * exc_palloc0(Size size)

context->isReset = false;

#if PG_VERSION_NUM >= 170000
ret = context->methods->alloc(context, size, 0);
#else
ret = context->methods->alloc(context, size);
#endif
if (unlikely(ret == NULL))
throw std::bad_alloc();

Expand Down
1 change: 1 addition & 0 deletions src/clickhouse-cpp/clickhouse/types/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <memory>
#include <string>
#include <vector>
#include <cstdint>

namespace clickhouse {

Expand Down
35 changes: 28 additions & 7 deletions src/clickhouse_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

PG_MODULE_MAGIC;


/* Default CPU cost to start up a foreign query. */
#define DEFAULT_FDW_STARTUP_COST 100.0

Expand Down Expand Up @@ -296,10 +295,10 @@ void _PG_init(void){}
Datum
clickhousedb_raw_query(PG_FUNCTION_ARGS)
{
char *connstring = TextDatumGetCString(PG_GETARG_TEXT_P(1)),
*query = TextDatumGetCString(PG_GETARG_TEXT_P(0));
char *connstring = text_to_cstring(PG_GETARG_TEXT_P(1)),
*query = text_to_cstring(PG_GETARG_TEXT_P(0));

ch_connection_details *details = connstring_parse(connstring);
ch_connection_details *details = connstring_parse(connstring);
ch_connection conn = chfdw_http_connect(details);
ch_cursor *cursor = conn.methods->simple_query(conn.conn, query);
text *res = chfdw_http_fetch_raw_data(cursor);
Expand Down Expand Up @@ -511,9 +510,13 @@ clickhouseGetForeignPaths(PlannerInfo *root,
ForeignPath *path;
CHFdwRelationInfo *fpinfo = (CHFdwRelationInfo *) baserel->fdw_private;

path= create_foreignscan_path(root, baserel, NULL,
path = create_foreignscan_path(root, baserel, NULL,
fpinfo->rows, fpinfo->startup_cost, fpinfo->total_cost,
NULL, NULL, NULL, NIL);
NULL, NULL, NULL, NIL
#if PG_VERSION_NUM >= 170000
, NIL
#endif
);

add_path(baserel, (Path *) path);
add_paths_with_pathkeys_for_rel(root, baserel, NULL);
Expand Down Expand Up @@ -1206,7 +1209,7 @@ clickhouseBeginForeignInsert(ModifyTableState *mtstate,
NULL,
sql.data,
targetAttrs,
table_name);
table_name);

resultRelInfo->ri_FdwState = fmstate;
}
Expand Down Expand Up @@ -1855,6 +1858,9 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
useful_pathkeys,
NULL,
sorted_epq_path,
#if PG_VERSION_NUM >= 170000
NIL,
#endif
NIL));
else
add_path(rel, (Path *)
Expand All @@ -1866,6 +1872,9 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
useful_pathkeys,
NULL,
sorted_epq_path,
#if PG_VERSION_NUM >= 170000
NIL,
#endif
NIL));
}
}
Expand Down Expand Up @@ -2025,6 +2034,9 @@ clickhouseGetForeignJoinPaths(PlannerInfo *root,
NIL, /* no pathkeys */
NULL,
epq_path,
#if PG_VERSION_NUM >= 170000
NIL,
#endif
NIL); /* no fdw_private */

/* Add generated path into joinrel by add_path(). */
Expand Down Expand Up @@ -2395,6 +2407,9 @@ add_foreign_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
total_cost,
NIL, /* no pathkeys */
NULL,
#if PG_VERSION_NUM >= 170000
NIL,
#endif
NIL); /* no fdw_private */
#endif

Expand Down Expand Up @@ -2533,6 +2548,9 @@ add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel,
total_cost,
root->sort_pathkeys,
NULL, /* no extra plan */
#if PG_VERSION_NUM >= 170000
NIL,
#endif
fdw_private);
#endif

Expand Down Expand Up @@ -2678,6 +2696,9 @@ add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel,
-10,
pathkeys,
NULL, /* no extra plan */
#if PG_VERSION_NUM >= 170000
NIL,
#endif
fdw_private);

/* and add it to the final_rel */
Expand Down
Loading