summaryrefslogtreecommitdiff
path: root/lib/output
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output')
-rw-r--r--lib/output/pq/sql/updateSourceRotate.sql4
-rw-r--r--lib/output/pq/updateDatabase.cpp10
-rw-r--r--lib/output/pq/updateDatabase.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/lib/output/pq/sql/updateSourceRotate.sql b/lib/output/pq/sql/updateSourceRotate.sql
new file mode 100644
index 0000000..74e22fc
--- /dev/null
+++ b/lib/output/pq/sql/updateSourceRotate.sql
@@ -0,0 +1,4 @@
+UPDATE mygrate.source SET
+ filename = $1,
+ position = $2
+WHERE source_id = $3
diff --git a/lib/output/pq/updateDatabase.cpp b/lib/output/pq/updateDatabase.cpp
index c43d8e4..9db672d 100644
--- a/lib/output/pq/updateDatabase.cpp
+++ b/lib/output/pq/updateDatabase.cpp
@@ -20,6 +20,7 @@
#include <output/pq/sql/selectSourceSchema.h>
#include <output/pq/sql/selectTables.h>
#include <output/pq/sql/updateSourcePosition.h>
+#include <output/pq/sql/updateSourceRotate.h>
#include <row.h>
#include <stdexcept>
#include <streamSupport.h>
@@ -384,4 +385,13 @@ namespace MyGrate::Output::Pq {
afterEvent(e);
}
}
+
+ void
+ UpdateDatabase::rotate(MariaDB_Event_Ptr e)
+ {
+ if ((e->flags & LOG_EVENT_ARTIFICIAL_F) == 0) {
+ output::pq::sql::updateSourceRotate::execute(
+ this, *e->event.rotate.filename, e->event.rotate.position, source);
+ }
+ }
}
diff --git a/lib/output/pq/updateDatabase.h b/lib/output/pq/updateDatabase.h
index 9547b90..12df97e 100644
--- a/lib/output/pq/updateDatabase.h
+++ b/lib/output/pq/updateDatabase.h
@@ -57,6 +57,7 @@ namespace MyGrate::Output::Pq {
void deleteRow(MariaDB_Event_Ptr) override;
void insertRow(MariaDB_Event_Ptr) override;
void tableMap(MariaDB_Event_Ptr) override;
+ void rotate(MariaDB_Event_Ptr) override;
const uint64_t source;
const std::string schema;