From: Francis Dupont Date: Mon, 14 Oct 2019 14:30:18 +0000 (+0200) Subject: [392-search-of-reservations-by-hostname] Addressed some comments X-Git-Tag: Kea-1.7.1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbaa30d93dc268bd7acd3568f2a1e02cb2aae119;p=thirdparty%2Fkea.git [392-search-of-reservations-by-hostname] Addressed some comments --- diff --git a/doc/sphinx/arm/admin.rst b/doc/sphinx/arm/admin.rst index 1fe978f7a0..f584381b37 100644 --- a/doc/sphinx/arm/admin.rst +++ b/doc/sphinx/arm/admin.rst @@ -321,6 +321,25 @@ earlier version. To perform an upgrade, issue the following command: $ kea-admin db-upgrade mysql -u database-user -p database-password -n database-name +.. note:: + + To search host reservations by hostname it is critical the collation of + the hostname column in the host table to be case-insensitive. Fortunately + the default collation in MySQL is case-insensitive. You can verify this + on your MySQL installation by: + + .. code-block:: mysql + + mysql> SELECT COLLATION(''); + +-----------------+ + | COLLATION('') | + +-----------------+ + | utf8_general_ci | + +-----------------+ + + According to the naming of collations when the name finishes by ``_ci`` + the collation is case-insensitive. + .. _pgsql-database: PostgreSQL diff --git a/src/lib/dhcpsrv/base_host_data_source.h b/src/lib/dhcpsrv/base_host_data_source.h index cb59481140..b7c6af6b4f 100644 --- a/src/lib/dhcpsrv/base_host_data_source.h +++ b/src/lib/dhcpsrv/base_host_data_source.h @@ -141,6 +141,10 @@ public: /// This method returns all @c Host objects which represent reservations /// using a specified hostname. /// + /// @note: as hostnames are case-insensitive the search key is given + /// in lower cases, search indexes should either be case-insensitive + /// or be case-sensitive using the lower case version of hostnames. + /// /// @param hostname The lower case hostname. /// /// @return Collection of const @c Host objects. diff --git a/src/lib/dhcpsrv/cql_host_data_source.h b/src/lib/dhcpsrv/cql_host_data_source.h index c90e3b1f55..a4be71b159 100644 --- a/src/lib/dhcpsrv/cql_host_data_source.h +++ b/src/lib/dhcpsrv/cql_host_data_source.h @@ -198,6 +198,8 @@ public: /// This method returns all @c Host objects which represent reservations /// using a specified hostname. /// + /// Cassandra uses the new indexed lower_case_hostname column. + /// /// @param hostname The lower case hostname. /// /// @return Collection of const @c Host objects. diff --git a/src/lib/dhcpsrv/host_container.h b/src/lib/dhcpsrv/host_container.h index 55692cf25d..113f4b8b13 100644 --- a/src/lib/dhcpsrv/host_container.h +++ b/src/lib/dhcpsrv/host_container.h @@ -91,6 +91,7 @@ typedef boost::multi_index_container< >, // Sixth index is used to search for the host using hostname + // (case-sensitive compare so the key is in lower case). boost::multi_index::ordered_non_unique< // Index using values returned by the @c Host::getLowerHostname boost::multi_index::const_mem_fun