Commit 7f4847e9 authored by Francis Dupont's avatar Francis Dupont

[354-compilation-with-mysql-fails-on-fedora-29] Solved other issues

parent ef559d3c
......@@ -101,6 +101,11 @@ The following environment variable can affect the unit tests:
mysql> GRANT ALL ON keatest.* TO 'keatest'@'localhost';
mysql> GRANT SELECT ON keatest.* TO 'keatest_readonly'@'localhost';
mysql>@endverbatim\n
-# If you get <i>You do not have the SUPER privilege and binary logging is
enabled</i> error message, you need to add:
@verbatim
mysql> SET GLOBAL LOG_BIN_TRUST_FUNCTION_CREATORS = 1;
mysql>@endverbatim\n
-# Exit MySQL:
@verbatim
mysql> quit
......
......@@ -220,10 +220,14 @@ public:
/// data associated with one of the "bind" elements, the
/// corresponding element in the error array is set to MLM_TRUE.
static void setErrorIndicators(std::vector<MYSQL_BIND>& bind,
std::vector<my_bool>& error) {
std::vector<my_bools>& error) {
for (size_t i = 0; i < error.size(); ++i) {
error[i] = MLM_FALSE;
#ifdef HAVE_MYSQL_MY_BOOL
bind[i].error = reinterpret_cast<char*>(&error[i]);
#else
bind[i].error = reinterpret_cast<bool*>(&error[i]);
#endif
}
};
......@@ -240,7 +244,7 @@ public:
/// the error.
/// @param names Array of column names, the same size as the error array.
/// @param count Size of each of the arrays.
static std::string getColumnsInError(std::vector<my_bool>& error,
static std::string getColumnsInError(std::vector<my_bools>& error,
const std::vector<std::string>& names) {
std::string result = "";
......@@ -723,7 +727,7 @@ protected:
std::vector<std::string> columns_;
/// Error array.
std::vector<my_bool> error_;
std::vector<my_bools> error_;
/// Pointer to Host object holding information to be inserted into
/// Hosts table.
......
......@@ -336,7 +336,11 @@ public:
size_t count) {
for (size_t i = 0; i < count; ++i) {
error[i] = MLM_FALSE;
#ifdef HAVE_MYSQL_MY_BOOL
bind[i].error = reinterpret_cast<char*>(&error[i]);
#else
bind[i].error = &error[i];
#endif
}
}
......
......@@ -23,6 +23,8 @@ using namespace std;
namespace isc {
namespace db {
bool MySqlHolder::atexit_ = false;
/// @todo: Migrate this default value to src/bin/dhcpX/simple_parserX.cc
const int MYSQL_DEFAULT_CONNECTION_TIMEOUT = 5; // seconds
......
......@@ -92,10 +92,15 @@ public:
/// @brief Constructor
///
/// Push a call to mysql_library_end() at exit time.
/// Initialize MySql and store the associated context object.
///
/// @throw DbOpenError Unable to initialize MySql handle.
MySqlHolder() : mysql_(mysql_init(NULL)) {
if (!atexit_) {
atexit([]{ mysql_library_end(); });
atexit_ = true;
}
if (mysql_ == NULL) {
isc_throw(db::DbOpenError, "unable to initialize MySQL");
}
......@@ -108,8 +113,7 @@ public:
if (mysql_ != NULL) {
mysql_close(mysql_);
}
// The library itself shouldn't be needed anymore
mysql_library_end();
// @note Moved the call to mysql_library_end() to atexit.
}
/// @brief Conversion Operator
......@@ -121,7 +125,9 @@ public:
}
private:
MYSQL* mysql_; ///< Initialization context
static bool atexit_; ///< Flag to call atexit once.
MYSQL* mysql_; ///< Initialization context
};
/// @brief Forward declaration to @ref MySqlConnection.
......
......@@ -17,6 +17,9 @@ namespace db {
//@{
#ifdef HAVE_MYSQL_MY_BOOL
/// @brief my_bools type for vectors.
typedef my_bool my_bools;
/// @brief MySQL false value.
const my_bool MLM_FALSE = 0;
......@@ -24,9 +27,13 @@ const my_bool MLM_FALSE = 0;
const my_bool MLM_TRUE = 1;
#else
/// @brief my_bool type for MySQL 8.x.
/// @brief my_bool type in MySQL 8.x.
typedef bool my_bool;
/// @brief my_bools type for vectors in MySQL 8.x.
/// @note vector<my_bool> is specialized into a bitset.
typedef char my_bools;
/// @brief MySQL false value.
const my_bool MLM_FALSE = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment