Skip to content

Commit

Permalink
Fix PGRES_COPY_IN handling for error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Dec 16, 2024
1 parent 26db90e commit 3225097
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/pq/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ namespace tao::pq
throw pq::connection_error( error_message() ); // LCOV_EXCL_LINE
}

auto result = connection::get_result( end );
const auto result = connection::get_result( end );
switch( PQresultStatus( result.get() ) ) {
case PGRES_COMMAND_OK:
connection::clear_results( end );
Expand Down
7 changes: 3 additions & 4 deletions src/lib/pq/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ namespace tao::pq
default:;
}

if( const auto next = m_connection->get_result( end ) ) {
const auto status = PQresultStatus( next.get() );
throw std::runtime_error( std::format( "unexpected result status: {}", PQresStatus( status ) ) );
while( auto next = m_connection->get_result( end ) ) {
result = std::move( next );
}

return pq::result( result.release() );
Expand All @@ -203,7 +202,7 @@ namespace tao::pq
check_current_transaction();
const auto end = m_connection->timeout_end( start );

auto result = m_connection->get_result( end );
const auto result = m_connection->get_result( end );
if( !result ) {
throw std::runtime_error( "unable to obtain result" );
}
Expand Down

0 comments on commit 3225097

Please sign in to comment.