Log SQLSTATE code for errors
authorTom Hughes <tom@compton.nu>
Wed, 22 Aug 2012 08:30:47 +0000 (09:30 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 22 Aug 2012 08:30:47 +0000 (09:30 +0100)
src/postgres.c

index 2393852..51555b4 100644 (file)
@@ -44,7 +44,8 @@ db_execute(const char *statement, ExecStatusType expected)
    result = PQexec(handle, statement);
 
    if (PQresultStatus(result) != expected) {
-      ERROR("Failure executing PostgreSQL statement: %s",
+      ERROR("Failure executing PostgreSQL statement: %s: %s",
+            PQresultErrorField(result, PG_DIAG_SQLSTATE),
             PQresultErrorMessage(result));
       PQclear(result);
       PQexec(handle, "ROLLBACK");