Skip to content

Commit

Permalink
fix(c/driver/postgresql): suppress console spam (#1027)
Browse files Browse the repository at this point in the history
Fixes #1023.
  • Loading branch information
lidavidm authored Sep 1, 2023
1 parent 932b721 commit 3d1d6cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions c/driver/postgresql/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@ class PqGetObjectsHelper {
struct ArrowArray* fk_column_name_col_;
};

// A notice processor that does nothing with notices. In the future we can log
// these, but this suppresses the default of printing to stderr.
void SilentNoticeProcessor(void* /*arg*/, const char* /*message*/) {}

} // namespace

AdbcStatusCode PostgresConnection::Cancel(struct AdbcError* error) {
Expand Down Expand Up @@ -1398,12 +1402,17 @@ AdbcStatusCode PostgresConnection::Init(struct AdbcDatabase* database,
database_ =
*reinterpret_cast<std::shared_ptr<PostgresDatabase>*>(database->private_data);
type_resolver_ = database_->type_resolver();

RAISE_ADBC(database_->Connect(&conn_, error));

cancel_ = PQgetCancel(conn_);
if (!cancel_) {
SetError(error, "[libpq] Could not initialize PGcancel");
return ADBC_STATUS_UNKNOWN;
}

std::ignore = PQsetNoticeProcessor(conn_, SilentNoticeProcessor, nullptr);

return ADBC_STATUS_OK;
}

Expand Down

0 comments on commit 3d1d6cc

Please sign in to comment.