Skip to content

Commit

Permalink
GetConnection should check secret table changes (#268)
Browse files Browse the repository at this point in the history
We don't need use anymore `GetDatabase()` which contained logic to
update secrets based on sequence number. Move thisi logic now in
`GetConnection` which is currently used in code.
  • Loading branch information
mkaruza authored Oct 10, 2024
1 parent 68dab4f commit 39ad690
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
13 changes: 1 addition & 12 deletions include/pgduckdb/pgduckdb_duckdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,7 @@ class DuckDBManager {
return instance;
}

inline duckdb::DuckDB &
GetDatabase() {
if(CheckSecretsSeq()) {
auto connection = duckdb::make_uniq<duckdb::Connection>(*database);
auto &context = *connection->context;
DropSecrets(context);
LoadSecrets(context);
}
return *database;
}

duckdb::unique_ptr<duckdb::Connection> GetConnection() const;
duckdb::unique_ptr<duckdb::Connection> GetConnection();

private:
DuckDBManager();
Expand Down
10 changes: 8 additions & 2 deletions src/pgduckdb_duckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,14 @@ DuckDBManager::LoadExtensions(duckdb::ClientContext &context) {
}

duckdb::unique_ptr<duckdb::Connection>
DuckDBManager::GetConnection() const {
return duckdb::make_uniq<duckdb::Connection>(*database);
DuckDBManager::GetConnection() {
auto connection = duckdb::make_uniq<duckdb::Connection>(*database);
if (CheckSecretsSeq()) {
auto &context = *connection->context;
DropSecrets(context);
LoadSecrets(context);
}
return connection;
}

} // namespace pgduckdb

0 comments on commit 39ad690

Please sign in to comment.