Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
b1ecd2e7
Commit
b1ecd2e7
authored
Apr 01, 2016
by
Marcin Siodelski
Browse files
[4302] Additional indexes added to search for hosts in MySQL.
parent
9900e40c
Changes
3
Show whitespace changes
Inline
Side-by-side
src/bin/admin/scripts/mysql/dhcpdb_create.mysql
View file @
b1ecd2e7
...
...
@@ -406,6 +406,15 @@ CREATE UNIQUE INDEX key_dhcp4_identifier_subnet_id ON hosts (dhcp_identifier ASC
DROP INDEX key_dhcp6_identifier_subnet_id ON hosts;
CREATE UNIQUE INDEX key_dhcp6_identifier_subnet_id ON hosts (dhcp_identifier ASC , dhcp_identifier_type ASC , dhcp6_subnet_id ASC);
# Create index to search for reservations using IP address and subnet id.
# This unique index guarantees that there is only one occurence of the
# particular IPv4 address for a given subnet.
CREATE UNIQUE INDEX key_dhcp4_ipv4_address_subnet_id ON hosts (ipv4_address ASC , dhcp4_subnet_id ASC);
# Create index to search for reservations using address/prefix and prefix
# length.
CREATE INDEX key_dhcp6_address_prefix_len ON ipv6_reservations (address ASC , prefix_len ASC);
# Create a table mapping host identifiers to their names. Values in this
# table are used as a foreign key in hosts table to guarantee that only
# identifiers present in host_identifier_type table are used in hosts
...
...
src/lib/dhcpsrv/tests/generic_host_data_source_unittest.cc
View file @
b1ecd2e7
...
...
@@ -842,6 +842,17 @@ void GenericHostDataSourceTest::testAddDuplicate4() {
// Then try to add it again, it should throw an exception.
ASSERT_THROW
(
hdsptr_
->
add
(
host
),
DuplicateEntry
);
// This time use a different host identifier and try again.
// This update should be rejected because of duplicated
// address.
ASSERT_NO_THROW
(
host
->
setIdentifier
(
"01:02:03:04:05:06"
,
"hw-address"
));
ASSERT_THROW
(
hdsptr_
->
add
(
host
),
DuplicateEntry
);
// Modify address to avoid its duplication and make sure
// we can now add the host.
ASSERT_NO_THROW
(
host
->
setIPv4Reservation
(
IOAddress
(
"192.0.2.3"
)));
EXPECT_NO_THROW
(
hdsptr_
->
add
(
host
));
}
void
GenericHostDataSourceTest
::
testAddr6AndPrefix
(){
...
...
src/lib/dhcpsrv/testutils/schema_mysql_copy.h
View file @
b1ecd2e7
...
...
@@ -266,6 +266,13 @@ const char* create_statement[] = {
"ON hosts "
"(dhcp_identifier ASC , dhcp_identifier_type ASC , dhcp6_subnet_id ASC)"
,
"CREATE UNIQUE INDEX key_dhcp4_ipv4_address_subnet_id "
"ON hosts "
"(ipv4_address ASC, dhcp4_subnet_id ASC)"
,
"CREATE INDEX key_dhcp6_address_prefix_len "
"ON ipv6_reservations (address ASC , prefix_len ASC)"
,
"CREATE TABLE IF NOT EXISTS host_identifier_type ("
"type TINYINT PRIMARY KEY NOT NULL,"
"name VARCHAR(32)"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment