#include <boost/lexical_cast.hpp>
#include <algorithm>
-#include <iterator>
#include <stdint.h>
#include <string>
#include <limits>
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);
}
///
/// 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.
///
/// 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.