summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/input/mysqlConn.cpp10
-rw-r--r--lib/input/mysqlConn.h2
-rw-r--r--lib/input/replStream.cpp5
3 files changed, 13 insertions, 4 deletions
diff --git a/lib/input/mysqlConn.cpp b/lib/input/mysqlConn.cpp
index 6c00628..3a2c9f4 100644
--- a/lib/input/mysqlConn.cpp
+++ b/lib/input/mysqlConn.cpp
@@ -1,4 +1,6 @@
#include "mysqlConn.h"
+#include "helpers.h"
+#include <mysql.h>
#include <stdexcept>
namespace MyGrate::Input {
@@ -11,11 +13,17 @@ namespace MyGrate::Input {
mysql_close(this);
throw std::runtime_error("ConnectionError");
}
- mysql_query(this, "SET NAMES utf8");
+ verify<std::runtime_error>(!mysql_set_character_set(this, "utf8"), "Set character set");
}
MySQLConn::~MySQLConn()
{
mysql_close(this);
}
+
+ void
+ MySQLConn::query(const char * const q)
+ {
+ verify<std::runtime_error>(!mysql_query(this, q), q);
+ }
}
diff --git a/lib/input/mysqlConn.h b/lib/input/mysqlConn.h
index fa3712c..2f57f33 100644
--- a/lib/input/mysqlConn.h
+++ b/lib/input/mysqlConn.h
@@ -8,6 +8,8 @@ namespace MyGrate::Input {
public:
MySQLConn(const char * const host, const char * const user, const char * const pass, unsigned short port);
~MySQLConn();
+
+ void query(const char * const);
};
}
diff --git a/lib/input/replStream.cpp b/lib/input/replStream.cpp
index c894941..0de91b5 100644
--- a/lib/input/replStream.cpp
+++ b/lib/input/replStream.cpp
@@ -3,7 +3,6 @@
#include <eventHandlerBase.h>
#include <eventHandlers.h>
#include <memory>
-#include <mysql.h>
#include <stdexcept>
#include <utility>
@@ -14,8 +13,8 @@ namespace MyGrate::Input {
using MariaDB_Rpl_Ptr = std::unique_ptr<MARIADB_RPL, decltype(&mariadb_rpl_close)>;
auto rpl = MariaDB_Rpl_Ptr {mariadb_rpl_init(this), &mariadb_rpl_close};
- mysql_query(this, "SET @mariadb_slave_capability = 4");
- mysql_query(this, "SET @master_binlog_checksum = @@global.binlog_checksum");
+ query("SET @mariadb_slave_capability = 4");
+ query("SET @master_binlog_checksum = @@global.binlog_checksum");
mariadb_rpl_optionsv(rpl.get(), MARIADB_RPL_SERVER_ID, 12);
mariadb_rpl_optionsv(rpl.get(), MARIADB_RPL_FILENAME, "mariadb-bin.000242");