From: Marcin Siodelski Date: Thu, 25 Aug 2016 07:09:19 +0000 (+0200) Subject: [4489] Addressed second set of review comments. X-Git-Tag: trac4631_base~9^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=7afd2addc6cc39dfae6bed62f52866247b9e9d68;p=thirdparty%2Fkea.git [4489] Addressed second set of review comments. Expand vector of statements depending on statement index and some little fixes in doxygen. --- diff --git a/src/lib/dhcpsrv/mysql_connection.cc b/src/lib/dhcpsrv/mysql_connection.cc index 9569b4e8d3..06162bdf1e 100644 --- a/src/lib/dhcpsrv/mysql_connection.cc +++ b/src/lib/dhcpsrv/mysql_connection.cc @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -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); } diff --git a/src/lib/dhcpsrv/mysql_connection.h b/src/lib/dhcpsrv/mysql_connection.h index 89ad0ec593..4f84731bcd 100644 --- a/src/lib/dhcpsrv/mysql_connection.h +++ b/src/lib/dhcpsrv/mysql_connection.h @@ -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. diff --git a/src/lib/dhcpsrv/pgsql_connection.h b/src/lib/dhcpsrv/pgsql_connection.h index 2ff1831203..b0d793b611 100644 --- a/src/lib/dhcpsrv/pgsql_connection.h +++ b/src/lib/dhcpsrv/pgsql_connection.h @@ -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.