diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-13 21:29:25 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-13 21:29:25 +0100 |
commit | 3bc5964793f1700551b7db8107a939c98f1d1be1 (patch) | |
tree | 38c77c4e49d54a348e5cdeb402bdd63f2e29d477 /lib/input/mysqlConn.cpp | |
parent | Add operator* to RecordSet, shorthand for getting scalar from 0,0 (diff) | |
download | mygrate-3bc5964793f1700551b7db8107a939c98f1d1be1.tar.bz2 mygrate-3bc5964793f1700551b7db8107a939c98f1d1be1.tar.xz mygrate-3bc5964793f1700551b7db8107a939c98f1d1be1.zip |
Add transaction support
Diffstat (limited to 'lib/input/mysqlConn.cpp')
-rw-r--r-- | lib/input/mysqlConn.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/input/mysqlConn.cpp b/lib/input/mysqlConn.cpp index 362f9ea..99c2891 100644 --- a/lib/input/mysqlConn.cpp +++ b/lib/input/mysqlConn.cpp @@ -52,4 +52,24 @@ namespace MyGrate::Input { { return std::make_unique<MySQLPrepStmt>(q, this); } + + void + MySQLConn::beginTx() + { + verify<MySQLErr>(!mysql_autocommit(this, false), "Auto commit off", this); + } + + void + MySQLConn::commitTx() + { + verify<MySQLErr>(!mysql_commit(this), "Commit", this); + verify<MySQLErr>(!mysql_autocommit(this, true), "Auto commit on", this); + } + + void + MySQLConn::rollbackTx() + { + verify<MySQLErr>(!mysql_rollback(this), "Rollback", this); + verify<MySQLErr>(!mysql_autocommit(this, true), "Auto commit on", this); + } } |