]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4373] Addressed more review comments
authorThomas Markwalder <tmark@isc.org>
Tue, 31 Mar 2026 11:59:23 +0000 (07:59 -0400)
committerThomas Markwalder <tmark@isc.org>
Tue, 31 Mar 2026 14:33:50 +0000 (14:33 +0000)
modified:   src/share/database/scripts/mysql/dhcpdb_create.mysql
modified:   src/share/database/scripts/mysql/upgrade_033_to_034.sh.in

src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_033_to_034.sh.in

index 677140af7913f634bddda3816abd081a2b2e4d66..99418996c6ddea02543e9bb8770226da96d16a09 100644 (file)
@@ -6611,8 +6611,8 @@ BEGIN
 
     -- Explanation: n_bytes specifies number of full bytes that are in-prefix.
     -- They can also be used as an offset for the first byte that is not in
-    -- prefix. n_bits specifies number of bits on the last byte that is
-    -- (often partially) in prefix. For example for a /125 prefix, the values
+    -- prefix. n_bits specifies number of lsb bits on the last byte that
+    -- are not in-prefix. For example for a /125 prefix, the values
     -- are 15 and 3, respectively. Mask is a bitmask that has the least
     -- significant bit from the prefix set.
 
@@ -6679,37 +6679,37 @@ BEGIN
     -- Ignore unknown variable errors.
     DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
 
-    IF (@kea_recursive_limit IS NOT NULL)
+    IF (@kea_recursion_limit IS NOT NULL)
     THEN
         -- Alreaddy set it.
         LEAVE SP;
     END IF;
 
     -- Try Mariab variable
-    SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursive_limit";
+    SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursion_limit";
     PREPARE stmt FROM @sqlv;
     EXECUTE stmt;
     DEALLOCATE PREPARE stmt;
-    IF (@kea_recursive_limit IS NOT NULL)
+    IF (@kea_recursion_limit IS NOT NULL)
     THEN
         -- We found it, all done.
         LEAVE SP;
     END IF;
 
     -- Try MySQL variable.
-    SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursive_limit";
+    SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursion_limit";
     PREPARE stmt FROM @sqlv;
     EXECUTE stmt;
     DEALLOCATE PREPARE stmt;
 
-    IF (@kea_recursive_limit IS NOT NULL)
+    IF (@kea_recursion_limit IS NOT NULL)
     THEN
         -- We found it, all done.
         LEAVE SP;
     END IF;
 
     -- Found neither use a default.
-    SET @kea_recursive_limit = 100;
+    SET @kea_recursion_limit = 100;
 END $$
 DELIMITER ;
 
@@ -6752,7 +6752,7 @@ BEGIN
     SET loop_limit = @kea_recursion_limit;
     SET next_start_address = p_start_address;
     SET next_end_address = p_start_address;
-    WHILE next_start_address < p_end_address DO
+    WHILE next_start_address <= p_end_address DO
         SET remaining = p_end_address - next_start_address;
         IF (remaining > loop_limit)
         THEN
@@ -6790,7 +6790,7 @@ DELIMITER $$
 CREATE FUNCTION sflqPickFreeLease4(alloc_start_address INT UNSIGNED,
                                    alloc_end_address INT UNSIGNED)
 RETURNS INT UNSIGNED
-DETERMINISTIC
+READS SQL DATA
 BEGIN
     -- Declarations
     DECLARE pool_id BIGINT(20);
@@ -6822,17 +6822,19 @@ BEGIN
         LEFT JOIN lease4 on f.address = lease4.address
         WHERE (f.address > last_address and f.address <= alloc_end_address)
         AND (lease4.address IS NULL OR lease4.state = 2)
+        ORDER BY f.address ASC
         LIMIT 1;
 
     -- Didn't find one, so try front half of the range, including
     -- the last pick. This avoids returning nothing if there is only
     -- one address free.
-    IF (free_address = 0 AND last_address != alloc_start_address)
+    IF (free_address = 0)
     THEN
         SELECT f.address INTO free_address FROM free_lease4 f
             LEFT JOIN lease4 on f.address = lease4.address
             WHERE (f.address >= alloc_start_address AND f.address <= last_address)
             AND (lease4.address IS NULL OR lease4.state = 2)
+            ORDER BY f.address ASC
             LIMIT 1;
     END IF;
 
@@ -6938,7 +6940,7 @@ DELIMITER $$
 CREATE FUNCTION sflqPickFreeLease6(alloc_start_address VARCHAR(45),
                                    alloc_end_address VARCHAR(45))
 RETURNS VARCHAR(45)
-DETERMINISTIC
+READS SQL DATA
 BEGIN
     -- Declarations
     DECLARE pool_id BIGINT(20);
index d52afba3e46a1af7cedc91adf899ac65fd22aa09..79639975095949916a361c8f5c648f6f8dd95162 100755 (executable)
@@ -191,8 +191,8 @@ BEGIN
 
     -- Explanation: n_bytes specifies number of full bytes that are in-prefix.
     -- They can also be used as an offset for the first byte that is not in
-    -- prefix. n_bits specifies number of bits on the last byte that is
-    -- (often partially) in prefix. For example for a /125 prefix, the values
+    -- prefix. n_bits specifies number of lsb bits on the last byte that
+    -- are not in-prefix. For example for a /125 prefix, the values
     -- are 15 and 3, respectively. Mask is a bitmask that has the least
     -- significant bit from the prefix set.
 
@@ -259,37 +259,37 @@ BEGIN
     -- Ignore unknown variable errors.
     DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
 
-    IF (@kea_recursive_limit IS NOT NULL)
+    IF (@kea_recursion_limit IS NOT NULL)
     THEN
         -- Alreaddy set it.
         LEAVE SP;
     END IF;
 
     -- Try Mariab variable
-    SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursive_limit";
+    SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursion_limit";
     PREPARE stmt FROM @sqlv;
     EXECUTE stmt;
     DEALLOCATE PREPARE stmt;
-    IF (@kea_recursive_limit IS NOT NULL)
+    IF (@kea_recursion_limit IS NOT NULL)
     THEN
         -- We found it, all done.
         LEAVE SP;
     END IF;
 
     -- Try MySQL variable.
-    SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursive_limit";
+    SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursion_limit";
     PREPARE stmt FROM @sqlv;
     EXECUTE stmt;
     DEALLOCATE PREPARE stmt;
 
-    IF (@kea_recursive_limit IS NOT NULL)
+    IF (@kea_recursion_limit IS NOT NULL)
     THEN
         -- We found it, all done.
         LEAVE SP;
     END IF;
 
     -- Found neither use a default.
-    SET @kea_recursive_limit = 100;
+    SET @kea_recursion_limit = 100;
 END $$
 DELIMITER ;
 
@@ -332,7 +332,7 @@ BEGIN
     SET loop_limit = @kea_recursion_limit;
     SET next_start_address = p_start_address;
     SET next_end_address = p_start_address;
-    WHILE next_start_address < p_end_address DO
+    WHILE next_start_address <= p_end_address DO
         SET remaining = p_end_address - next_start_address;
         IF (remaining > loop_limit)
         THEN
@@ -370,7 +370,7 @@ DELIMITER $$
 CREATE FUNCTION sflqPickFreeLease4(alloc_start_address INT UNSIGNED,
                                    alloc_end_address INT UNSIGNED)
 RETURNS INT UNSIGNED
-DETERMINISTIC
+READS SQL DATA
 BEGIN
     -- Declarations
     DECLARE pool_id BIGINT(20);
@@ -402,17 +402,19 @@ BEGIN
         LEFT JOIN lease4 on f.address = lease4.address
         WHERE (f.address > last_address and f.address <= alloc_end_address)
         AND (lease4.address IS NULL OR lease4.state = 2)
+        ORDER BY f.address ASC
         LIMIT 1;
 
     -- Didn't find one, so try front half of the range, including
     -- the last pick. This avoids returning nothing if there is only
     -- one address free.
-    IF (free_address = 0 AND last_address != alloc_start_address)
+    IF (free_address = 0)
     THEN
         SELECT f.address INTO free_address FROM free_lease4 f
             LEFT JOIN lease4 on f.address = lease4.address
             WHERE (f.address >= alloc_start_address AND f.address <= last_address)
             AND (lease4.address IS NULL OR lease4.state = 2)
+            ORDER BY f.address ASC
             LIMIT 1;
     END IF;
 
@@ -519,7 +521,7 @@ DELIMITER $$
 CREATE FUNCTION sflqPickFreeLease6(alloc_start_address VARCHAR(45),
                                    alloc_end_address VARCHAR(45))
 RETURNS VARCHAR(45)
-DETERMINISTIC
+READS SQL DATA
 BEGIN
     -- Declarations
     DECLARE pool_id BIGINT(20);