Skip to content

Commit

Permalink
Improve result logging
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Jan 4, 2025
1 parent 0562721 commit 5c4ec5f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/test/pq/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,19 @@ namespace
};
log->connection.get_result.result = []( tao::pq::connection& c, PGresult* r ) {
std::cout << std::format( "get_result(connection={}) -> {}", static_cast< const void* >( &c ), static_cast< const void* >( r ) ) << '\n';
if( r ) {
std::cout << std::format( " columns={}, rows={}", PQnfields( r ), PQntuples( r ) ) << '\n';
if( r != nullptr ) {
const auto st = PQresultStatus( r );
std::cout << std::format( " status={}", PQresStatus( st ) ) << '\n';
const auto cols = PQnfields( r );
if( cols != 0 ) {
std::cout << std::format( " columns={}, rows={}", cols, PQntuples( r ) ) << '\n';
}
else {
const char* str = PQcmdTuples( r );
if( str[ 0 ] != '\0' ) {
std::cout << std::format( " rows_affected={}", str ) << '\n';
}
}
}
};

Expand Down

0 comments on commit 5c4ec5f

Please sign in to comment.