diff options
Diffstat (limited to 'libmysqlpp/my-connection.cpp')
-rw-r--r-- | libmysqlpp/my-connection.cpp | 57 |
1 files changed, 12 insertions, 45 deletions
diff --git a/libmysqlpp/my-connection.cpp b/libmysqlpp/my-connection.cpp index c6ab993..687572f 100644 --- a/libmysqlpp/my-connection.cpp +++ b/libmysqlpp/my-connection.cpp @@ -58,9 +58,7 @@ NvpTarget(Opts) OptsTargetMap { }; -MySQL::Connection::Connection(const std::string & str) : - txDepth(0), - rolledback(false) +MySQL::Connection::Connection(const std::string & str) { std::stringstream i(str); Opts o; @@ -84,58 +82,27 @@ MySQL::Connection::~Connection() } void -MySQL::Connection::finish() const +MySQL::Connection::beginTxInt() { - if (txDepth != 0) { - rollbackTx(); - throw DB::TransactionStillOpen(); - } -} - -int -MySQL::Connection::beginTx() const -{ - if (txDepth == 0) { - if (mysql_autocommit(&conn, 0)) { - throw Error(&conn); - } - rolledback = false; + if (mysql_autocommit(&conn, 0)) { + throw Error(&conn); } - return ++txDepth; } -int -MySQL::Connection::commitTx() const +void +MySQL::Connection::commitTxInt() { - if (rolledback) { - return rollbackTx(); - } - if (--txDepth == 0) { - if (mysql_commit(&conn)) { - throw Error(&conn); - } + if (mysql_commit(&conn)) { + throw Error(&conn); } - return txDepth; } -int -MySQL::Connection::rollbackTx() const +void +MySQL::Connection::rollbackTxInt() { - if (--txDepth == 0) { - if (mysql_rollback(&conn)) { - throw Error(&conn); - } - } - else { - rolledback = true; + if (mysql_rollback(&conn)) { + throw Error(&conn); } - return txDepth; -} - -bool -MySQL::Connection::inTx() const -{ - return txDepth; } DB::BulkDeleteStyle |