-
Notifications
You must be signed in to change notification settings - Fork 129
Add GUC to allow DuckDB execution inside functions #884
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
Add GUC to allow DuckDB execution inside functions #884
Conversation
src/pgduckdb_guc.cpp
Outdated
@@ -143,6 +144,9 @@ InitGUC() { | |||
/* pg_duckdb specific GUCs */ | |||
DefineCustomVariable("duckdb.force_execution", "Force queries to use DuckDB execution", &duckdb_force_execution); | |||
|
|||
DefineCustomVariable("duckdb.unsafe_allow_execution_inside_functions", "Allow DuckDB execution inside functions", | |||
&duckdb_unsafe_allow_execution_inside_functions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this can introduce crashes I think a superuser should be configuring this.
&duckdb_unsafe_allow_execution_inside_functions); | |
&duckdb_unsafe_allow_execution_inside_functions, 0, GUC_SUPERUSER_ONLY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense. But did you mean
&duckdb_unsafe_allow_execution_inside_functions, PGC_SUSET);
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's definitely what I meant. After many years I still keep confusing these two.
@@ -117,9 +118,8 @@ $$; | |||
-- After executing the function the table should not contain the value 8, | |||
-- because that change was rolled back | |||
SELECT * FROM f(true); | |||
ERROR: DuckDB execution is not supported inside functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still have some tests for the default behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, test/regression/expected/issue_730.out
still uses the default behavior
https://github.com/duckdb/pg_duckdb/pull/764/files#diff-6e283896067d2e581c1917f5595977aa405d8f337cc77303a72e49dd9463eb26
DuckDB execution inside functions was disallowed in #764 for good reason
However, some users depend on running analytics with pg_duckdb inside functions
Given that (1) the problematic cases are rare, and (2) pg_duckdb is mostly used for read queries, failures are limited to crashing the current session and can be recovered by restarting the session without data loss. This change introduces an unsafe GUC to restore this capability for users who need it