explicit MySqlConfigBackendDHCPv4Impl(const DatabaseConnection::ParameterMap&
parameters);
- /// @brief Sends query to retrieve multiple global parameters.
- ///
- /// @param index Index of the query to be used.
- /// @param in_bindings Input bindings specifying selection criteria. The
- /// size of the bindings collection must match the number of placeholders
- /// in the prepared statement. The input bindings collection must be empty
- /// if the query contains no WHERE clause.
- /// @param [out] subnets Reference to the container where fetched parameters
- /// will be inserted.
- void getGlobalParameters4(const StatementIndex& index,
- const MySqlBindingCollection& in_bindings,
- StampedValueCollection& parameters) {
- // The following parameters from the dhcp4_global_parameter table are
- // returned:
- // - id
- // - name - parameter name
- // - value - parameter value
- // - modification_ts - modification timestamp.
- MySqlBindingCollection out_bindings = {
- MySqlBinding::createInteger<uint64_t>(), // id
- MySqlBinding::createString(GLOBAL_PARAMETER_NAME_BUF_LENGTH), // name
- MySqlBinding::createString(GLOBAL_PARAMETER_VALUE_BUF_LENGTH), // value
- MySqlBinding::createInteger<uint8_t>(), // parameter_type
- MySqlBinding::createTimestamp() // modification_ts
- };
-
- conn_.selectQuery(index, in_bindings, out_bindings,
- [¶meters]
- (MySqlBindingCollection& out_bindings) {
- if (!out_bindings[1]->getString().empty()) {
-
- // Convert value read as string from the database to the actual
- // data type known from the database as binding #3.
- StampedValuePtr stamped_value =
- StampedValue::create(out_bindings[1]->getString(),
- out_bindings[2]->getString(),
- static_cast<Element::types>
- (out_bindings[3]->getInteger<uint8_t>()));
-
- stamped_value->setModificationTime(out_bindings[4]->getTimestamp());
- parameters.insert(stamped_value);
- }
- });
- }
-
/// @brief Sends query to retrieve global parameter.
///
/// @param server_selector Server selector.
MySqlBinding::createString(name)
};
- getGlobalParameters4(GET_GLOBAL_PARAMETER4, in_bindings, parameters);
+ getGlobalParameters(GET_GLOBAL_PARAMETER4, in_bindings, parameters);
}
return (parameters.empty() ? StampedValuePtr() : *parameters.begin());
auto tags = impl_->getServerTags(server_selector);
for (auto tag : tags) {
MySqlBindingCollection in_bindings = { MySqlBinding::createString(tag) };
- impl_->getGlobalParameters4(MySqlConfigBackendDHCPv4Impl::GET_ALL_GLOBAL_PARAMETERS4,
- in_bindings, parameters);
+ impl_->getGlobalParameters(MySqlConfigBackendDHCPv4Impl::GET_ALL_GLOBAL_PARAMETERS4,
+ in_bindings, parameters);
}
return (parameters);
}
MySqlBinding::createString(tag),
MySqlBinding::createTimestamp(modification_time)
};
- impl_->getGlobalParameters4(MySqlConfigBackendDHCPv4Impl::GET_MODIFIED_GLOBAL_PARAMETERS4,
- in_bindings, parameters);
+ impl_->getGlobalParameters(MySqlConfigBackendDHCPv4Impl::GET_MODIFIED_GLOBAL_PARAMETERS4,
+ in_bindings, parameters);
}
return (parameters);
return (deleteFromTable(index, server_selector, operation, in_bindings));
}
+void
+MySqlConfigBackendImpl::getGlobalParameters(const int index,
+ const MySqlBindingCollection& in_bindings,
+ StampedValueCollection& parameters) {
+ // The following parameters from the dhcp[46]_global_parameter table are
+ // returned:
+ // - id
+ // - name - parameter name
+ // - value - parameter value
+ // - modification_ts - modification timestamp.
+ MySqlBindingCollection out_bindings = {
+ MySqlBinding::createInteger<uint64_t>(), // id
+ MySqlBinding::createString(GLOBAL_PARAMETER_NAME_BUF_LENGTH), // name
+ MySqlBinding::createString(GLOBAL_PARAMETER_VALUE_BUF_LENGTH), // value
+ MySqlBinding::createInteger<uint8_t>(), // parameter_type
+ MySqlBinding::createTimestamp() // modification_ts
+ };
+
+ conn_.selectQuery(index, in_bindings, out_bindings,
+ [¶meters] (MySqlBindingCollection& out_bindings) {
+ if (!out_bindings[1]->getString().empty()) {
+
+ // Convert value read as string from the database to the actual
+ // data type known from the database as binding #3.
+ StampedValuePtr stamped_value =
+ StampedValue::create(out_bindings[1]->getString(),
+ out_bindings[2]->getString(),
+ static_cast<Element::types>
+ (out_bindings[3]->getInteger<uint8_t>()));
+
+ stamped_value->setModificationTime(out_bindings[4]->getTimestamp());
+ parameters.insert(stamped_value);
+ }
+ });
+}
+
void
MySqlConfigBackendImpl::getOptionDefs(const int index,
const MySqlBindingCollection& in_bindings,
#ifndef MYSQL_CONFIG_BACKEND_IMPL_H
#define MYSQL_CONFIG_BACKEND_IMPL_H
+#include <cc/stamped_value.h>
#include <database/audit_entry.h>
#include <database/database_connection.h>
#include <database/server_selector.h>
return (deleteFromTable(index, server_selector, operation, in_bindings));
}
+ /// @brief Sends query to retrieve multiple global parameters.
+ ///
+ /// @param index Index of the query to be used.
+ /// @param in_bindings Input bindings specifying selection criteria. The
+ /// size of the bindings collection must match the number of placeholders
+ /// in the prepared statement. The input bindings collection must be empty
+ /// if the query contains no WHERE clause.
+ /// @param [out] subnets Reference to the container where fetched parameters
+ /// will be inserted.
+ void getGlobalParameters(const int index,
+ const db::MySqlBindingCollection& in_bindings,
+ data::StampedValueCollection& parameters);
+
/// @brief Sends query to the database to retrieve multiple option
/// definitions.
///