diff options
author | louiz’ <louiz@louiz.org> | 2018-02-16 00:58:49 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2018-02-16 00:58:49 +0100 |
commit | 8503d1f6831fc8522a16e0670578d1157d23e116 (patch) | |
tree | 98c22a3ee10cb9b36d34384b6cc503f910a0bf00 /src | |
parent | b1750843008b7928c72699c592776fb56c66ec26 (diff) | |
download | biboumi-8503d1f6831fc8522a16e0670578d1157d23e116.tar.gz biboumi-8503d1f6831fc8522a16e0670578d1157d23e116.tar.bz2 biboumi-8503d1f6831fc8522a16e0670578d1157d23e116.tar.xz biboumi-8503d1f6831fc8522a16e0670578d1157d23e116.zip |
Actually display the error message from postgresql when a query failed
Diffstat (limited to 'src')
-rw-r--r-- | src/database/postgresql_statement.hpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/database/postgresql_statement.hpp b/src/database/postgresql_statement.hpp index 571c8f1..5665aed 100644 --- a/src/database/postgresql_statement.hpp +++ b/src/database/postgresql_statement.hpp @@ -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; |