Skip to content

Commit

Permalink
Add autoload and autoinstall GUC (#484)
Browse files Browse the repository at this point in the history
Add two GUC settings: `duckdb_autoinstall_known_extensions` and
`duckdb_autoload_known_extensions`, which are direct proxy for DuckDB
[settings](https://duckdb.org/docs/configuration/overview.html)
`autoinstall_known_extensions` and `autoload_known_extensions`.

Mark both option enabled by default.
  • Loading branch information
Y-- authored Dec 9, 2024
1 parent 940c705 commit 39a5ffd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,7 @@ Querying data stored in Parquet, CSV, JSON, Iceberg and Delta format can be done
LIMIT 100;
```

Note, for Azure, you will need to first install the Azure extension:
```sql
SELECT duckdb.install_extension('azure');
```

You may then store a secret using the `connection_string` parameter as such:
Note, for Azure, you may store a secret using the `connection_string` parameter as such:
```sql
INSERT INTO duckdb.secrets
(type, connection_string)
Expand Down
2 changes: 2 additions & 0 deletions include/pgduckdb/pgduckdb_guc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern char *duckdb_maximum_memory;
extern char *duckdb_disabled_filesystems;
extern bool duckdb_enable_external_access;
extern bool duckdb_allow_unsigned_extensions;
extern bool duckdb_autoinstall_known_extensions;
extern bool duckdb_autoload_known_extensions;
extern int duckdb_max_threads_per_postgres_scan;
extern char *duckdb_motherduck_postgres_database;
extern int duckdb_motherduck_enabled;
Expand Down
10 changes: 10 additions & 0 deletions src/pgduckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ char *duckdb_maximum_memory = strdup("4GB");
char *duckdb_disabled_filesystems = strdup("LocalFileSystem");
bool duckdb_enable_external_access = true;
bool duckdb_allow_unsigned_extensions = false;
bool duckdb_autoinstall_known_extensions = true;
bool duckdb_autoload_known_extensions = true;

extern "C" {
PG_MODULE_MAGIC;
Expand Down Expand Up @@ -131,6 +133,14 @@ DuckdbInitGUC(void) {
"Allow DuckDB to load extensions with invalid or missing signatures",
&duckdb_allow_unsigned_extensions, PGC_SUSET);

DefineCustomVariable("duckdb.autoinstall_known_extensions",
"Whether known extensions are allowed to be automatically installed when a DuckDB query depends on them",
&duckdb_autoinstall_known_extensions, PGC_SUSET);

DefineCustomVariable("duckdb.autoload_known_extensions",
"Whether known extensions are allowed to be automatically loaded when a DuckDB query depends on them",
&duckdb_autoload_known_extensions, PGC_SUSET);

DefineCustomVariable("duckdb.max_memory", "The maximum memory DuckDB can use (e.g., 1GB)", &duckdb_maximum_memory,
PGC_SUSET);
DefineCustomVariable("duckdb.memory_limit",
Expand Down
2 changes: 2 additions & 0 deletions src/pgduckdb_duckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ DuckDBManager::Initialize() {
config.replacement_scans.emplace_back(pgduckdb::PostgresReplacementScan);
SET_DUCKDB_OPTION(allow_unsigned_extensions);
SET_DUCKDB_OPTION(enable_external_access);
SET_DUCKDB_OPTION(autoinstall_known_extensions);
SET_DUCKDB_OPTION(autoload_known_extensions);

if (duckdb_maximum_memory != NULL) {
config.options.maximum_memory = duckdb::DBConfig::ParseMemoryLimit(duckdb_maximum_memory);
Expand Down

0 comments on commit 39a5ffd

Please sign in to comment.