Skip to content

Commit

Permalink
Minor cleanups (#585)
Browse files Browse the repository at this point in the history
Misc cleanups I had stashed locally
  • Loading branch information
Y-- authored Feb 12, 2025
1 parent 236e5c1 commit 371a680
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/pgduckdb/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace pgduckdb {
pd_prevent_errno_in_scope(); \
static_assert(elevel >= DEBUG5 && elevel <= WARNING_CLIENT_ONLY, "Invalid error level"); \
if (message_level_is_interesting(elevel)) { \
std::lock_guard<std::mutex> lock(GlobalProcessLock::GetLock()); \
std::lock_guard<std::mutex> lock(pgduckdb::GlobalProcessLock::GetLock()); \
if (errstart(elevel, domain)) \
__VA_ARGS__, errfinish(__FILE__, __LINE__, __func__); \
} \
Expand Down
9 changes: 4 additions & 5 deletions src/pgduckdb_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ Duckdb_BeginCustomScan(CustomScanState *cscanstate, EState *estate, int eflags)
static void
ExecuteQuery(DuckdbScanState *state) {
auto &prepared = *state->prepared_statement;
auto &query_results = state->query_results;
auto &connection = state->duckdb_connection;
auto pg_params = state->params;
const auto num_params = pg_params ? pg_params->numParams : 0;
duckdb::case_insensitive_map_t<duckdb::BoundParameterData> named_values;
Expand Down Expand Up @@ -136,14 +134,15 @@ ExecuteQuery(DuckdbScanState *state) {
return pending->ThrowError();
}

duckdb::PendingExecutionResult execution_result;
duckdb::PendingExecutionResult execution_result = duckdb::PendingExecutionResult::RESULT_NOT_READY;
while (true) {
execution_result = pending->ExecuteTask();
if (duckdb::PendingQueryResult::IsResultReady(execution_result)) {
break;
}

if (QueryCancelPending) {
auto &connection = state->duckdb_connection;
// Send an interrupt
connection->Interrupt();
auto &executor = duckdb::Executor::Get(*connection->context);
Expand All @@ -160,8 +159,8 @@ ExecuteQuery(DuckdbScanState *state) {
return pending->ThrowError();
}

query_results = pending->Execute();
state->column_count = query_results->ColumnCount();
state->query_results = pending->Execute();
state->column_count = state->query_results->ColumnCount();
state->is_executed = true;
}

Expand Down
3 changes: 1 addition & 2 deletions src/pgduckdb_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ DuckdbPrepare(const Query *query) {
elog(DEBUG2, "(PGDuckDB/DuckdbPrepare) Preparing: %s", query_string);

auto con = pgduckdb::DuckDBManager::GetConnection();
auto prepared_query = con->context->Prepare(query_string);
return prepared_query;
return con->context->Prepare(query_string);
}

static Plan *
Expand Down
1 change: 0 additions & 1 deletion src/utility/copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern "C" {

#include "pgduckdb/vendor/pg_list.hpp"
#include "pgduckdb/pgduckdb_ruleutils.h"
#include "pgduckdb/vendor/pg_list.hpp"
}

static constexpr char s3_filename_prefix[] = "s3://";
Expand Down

0 comments on commit 371a680

Please sign in to comment.