summaryrefslogtreecommitdiff
path: root/lib/output/pq
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/pq')
-rw-r--r--lib/output/pq/updateDatabase.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/output/pq/updateDatabase.cpp b/lib/output/pq/updateDatabase.cpp
index 99d2861..f344f42 100644
--- a/lib/output/pq/updateDatabase.cpp
+++ b/lib/output/pq/updateDatabase.cpp
@@ -47,10 +47,11 @@ namespace MyGrate::Output::Pq {
{
Input::MySQLConn my {host, username, password, port};
auto ms = input::sql::showMasterStatus::execute(&my);
- auto source_id = output::pq::sql::insertSource::execute(
- pq, host, username, password, port, db, ms->at(0, 0), ms->at(0, 1), sid, schema);
- pq->query(scprintf<"CREATE SCHEMA IF NOT EXISTS %?">(schema).c_str());
-
- return UpdateDatabase(pq->connstr.c_str(), source_id->at(0, 0));
+ auto source_id = Tx {pq}([&]() {
+ pq->query(scprintf<"CREATE SCHEMA IF NOT EXISTS %?">(schema).c_str());
+ return **output::pq::sql::insertSource::execute(
+ pq, host, username, password, port, db, ms->at(0, 0), ms->at(0, 1), sid, schema);
+ });
+ return UpdateDatabase(pq->connstr.c_str(), source_id);
}
}