Skip to content

Conversation

Y--
Copy link
Collaborator

@Y-- Y-- commented Apr 25, 2025

Fixes #736

@Y-- Y-- requested a review from JelteF April 25, 2025 08:53
@Y-- Y-- force-pushed the yl/err-after-init branch 3 times, most recently from ef3967e to c5c246a Compare April 25, 2025 09:03
src/pgduckdb.cpp Outdated
@@ -122,53 +135,54 @@ DuckdbInitGUC() {
&duckdb_log_pg_explain);

DefineCustomVariable("duckdb.enable_external_access", "Allow the DuckDB to access external state.",
&duckdb_enable_external_access, PGC_SUSET);
&duckdb_enable_external_access, PGC_SUSET, 0, GucCheckDuckDBNotInitdHook);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: does it make sense to add another template without the flags argument, so we don't need to specify 0 soo many times.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I went back and forth on that. I thought I remembered that you created those with all the possible args, so didn't want to add toe many helpers.

But maybe we do want a DefineCustomDuckDBVariable that would do exactly that. I'll give it a shot so we can compare

src/pgduckdb.cpp Outdated
GucCheckDuckDBNotInitdHook(T *, void **, GucSource) {
if (pgduckdb::DuckDBManager::IsInitialized()) {
GUC_check_errmsg(
"Cannot set this variable after DuckDB has been initialized. Use `duckdb.recycle_ddb()` to reset "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Cannot set this variable after DuckDB has been initialized. Use `duckdb.recycle_ddb()` to reset "
"Cannot set this variable after DuckDB has been initialized. Reconnect to Postgres or use `duckdb.recycle_ddb()` to reset "

@Y-- Y-- force-pushed the yl/err-after-init branch from c5c246a to d0ef473 Compare April 25, 2025 12:05
GucIntCheckHook check_hook,
GucIntAssignHook assign_hook,
GucTypeCheckHook<T> check_hook,
GucTypeAssignHook<T> assign_hook,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a "bug" - using a float type would have failed to compile

@Y-- Y-- force-pushed the yl/err-after-init branch from d0ef473 to 726a4b8 Compare April 25, 2025 12:08
@Y-- Y-- force-pushed the yl/err-after-init branch from 44f7a60 to f1fc8f4 Compare April 25, 2025 12:25
using GucTypeAssignHook = void (*)(T, void *);

template <typename T>
void
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put static back so it doesn't conflict with symbols from possibly other libraries.

Suggested change
void
static void

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these are templates, so it won't conflict with anything, and I've put all the concrete implementation in the anonymous ns:

namespace {

@Y-- Y-- enabled auto-merge (squash) April 25, 2025 12:30
@Y-- Y-- merged commit c8b909b into main Apr 25, 2025
6 checks passed
@Y-- Y-- deleted the yl/err-after-init branch April 25, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Throw error when changing a duckdb GUC after DuckDB is initialized
2 participants