Skip to content

Commit

Permalink
No redundant extension download (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
elefeint authored Apr 6, 2024
1 parent afb4a2b commit 1650658
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ INSTALL_DIR="${ROOT_DIR}/install"

GRPC_VERSION=v1.59.1
OPENSSL_VERSION=3.1.3
ARROW_VERSION=14.0.2
ARROW_VERSION=15.0.2
DUCKDB_VERSION=v0.9.2
CATCH2_VERSION=v3.5.1

Expand Down
22 changes: 22 additions & 0 deletions src/motherduck_destination.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "duckdb.hpp"
#include "motherduck_destination_server.hpp"
#include <grpcpp/grpcpp.h>
#include <string>
Expand All @@ -18,6 +19,26 @@ void RunServer(const std::string &port) {
server->Wait();
}

void download_motherduck_extension() {
// create an in-memory DuckDB instance
duckdb::DuckDB db;
duckdb::Connection con(db);
{
auto result = con.Query("INSTALL motherduck");
if (result->HasError()) {
throw std::runtime_error("Could not install motherduck extension prior "
"to gRPC server startup");
}
}
{
auto result = con.Query("LOAD motherduck");
if (result->HasError()) {
throw std::runtime_error(
"Could not load motherduck extension prior to gRPC server startup");
}
}
}

int main(int argc, char **argv) {
std::string port = "50052";
for (auto i = 1; i < argc; i++) {
Expand All @@ -31,6 +52,7 @@ int main(int argc, char **argv) {
std::cout << "argument: " << argv[i] << std::endl;
}

download_motherduck_extension();
RunServer(port);
return 0;
}

0 comments on commit 1650658

Please sign in to comment.