Browse Source

[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.
Marcin Siodelski 8 years ago
parent
commit
20d70ed0b3

+ 2 - 2
doc/guide/hooks.xml

@@ -207,7 +207,7 @@
             <row>
               <entry>Flexible Identifier</entry>
               <entry>Support customers</entry>
-              <entry>Kea 1.2.0 beta</entry>
+              <entry>Kea 1.2.0</entry>
               <entry>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:
         <para>Currently this library is only available to ISC customers with a
         support contract.</para>
 
-        <para>The library allows defining an expression, using notation
+        <para>The library allows for defining an expression, using notation
         initially used for client classification only. See <xref
         linkend="classification-using-expressions" /> for detailed description
         of the syntax available. One notable difference is that for client

+ 2 - 2
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<char*>(&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);

+ 15 - 0
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';

+ 14 - 0
src/share/database/scripts/mysql/upgrade_5.0_to_5.1.sh.in

@@ -20,6 +20,20 @@ mysql "$@" <<EOF
 # 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';