From: Aki Tuomi Date: Wed, 8 Jul 2015 18:10:27 +0000 (+0300) Subject: Add transaction support to goracle X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~58^2~18^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2632%2Fhead;p=thirdparty%2Fpdns.git Add transaction support to goracle --- diff --git a/modules/goraclebackend/soracle.cc b/modules/goraclebackend/soracle.cc index aafe54415f..19e7aae934 100644 --- a/modules/goraclebackend/soracle.cc +++ b/modules/goraclebackend/soracle.cc @@ -13,6 +13,8 @@ #include "pdns/namespaces.hh" #include "pdns/md5.hh" +static AtomicCounter s_txid; + bool SOracle::s_dolog; class SOracleStatement: public SSqlStatement { @@ -464,6 +466,19 @@ SOracle::~SOracle() } } +void SOracle::startTransaction() { + std::string cmd = "SET TRANSACTION NAME '" + boost::lexical_cast(s_txid++) + "'"; + execute(cmd); +} + +void SOracle::commit() { + execute("COMMIT"); +} + +void SOracle::rollback() { + execute("ROLLBACK"); +} + SSqlException SOracle::sPerrorException(const string &reason) { return SSqlException(reason); diff --git a/modules/goraclebackend/soracle.hh b/modules/goraclebackend/soracle.hh index 689cb7403f..d611080536 100644 --- a/modules/goraclebackend/soracle.hh +++ b/modules/goraclebackend/soracle.hh @@ -8,6 +8,7 @@ #include "pdns/utility.hh" #include #include +#include "pdns/misc.hh" #ifndef dsword typedef sb4 dsword; @@ -29,9 +30,9 @@ public: SSqlStatement* prepare(const string& query, int nparams); void execute(const string& query); - void startTransaction() {} - void commit() {} - void rollback() {} + void startTransaction(); + void commit(); + void rollback(); private: OCIEnv* d_environmentHandle; OCIError* d_errorHandle;