summaryrefslogtreecommitdiff
path: root/lib/input
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-06-13 21:29:25 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-06-13 21:29:25 +0100
commit3bc5964793f1700551b7db8107a939c98f1d1be1 (patch)
tree38c77c4e49d54a348e5cdeb402bdd63f2e29d477 /lib/input
parentAdd operator* to RecordSet, shorthand for getting scalar from 0,0 (diff)
downloadmygrate-3bc5964793f1700551b7db8107a939c98f1d1be1.tar.bz2
mygrate-3bc5964793f1700551b7db8107a939c98f1d1be1.tar.xz
mygrate-3bc5964793f1700551b7db8107a939c98f1d1be1.zip
Add transaction support
Diffstat (limited to 'lib/input')
-rw-r--r--lib/input/mysqlConn.cpp20
-rw-r--r--lib/input/mysqlConn.h4
2 files changed, 24 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);
+ }
}
diff --git a/lib/input/mysqlConn.h b/lib/input/mysqlConn.h
index dfb408f..bd53616 100644
--- a/lib/input/mysqlConn.h
+++ b/lib/input/mysqlConn.h
@@ -29,6 +29,10 @@ namespace MyGrate::Input {
void query(const char * const q, const std::initializer_list<DbValue> &) override;
DbPrepStmtPtr prepare(const char * const, std::size_t) override;
+
+ void beginTx() override;
+ void commitTx() override;
+ void rollbackTx() override;
};
}