summaryrefslogtreecommitdiff
path: root/lib/output/pq/updateDatabase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/pq/updateDatabase.cpp')
-rw-r--r--lib/output/pq/updateDatabase.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/output/pq/updateDatabase.cpp b/lib/output/pq/updateDatabase.cpp
index 232e8f9..ea8797b 100644
--- a/lib/output/pq/updateDatabase.cpp
+++ b/lib/output/pq/updateDatabase.cpp
@@ -27,6 +27,8 @@
#include <streamSupport.h>
namespace MyGrate::Output::Pq {
+ constexpr uint8_t STANDALONE {1};
+
#ifndef __cpp_aggregate_paren_init
ColumnDef::ColumnDef(std::string n, std::size_t o, bool p) : name {std::move(n)}, ordinal(o), is_pk(p) { }
#endif
@@ -266,14 +268,18 @@ namespace MyGrate::Output::Pq {
void
UpdateDatabase::beforeEvent(const MariaDB_Event_Ptr &)
{
- beginTx();
+ if (!intx) {
+ beginTx();
+ }
}
void
UpdateDatabase::afterEvent(const MariaDB_Event_Ptr & e)
{
- output::pq::sql::updateSourcePosition::execute(this, e->next_event_pos, source);
- commitTx();
+ if (!intx) {
+ output::pq::sql::updateSourcePosition::execute(this, e->next_event_pos, source);
+ commitTx();
+ }
}
void
@@ -401,4 +407,22 @@ namespace MyGrate::Output::Pq {
afterEvent(e);
}
}
+
+ void
+ UpdateDatabase::gtid(MariaDB_Event_Ptr e)
+ {
+ beforeEvent(e);
+ if (!(e->event.gtid.flags & STANDALONE)) {
+ intx = true;
+ }
+ afterEvent(e);
+ }
+
+ void
+ UpdateDatabase::xid(MariaDB_Event_Ptr e)
+ {
+ beforeEvent(e);
+ intx = false;
+ afterEvent(e);
+ }
}