Skip to content

Commit

Permalink
Merge pull request #31 from hydradatabase/duckdb-execution-guc
Browse files Browse the repository at this point in the history
GUC to enable/disable DuckDB query execution
  • Loading branch information
mkaruza authored May 16, 2024
2 parents 9f535e3 + a0f5f6e commit 46151ff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/quack/quack.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

// quack.c
extern bool quack_execution;
extern int quack_max_threads_per_query;
extern char *quack_secret;
extern "C" void _PG_init(void);
Expand Down
11 changes: 11 additions & 0 deletions src/quack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern "C" {

static void quack_init_guc(void);

bool quack_execution = true;
int quack_max_threads_per_query = 1;
char *quack_secret = nullptr;

Expand Down Expand Up @@ -50,6 +51,16 @@ quack_cloud_secret_check_hooks(char **newval, void **extra, GucSource source) {
static void
quack_init_guc(void) {

DefineCustomBoolVariable("quack.execution",
gettext_noop("Is DuckDB query execution enabled."),
NULL,
&quack_execution,
true,
PGC_USERSET,
0,
NULL,
NULL,
NULL);
DefineCustomIntVariable("quack.max_threads_per_query",
gettext_noop("DuckDB max no. threads per query."),
NULL,
Expand Down
5 changes: 3 additions & 2 deletions src/quack_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ is_catalog_table(List *tables) {

static PlannedStmt *
quack_planner(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams) {
if (is_quack_extension_registered() && !is_catalog_table(parse->rtable) && parse->commandType == CMD_SELECT) {
PlannedStmt * quackPlan = quack_plan_node(parse, query_string, cursorOptions, boundParams);
if (quack_execution && is_quack_extension_registered() && !is_catalog_table(parse->rtable) &&
parse->commandType == CMD_SELECT) {
PlannedStmt *quackPlan = quack_plan_node(parse, query_string, cursorOptions, boundParams);
if (quackPlan) {
return quackPlan;
}
Expand Down

0 comments on commit 46151ff

Please sign in to comment.