Skip to content

Commit 5c6d7df

Browse files
authored
Merge pull request #1825 from joto/pgsql-exec-prep
Allow PGRES_COMMAND_OK as well as PGRES_TUPLES_OK status
2 parents 88e9472 + 604ec08 commit 5c6d7df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/pgsql.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ 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 (res.status() != PGRES_TUPLES_OK) {
159+
auto const status = res.status();
160+
if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) {
160161
log_error("SQL command failed: EXECUTE {}({})", stmt,
161162
concat_params(num_params, param_values));
162163
throw std::runtime_error{
163-
"Database error: {} ({})"_format(error_msg(), res.status())};
164+
"Database error: {} ({})"_format(error_msg(), status)};
164165
}
165166

166167
return res;

0 commit comments

Comments
 (0)