]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4489] Addressed second set of review comments.
authorMarcin Siodelski <marcin@isc.org>
Thu, 25 Aug 2016 07:09:19 +0000 (09:09 +0200)
committerMarcin Siodelski <marcin@isc.org>
Thu, 25 Aug 2016 07:09:19 +0000 (09:09 +0200)
Expand vector of statements depending on statement index and
some little fixes in doxygen.

src/lib/dhcpsrv/mysql_connection.cc
src/lib/dhcpsrv/mysql_connection.h
src/lib/dhcpsrv/pgsql_connection.h

index 9569b4e8d3f1ac8021806ef72335a021be1a7094..06162bdf1e6ea92de89d811bd5a907a325d29b94 100644 (file)
@@ -12,7 +12,6 @@
 #include <boost/lexical_cast.hpp>
 
 #include <algorithm>
-#include <iterator>
 #include <stdint.h>
 #include <string>
 #include <limits>
@@ -215,18 +214,14 @@ MySqlConnection::prepareStatement(uint32_t index, const char* text) {
 void
 MySqlConnection::prepareStatements(const TaggedStatement* start_statement,
                                    const TaggedStatement* end_statement) {
-    size_t num_statements = std::distance(start_statement, end_statement);
-    if (num_statements == 0) {
-        return;
-    }
-
-    // Expand vectors of allocated statements to hold additional statements.
-    statements_.resize(statements_.size() + num_statements, NULL);
-    text_statements_.resize(text_statements_.size() + num_statements, std::string(""));
-
     // Created the MySQL prepared statements for each DML statement.
     for (const TaggedStatement* tagged_statement = start_statement;
          tagged_statement != end_statement; ++tagged_statement) {
+        if (tagged_statement->index >= statements_.size()) {
+            statements_.resize(tagged_statement->index + 1, NULL);
+            text_statements_.resize(tagged_statement->index + 1,
+                                    std::string(""));
+        }
         prepareStatement(tagged_statement->index,
                          tagged_statement->text);
     }
index 89ad0ec59371bf4f9064596fee22d3a6d8fdc2d7..4f84731bcd01a53cf09576dd91a0c74341ea979f 100644 (file)
@@ -240,7 +240,11 @@ public:
     ///
     /// Creates the prepared statements for all of the SQL statements used
     /// by the MySQL backend.
-    /// @param tagged_statements an array of statements to be compiled
+    ///
+    /// @param start_statement Pointer to the first statement in range of the
+    /// statements to be compiled.
+    /// @param end_statement Pointer to the statement marking end of the
+    /// range of statements to be compiled. This last statement is not compiled.
     ///
     /// @throw isc::dhcp::DbOperationError An operation on the open database has
     ///        failed.
index 2ff1831203f067fa302a51a0ed44ee193be6ce58..b0d793b6111604e16ffe82633e32b8a77f49c55c 100644 (file)
@@ -317,7 +317,11 @@ public:
     ///
     /// Creates the prepared statements for all of the SQL statements used
     /// by the PostgreSQL backend.
-    /// @param tagged_statements an array of statements to be compiled
+    ///
+    /// @param start_statement Pointer to the first statement in range of the
+    /// statements to be compiled.
+    /// @param end_statement Pointer to the statement marking end of the
+    /// range of statements to be compiled. This last statement is not compiled.
     ///
     /// @throw isc::dhcp::DbOperationError An operation on the open database has
     ///        failed.