54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
|
|
#ifndef PGSQL_TRANSACTION_H
|
|||
|
|
#define PGSQL_TRANSACTION_H
|
|||
|
|
|
|||
|
|
#include <QString>
|
|||
|
|
#include <string>
|
|||
|
|
#include "Pgsql_Canceller.h"
|
|||
|
|
|
|||
|
|
namespace Pgsql {
|
|||
|
|
|
|||
|
|
class Result;
|
|||
|
|
class Params;
|
|||
|
|
class Connection;
|
|||
|
|
|
|||
|
|
|
|||
|
|
class Transaction {
|
|||
|
|
public:
|
|||
|
|
static Transaction startTransaction(Connection &conn);
|
|||
|
|
~Transaction();
|
|||
|
|
void rollback();
|
|||
|
|
void commit();
|
|||
|
|
Canceller getCancel();
|
|||
|
|
std::string getErrorMessage() const;
|
|||
|
|
Result query(const char * command);
|
|||
|
|
Result query(const QString &command);
|
|||
|
|
Result queryParam(const char * command, const Params ¶ms);
|
|||
|
|
Result queryParam(const QString &command, const Params ¶ms);
|
|||
|
|
bool sendQuery(const char * query);
|
|||
|
|
bool sendQuery(const std::string &command);
|
|||
|
|
bool sendQuery(const QString &command);
|
|||
|
|
bool sendQueryParams(const char * command, const Params ¶ms);
|
|||
|
|
std::shared_ptr<Result> getResult();
|
|||
|
|
bool consumeInput();
|
|||
|
|
bool isBusy();
|
|||
|
|
std::string escapeLiteral(const std::string_view &literal);
|
|||
|
|
QString escapeLiteral(const QString &literal);
|
|||
|
|
std::string escapeIdentifier(const std::string_view &ident);
|
|||
|
|
QString escapeIdentifier(const QString &ident);
|
|||
|
|
QString getDBName() const;
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
Connection *m_conn = nullptr;
|
|||
|
|
bool m_committed = false;
|
|||
|
|
bool m_rolledback = false;
|
|||
|
|
|
|||
|
|
Transaction(Connection *conn)
|
|||
|
|
: m_conn(conn)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif // PGSQL_TRANSACTION_H
|