~singpolyma/biboumi

8503d1f6831fc8522a16e0670578d1157d23e116 — louiz’ 5 years ago b175084
Actually display the error message from postgresql when a query failed
1 files changed, 5 insertions(+), 1 deletions(-)

M src/database/postgresql_statement.hpp
M src/database/postgresql_statement.hpp => src/database/postgresql_statement.hpp +5 -1
@@ 6,6 6,8 @@

#include <libpq-fe.h>

#include <cstring>

class PostgresqlStatement: public Statement
{
 public:


@@ 108,7 110,9 @@ private:
    const auto status = PQresultStatus(this->result);
    if (status != PGRES_TUPLES_OK && status != PGRES_COMMAND_OK)
      {
        log_error("Failed to execute command: ", PQresultErrorMessage(this->result));
        const char* original = PQerrorMessage(this->conn);
        if (original && std::strlen(original) > 0)
          log_error("Failed to execute command: ", std::string{original, std::strlen(original) - 1});
        return false;
      }
    return true;