diff --git a/src/motherduck_destination.cpp b/src/motherduck_destination.cpp index 55f7721..39247a7 100644 --- a/src/motherduck_destination.cpp +++ b/src/motherduck_destination.cpp @@ -1,5 +1,7 @@ #include "duckdb.hpp" #include "motherduck_destination_server.hpp" +#include +#include #include #include @@ -39,7 +41,15 @@ void download_motherduck_extension() { } } +void logCrash(int sig) { + std::cerr << "Crash signal " << sig << std::endl; + std::exit(sig); +} + int main(int argc, char **argv) { + std::signal(SIGSEGV, logCrash); + std::signal(SIGABRT, logCrash); + std::string port = "50052"; for (auto i = 1; i < argc; i++) { if (strcmp(argv[i], "--port") == 0) { diff --git a/src/motherduck_destination_server.cpp b/src/motherduck_destination_server.cpp index 4ecd336..35e1111 100644 --- a/src/motherduck_destination_server.cpp +++ b/src/motherduck_destination_server.cpp @@ -204,10 +204,16 @@ grpc::Status DestinationSdkImpl::DescribeTable( find_property(request->configuration(), MD_PROP_DATABASE); std::unique_ptr con = get_connection(request->configuration(), db_name); + mdlog::info("Endpoint : got connection"); table_def table_name{db_name, get_schema_name(request), get_table_name(request)}; + mdlog::info("Endpoint : schema name <" + + table_name.schema_name + ">"); + mdlog::info("Endpoint : table name <" + + table_name.table_name + ">"); if (!table_exists(*con, table_name)) { + mdlog::info("Endpoint : table not found"); response->set_not_found(true); return ::grpc::Status(::grpc::StatusCode::OK, ""); } diff --git a/src/sql_generator.cpp b/src/sql_generator.cpp index 6cf209a..508867a 100644 --- a/src/sql_generator.cpp +++ b/src/sql_generator.cpp @@ -102,6 +102,7 @@ bool table_exists(duckdb::Connection &con, const table_def &table) { const std::string err = "Could not find whether table <" + table.to_escaped_string() + "> exists"; auto statement = con.Prepare(query); + mdlog::info(" prepared table_exists query for table " + table.table_name); if (statement->HasError()) { throw std::runtime_error(err + " (at bind step): " + statement->GetError()); } @@ -109,12 +110,15 @@ bool table_exists(duckdb::Connection &con, const table_def &table) { duckdb::Value(table.schema_name), duckdb::Value(table.table_name)}; auto result = statement->Execute(params, false); + mdlog::info(" executed table_exists query for table " + table.table_name); if (result->HasError()) { throw std::runtime_error(err + ": " + result->GetError()); } auto materialized_result = duckdb::unique_ptr_cast< duckdb::QueryResult, duckdb::MaterializedQueryResult>(std::move(result)); + mdlog::info(" materialized table_exists results for table " + + table.table_name); return materialized_result->RowCount() > 0; }