Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(c/driver/postgresql): suppress console spam #1027

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading