Created Pgsql::Transaction class for handling of transactions. It auto rollsback if no commit has been done.

Also moved some code out of the connection files to their own files.
This commit is contained in:
eelke 2018-12-09 20:24:11 +01:00
parent 255b2ec970
commit e32c82ac6f
12 changed files with 394 additions and 130 deletions

View file

@ -0,0 +1,35 @@
#ifndef PGSQL_ERRORDETAILS_H
#define PGSQL_ERRORDETAILS_H
#include <string>
#include <libpq-fe.h>
namespace Pgsql {
class ErrorDetails {
public:
static ErrorDetails createErrorDetailsFromPGresult(const PGresult *res);
std::string errorMessage;
std::string state; ///< PG_DIAG_SQLSTATE Error code as listed in https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html
std::string severity;
std::string messagePrimary;
std::string messageDetail;
std::string messageHint;
int statementPosition; ///< First character is one, measured in characters not bytes!
int internalPosition;
std::string internalQuery;
std::string context;
std::string schemaName;
std::string tableName;
std::string columnName;
std::string datatypeName;
std::string constraintName;
std::string sourceFile;
std::string sourceLine;
std::string sourceFunction;
};
}
#endif // PGSQL_ERRORDETAILS_H