]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[354-compilation-with-mysql-fails-on-fedora-29] Solved other issues
authorFrancis Dupont <fdupont@isc.org>
Sat, 22 Dec 2018 01:03:33 +0000 (02:03 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 7 Feb 2019 22:02:22 +0000 (17:02 -0500)
doc/devel/unit-tests.dox
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/mysql/mysql_connection.cc
src/lib/mysql/mysql_connection.h
src/lib/mysql/mysql_constants.h

index cf3964813401b87a7948267496cc19873a39c141..937502ed828cf569c16f56432226b06fcd7f431d 100644 (file)
@@ -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
index d6c63585db548a576cd2192abe0ffdb47939ca92..75e2d17e1818ca6bdfe7d019f186a5d03f356ebe 100644 (file)
@@ -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.
index a663e781af766d28410165bd230bfed8026793fc..ef41e92e04c80aa7eb8bba85e0cd5efd67fc8b06 100644 (file)
@@ -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
         }
     }
 
index e51a61f13c069f5a871e3d873ea3f77ff68b35bd..0e9f001d5b6d7c90827abbafd3a05bc963d7b210 100644 (file)
@@ -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
 
index 82ce504cf173b17de3d9e8ecd2ea3d641de19ce4..183934ca59bd66d63465b154b08e131a3fb8295e 100644 (file)
@@ -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.
index 64b052017cda2696ed27b014a88020ed97182b0f..a18c4e027c22dab4209edc5c8bf42e85d2b53f89 100644 (file)
@@ -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;