EXPECT_EQ(subnet2->toElement()->str(), returned_subnet->toElement()->str());
// Fetching the subnet for an explicitly specified server tag should
- // succeeed too.
+ // succeed too.
returned_subnet = cbptr_->getSubnet4(ServerSelector::ONE("server1"),
SubnetID(1024));
EXPECT_EQ(subnet2->toElement()->str(), returned_subnet->toElement()->str());
// Fetch this subnet by prefix and verify it matches.
returned_subnet = cbptr_->getSubnet4(ServerSelector::ALL(),
- test_subnets_[2]->toText());
+ test_subnets_[2]->toText());
ASSERT_TRUE(returned_subnet);
EXPECT_EQ(test_subnets_[2]->toElement()->str(), returned_subnet->toElement()->str());
- // Update the the subnet in the database (both use the same prefix).
+ // Update the subnet in the database (both use the same prefix).
subnet2.reset(new Subnet4(IOAddress("192.0.3.0"), 24, 30, 40, 60, 8192));
cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet2);
// Fetch again and verify.
returned_subnet = cbptr_->getSubnet4(ServerSelector::ALL(),
- test_subnets_[2]->toText());
+ test_subnets_[2]->toText());
ASSERT_TRUE(returned_subnet);
EXPECT_EQ(subnet2->toElement()->str(), returned_subnet->toElement()->str());
+
+ // Update the subnet when it conflicts same id and same prefix both
+ // with different subnets. This should throw.
+ // Subnets are 10.0.0.0/8 id 1024 and 192.0.3.0/24 id 8192
+ subnet2.reset(new Subnet4(IOAddress("10.0.0.0"), 8, 30, 40, 60, 8192));
+ EXPECT_THROW(cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet2),
+ DbOperationError);
}
// Test that the information about unspecified optional parameters gets
/// created using static factory functions.
///
/// @param buffer_type MySQL buffer type as defined in MySQL C API.
- /// @param length Buffer length.
+ /// @param length Buffer length.
MySqlBinding(enum_field_types buffer_type, const size_t length);
/// @brief Assigns new value to a buffer.
-// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// Failure: check for the special case of duplicate entry.
if (mysql_errno(mysql_) == ER_DUP_ENTRY) {
isc_throw(DuplicateEntry, "Database duplicate entry error");
- }
+ }
checkError(status, index, "unable to execute");
}
}
status = mysql_stmt_execute(statements_[index]);
if (status != 0) {
+ // Failure: check for the special case of duplicate entry.
+ if (mysql_errno(mysql_) == ER_DUP_ENTRY) {
+ isc_throw(DuplicateEntry, "Database duplicate entry error");
+ }
checkError(status, index, "unable to execute");
}