Skip to content

Commit 9ed0c5f

Browse files
committed
Remove access to underlying PGresult from pg_result_t
1 parent d65db5c commit 9ed0c5f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/pgsql.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pg_result_t pg_conn_t::query(ExecStatusType expect, char const *sql) const
4343

4444
log_sql("{}", sql);
4545
pg_result_t res{PQexec(m_conn.get(), sql)};
46-
if (PQresultStatus(res.get()) != expect) {
46+
if (res.status() != expect) {
4747
throw std::runtime_error{"Database error: {}"_format(error_msg())};
4848
}
4949
return res;
@@ -121,7 +121,7 @@ void pg_conn_t::end_copy(std::string const &context) const
121121
}
122122

123123
pg_result_t const res{PQgetResult(m_conn.get())};
124-
if (PQresultStatus(res.get()) != PGRES_COMMAND_OK) {
124+
if (res.status() != PGRES_COMMAND_OK) {
125125
throw std::runtime_error{fmt::format(
126126
"Ending COPY mode for '{}' failed: {}.", context, error_msg())};
127127
}
@@ -156,11 +156,11 @@ pg_conn_t::exec_prepared_internal(char const *stmt, int num_params,
156156
}
157157
pg_result_t res{PQexecPrepared(m_conn.get(), stmt, num_params, param_values,
158158
nullptr, nullptr, 0)};
159-
if (PQresultStatus(res.get()) != PGRES_TUPLES_OK) {
159+
if (res.status() != PGRES_TUPLES_OK) {
160160
log_error("SQL command failed: EXECUTE {}({})", stmt,
161161
concat_params(num_params, param_values));
162-
throw std::runtime_error{"Database error: {} ({})"_format(
163-
error_msg(), PQresultStatus(res.get()))};
162+
throw std::runtime_error{
163+
"Database error: {} ({})"_format(error_msg(), res.status())};
164164
}
165165

166166
return res;

src/pgsql.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ class pg_result_t
4141

4242
explicit pg_result_t(PGresult *result) noexcept : m_result(result) {}
4343

44-
/// Get a pointer to the underlying PGresult object.
45-
PGresult *get() const noexcept { return m_result.get(); }
46-
4744
/// Get the status of this result.
4845
ExecStatusType status() const noexcept
4946
{

0 commit comments

Comments
 (0)