/// @param option_def Pointer to the option definition to be inserted or updated.
void createUpdateOptionDef4(const ServerSelector& server_selector,
const OptionDefinitionPtr& option_def) {
- auto tags = getServerTags(server_selector);
- if (tags.size() != 1) {
- isc_throw(InvalidOperation, "expected exactly one server tag to be"
- " specified while creating or updating option definition."
- " Got: " << getServerTagsAsText(server_selector));
- }
+ auto tag = getServerTag(server_selector, "creating or updating option definition");
ElementPtr record_types = Element::createList();
for (auto field : option_def->getRecordFields()) {
option_def->getCode(),
option_def->getOptionSpaceName());
if (existing_definition) {
- // Need to add two more bindings for WHERE clause.
+ // Need to add three more bindings for WHERE clause.
+ in_bindings.push_back(MySqlBinding::createString(tag));
in_bindings.push_back(MySqlBinding::createInteger<uint8_t>(existing_definition->getCode()));
in_bindings.push_back(MySqlBinding::createString(existing_definition->getOptionSpaceName()));
conn_.updateDeleteQuery(MySqlConfigBackendDHCPv4Impl::UPDATE_OPTION_DEF4,
MySqlBindingCollection in_server_bindings = {
MySqlBinding::createInteger<uint64_t>(id), // option_def_id
- MySqlBinding::createString(*tags.begin()), // tag used to obtain server_id
+ MySqlBinding::createString(tag), // tag used to obtain server_id
MySqlBinding::createTimestamp(option_def->getModificationTime()), // modification_ts
};
#ifndef MYSQL_UPDATE_OPTION_DEF
#define MYSQL_UPDATE_OPTION_DEF(table_prefix) \
- "UPDATE " #table_prefix "_option_def SET" \
- " code = ?," \
- " name = ?," \
- " space = ?," \
- " type = ?," \
- " modification_ts = ?," \
- " array = ?," \
- " encapsulate = ?," \
- " record_types = ?," \
- " user_context = ? " \
- "WHERE code = ? AND space = ?"
+ "UPDATE " #table_prefix "_option_def AS d " \
+ "INNER JOIN " #table_prefix "_option_def_server AS a" \
+ " ON d.id = a.option_def_id " \
+ "INNER JOIN " #table_prefix "_server AS s" \
+ " ON a.server_id = s.id " \
+ "SET" \
+ " d.code = ?," \
+ " d.name = ?," \
+ " d.space = ?," \
+ " d.type = ?," \
+ " d.modification_ts = ?," \
+ " d.array = ?," \
+ " d.encapsulate = ?," \
+ " d.record_types = ?," \
+ " d.user_context = ? " \
+ "WHERE s.tag = ? AND d.code = ? AND d.space = ?"
#endif
#ifndef MYSQL_UPDATE_OPTION