Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support postgresql 15 #180

Merged
merged 2 commits into from
Sep 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
version: [REL_16_STABLE, REL_17_STABLE]
version: [REL_15_STABLE, REL_16_STABLE, REL_17_STABLE]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 2 additions & 0 deletions src/pgduckdb_detoast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
extern "C" {
#include "postgres.h"
#include "pg_config.h"
#if PG_VERSION_NUM >= 160000
#include "varatt.h"
#endif

#ifdef USE_LZ4
#include <lz4.h>
Expand Down
12 changes: 12 additions & 0 deletions src/pgduckdb_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ ContainsDuckdbFunctions(Node *node, void *context) {

if (IsA(node, Query)) {
Query *query = (Query *)node;
#if PG_VERSION_NUM >= 160000
return query_tree_walker(query, ContainsDuckdbFunctions, context, 0);
#else
return query_tree_walker(query, (bool (*)()) ((void *) ContainsDuckdbFunctions), context, 0);
#endif
}

if (IsA(node, FuncExpr)) {
Expand All @@ -62,12 +66,20 @@ ContainsDuckdbFunctions(Node *node, void *context) {
}
}

#if PG_VERSION_NUM >= 160000
return expression_tree_walker(node, ContainsDuckdbFunctions, context);
#else
return expression_tree_walker(node, (bool (*)()) ((void *) ContainsDuckdbFunctions), context);
#endif
}

static bool
NeedsDuckdbExecution(Query *query) {
#if PG_VERSION_NUM >= 160000
return query_tree_walker(query, ContainsDuckdbFunctions, NULL, 0);
#else
return query_tree_walker(query, (bool (*)()) ((void *) ContainsDuckdbFunctions), NULL, 0);
#endif
}

static bool
Expand Down
4 changes: 4 additions & 0 deletions src/pgduckdb_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ PlanQuery(Query *parse, ParamListInfo bound_params) {
glob->subroots = NIL;
glob->rewindPlanIDs = NULL;
glob->finalrtable = NIL;
#if PG_VERSION_NUM >= 160000
glob->finalrteperminfos = NIL;
#endif
glob->finalrowmarks = NIL;
glob->resultRelations = NIL;
glob->appendRelations = NIL;
Expand Down Expand Up @@ -171,7 +173,9 @@ DuckdbPlanNode(Query *parse, int cursor_options, ParamListInfo bound_params) {
result->parallelModeNeeded = false;
result->planTree = duckdb_plan;
result->rtable = NULL;
#if PG_VERSION_NUM >= 160000
result->permInfos = NULL;
#endif
result->resultRelations = NULL;
result->appendRelations = NULL;
result->subplans = NIL;
Expand Down
25 changes: 24 additions & 1 deletion src/utility/copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ static constexpr char r2_filename_prefix[] = "r2://";
static bool
CreateRelationCopyParseState(ParseState *pstate, const CopyStmt *stmt, List **vars, int stmt_location, int stmt_len) {
ParseNamespaceItem *nsitem;
#if PG_VERSION_NUM >= 160000
RTEPermissionInfo *perminfo;
#else
RangeTblEntry *rte;
#endif
TupleDesc tuple_desc;
List *attnums;
Relation rel;
Expand All @@ -43,12 +47,18 @@ CreateRelationCopyParseState(ParseState *pstate, const CopyStmt *stmt, List **va

nsitem = addRangeTableEntryForRelation(pstate, rel, AccessShareLock, NULL, false, false);

#if PG_VERSION_NUM >= 160000
perminfo = nsitem->p_perminfo;
perminfo->requiredPerms = ACL_SELECT;
#else
rte = nsitem->p_rte;
rte->requiredPerms = ACL_SELECT;
#endif

tuple_desc = RelationGetDescr(rel);
attnums = CopyGetAttnums(tuple_desc, rel, stmt->attlist);

#if PG_VERSION_NUM >= 160000
foreach_int(cur, attnums) {
int attno;
Bitmapset **bms;
Expand All @@ -59,12 +69,25 @@ CreateRelationCopyParseState(ParseState *pstate, const CopyStmt *stmt, List **va
lappend(*vars, makeVar(1, cur, tuple_desc->attrs[cur - 1].atttypid, tuple_desc->attrs[cur - 1].atttypmod,
tuple_desc->attrs[cur - 1].attcollation, 0));
}
#else
foreach_int(cur, attnums)
{
int attno = cur - FirstLowInvalidHeapAttributeNumber;
rte->selectedCols = bms_add_member(rte->selectedCols, attno);
}
#endif

#if PG_VERSION_NUM >= 160000
if (!ExecCheckPermissions(pstate->p_rtable, list_make1(perminfo), false)) {
ereport(WARNING, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("(Duckdb) Failed Permission \"%s\"", RelationGetRelationName(rel))));
}

#else
if (!ExecCheckRTPerms(pstate->p_rtable, true)) {
ereport(WARNING, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("(Duckdb) Failed Permission \"%s\"", RelationGetRelationName(rel))));
}
#endif
table_close(rel, AccessShareLock);

/*
Expand Down
Loading