From 20d70ed0b307a9abe7fd42b4055f764c465599cc Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Mon, 24 Apr 2017 16:19:37 +0200 Subject: [PATCH] [5208] Multiple fixes as a result of review. The most notable change is the update of the MySQL trigger which deletes options as a consequence of deletion of the host. --- doc/guide/hooks.xml | 4 ++-- src/lib/dhcpsrv/mysql_host_data_source.cc | 4 ++-- .../database/scripts/mysql/dhcpdb_create.mysql | 15 +++++++++++++++ .../scripts/mysql/upgrade_5.0_to_5.1.sh.in | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/doc/guide/hooks.xml b/doc/guide/hooks.xml index e63932db42..7bfb23e00a 100644 --- a/doc/guide/hooks.xml +++ b/doc/guide/hooks.xml @@ -207,7 +207,7 @@ Flexible Identifier Support customers - Kea 1.2.0 beta + Kea 1.2.0 Kea software provides a way to handle host reservations that include addresses, prefixes, options, client classes and other features. The reservation can be based on hardware address, @@ -582,7 +582,7 @@ link address: 3001::1, hop count: 1, identified by remote-id: Currently this library is only available to ISC customers with a support contract. - The library allows defining an expression, using notation + The library allows for defining an expression, using notation initially used for client classification only. See for detailed description of the syntax available. One notable difference is that for client diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index f571c24d2c..8c6efec17b 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -295,11 +295,11 @@ public: // The address in the Host structure is an IOAddress object. Convert // this to an integer for storage. ipv4_address_ = host->getIPv4Reservation().toUint32(); + ipv4_address_null_ = ipv4_address_ == 0 ? MLM_TRUE : MLM_FALSE; bind_[5].buffer_type = MYSQL_TYPE_LONG; bind_[5].buffer = reinterpret_cast(&ipv4_address_); bind_[5].is_unsigned = MLM_TRUE; - // bind_[5].is_null = &MLM_FALSE; // commented out for performance - // reasons, see memset() above + bind_[5].is_null = &ipv4_address_null_; // hostname : VARCHAR(255) NULL strncpy(hostname_, host->getHostname().c_str(), HOSTNAME_MAX_LEN - 1); diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index 6ee0df3842..ba946f7b9b 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -483,6 +483,21 @@ SET version = '5', minor = '0'; # Add missing 'client-id' host identifier type. INSERT INTO host_identifier_type VALUES (3, 'client-id'); +# Recreate the trigger removing dependent host entries. +DROP TRIGGER host_BDEL; + +DELIMITER $$ +CREATE TRIGGER host_BDEL BEFORE DELETE ON hosts FOR EACH ROW +-- Edit trigger body code below this line. Do not edit lines above this one +BEGIN +DELETE FROM ipv6_reservations WHERE ipv6_reservations.host_id = OLD.host_id; +DELETE FROM dhcp4_options WHERE dhcp4_options.host_id = OLD.host_id; +DELETE FROM dhcp6_options WHERE dhcp6_options.host_id = OLD.host_id; +END +$$ +DELIMITER ; + + # Update the schema version number UPDATE schema_version SET version = '5', minor = '1'; diff --git a/src/share/database/scripts/mysql/upgrade_5.0_to_5.1.sh.in b/src/share/database/scripts/mysql/upgrade_5.0_to_5.1.sh.in index 86385baddd..f8440b3a12 100644 --- a/src/share/database/scripts/mysql/upgrade_5.0_to_5.1.sh.in +++ b/src/share/database/scripts/mysql/upgrade_5.0_to_5.1.sh.in @@ -20,6 +20,20 @@ mysql "$@" <