-- 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.
-- 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 ;
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
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);
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;
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);
-- 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.
-- 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 ;
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
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);
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;
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);