Commit 420d6e68 authored by Marcin Siodelski's avatar Marcin Siodelski

[#93,!63] Fixed update statement for option definition.

parent 15c6f450
......@@ -1604,12 +1604,7 @@ public:
/// @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()) {
......@@ -1646,7 +1641,8 @@ public:
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,
......@@ -1663,7 +1659,7 @@ public:
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
};
......
......@@ -307,17 +307,22 @@ namespace {
#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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment