Skip to content

Commit 0f9d359

Browse files
committed
[#4373] Addressed more review comments
modified: src/share/database/scripts/mysql/dhcpdb_create.mysql modified: src/share/database/scripts/mysql/upgrade_033_to_034.sh.in
1 parent 13d031c commit 0f9d359

2 files changed

Lines changed: 28 additions & 24 deletions

File tree

src/share/database/scripts/mysql/dhcpdb_create.mysql

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6611,8 +6611,8 @@ BEGIN
66116611

66126612
-- Explanation: n_bytes specifies number of full bytes that are in-prefix.
66136613
-- They can also be used as an offset for the first byte that is not in
6614-
-- prefix. n_bits specifies number of bits on the last byte that is
6615-
-- (often partially) in prefix. For example for a /125 prefix, the values
6614+
-- prefix. n_bits specifies number of lsb bits on the last byte that
6615+
-- are not in-prefix. For example for a /125 prefix, the values
66166616
-- are 15 and 3, respectively. Mask is a bitmask that has the least
66176617
-- significant bit from the prefix set.
66186618

@@ -6679,37 +6679,37 @@ BEGIN
66796679
-- Ignore unknown variable errors.
66806680
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
66816681

6682-
IF (@kea_recursive_limit IS NOT NULL)
6682+
IF (@kea_recursion_limit IS NOT NULL)
66836683
THEN
66846684
-- Alreaddy set it.
66856685
LEAVE SP;
66866686
END IF;
66876687

66886688
-- Try Mariab variable
6689-
SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursive_limit";
6689+
SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursion_limit";
66906690
PREPARE stmt FROM @sqlv;
66916691
EXECUTE stmt;
66926692
DEALLOCATE PREPARE stmt;
6693-
IF (@kea_recursive_limit IS NOT NULL)
6693+
IF (@kea_recursion_limit IS NOT NULL)
66946694
THEN
66956695
-- We found it, all done.
66966696
LEAVE SP;
66976697
END IF;
66986698

66996699
-- Try MySQL variable.
6700-
SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursive_limit";
6700+
SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursion_limit";
67016701
PREPARE stmt FROM @sqlv;
67026702
EXECUTE stmt;
67036703
DEALLOCATE PREPARE stmt;
67046704

6705-
IF (@kea_recursive_limit IS NOT NULL)
6705+
IF (@kea_recursion_limit IS NOT NULL)
67066706
THEN
67076707
-- We found it, all done.
67086708
LEAVE SP;
67096709
END IF;
67106710

67116711
-- Found neither use a default.
6712-
SET @kea_recursive_limit = 100;
6712+
SET @kea_recursion_limit = 100;
67136713
END $$
67146714
DELIMITER ;
67156715

@@ -6752,7 +6752,7 @@ BEGIN
67526752
SET loop_limit = @kea_recursion_limit;
67536753
SET next_start_address = p_start_address;
67546754
SET next_end_address = p_start_address;
6755-
WHILE next_start_address < p_end_address DO
6755+
WHILE next_start_address <= p_end_address DO
67566756
SET remaining = p_end_address - next_start_address;
67576757
IF (remaining > loop_limit)
67586758
THEN
@@ -6790,7 +6790,7 @@ DELIMITER $$
67906790
CREATE FUNCTION sflqPickFreeLease4(alloc_start_address INT UNSIGNED,
67916791
alloc_end_address INT UNSIGNED)
67926792
RETURNS INT UNSIGNED
6793-
DETERMINISTIC
6793+
READS SQL DATA
67946794
BEGIN
67956795
-- Declarations
67966796
DECLARE pool_id BIGINT(20);
@@ -6822,17 +6822,19 @@ BEGIN
68226822
LEFT JOIN lease4 on f.address = lease4.address
68236823
WHERE (f.address > last_address and f.address <= alloc_end_address)
68246824
AND (lease4.address IS NULL OR lease4.state = 2)
6825+
ORDER BY f.address ASC
68256826
LIMIT 1;
68266827

68276828
-- Didn't find one, so try front half of the range, including
68286829
-- the last pick. This avoids returning nothing if there is only
68296830
-- one address free.
6830-
IF (free_address = 0 AND last_address != alloc_start_address)
6831+
IF (free_address = 0)
68316832
THEN
68326833
SELECT f.address INTO free_address FROM free_lease4 f
68336834
LEFT JOIN lease4 on f.address = lease4.address
68346835
WHERE (f.address >= alloc_start_address AND f.address <= last_address)
68356836
AND (lease4.address IS NULL OR lease4.state = 2)
6837+
ORDER BY f.address ASC
68366838
LIMIT 1;
68376839
END IF;
68386840

@@ -6938,7 +6940,7 @@ DELIMITER $$
69386940
CREATE FUNCTION sflqPickFreeLease6(alloc_start_address VARCHAR(45),
69396941
alloc_end_address VARCHAR(45))
69406942
RETURNS VARCHAR(45)
6941-
DETERMINISTIC
6943+
READS SQL DATA
69426944
BEGIN
69436945
-- Declarations
69446946
DECLARE pool_id BIGINT(20);

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ BEGIN
191191
192192
-- Explanation: n_bytes specifies number of full bytes that are in-prefix.
193193
-- They can also be used as an offset for the first byte that is not in
194-
-- prefix. n_bits specifies number of bits on the last byte that is
195-
-- (often partially) in prefix. For example for a /125 prefix, the values
194+
-- prefix. n_bits specifies number of lsb bits on the last byte that
195+
-- are not in-prefix. For example for a /125 prefix, the values
196196
-- are 15 and 3, respectively. Mask is a bitmask that has the least
197197
-- significant bit from the prefix set.
198198
@@ -259,37 +259,37 @@ BEGIN
259259
-- Ignore unknown variable errors.
260260
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
261261
262-
IF (@kea_recursive_limit IS NOT NULL)
262+
IF (@kea_recursion_limit IS NOT NULL)
263263
THEN
264264
-- Alreaddy set it.
265265
LEAVE SP;
266266
END IF;
267267
268268
-- Try Mariab variable
269-
SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursive_limit";
269+
SET @sqlv = "select @@max_recursive_iterations INTO @kea_recursion_limit";
270270
PREPARE stmt FROM @sqlv;
271271
EXECUTE stmt;
272272
DEALLOCATE PREPARE stmt;
273-
IF (@kea_recursive_limit IS NOT NULL)
273+
IF (@kea_recursion_limit IS NOT NULL)
274274
THEN
275275
-- We found it, all done.
276276
LEAVE SP;
277277
END IF;
278278
279279
-- Try MySQL variable.
280-
SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursive_limit";
280+
SET @sqlv = "select @@cte_max_recursion_depth INTO @kea_recursion_limit";
281281
PREPARE stmt FROM @sqlv;
282282
EXECUTE stmt;
283283
DEALLOCATE PREPARE stmt;
284284
285-
IF (@kea_recursive_limit IS NOT NULL)
285+
IF (@kea_recursion_limit IS NOT NULL)
286286
THEN
287287
-- We found it, all done.
288288
LEAVE SP;
289289
END IF;
290290
291291
-- Found neither use a default.
292-
SET @kea_recursive_limit = 100;
292+
SET @kea_recursion_limit = 100;
293293
END $$
294294
DELIMITER ;
295295
@@ -332,7 +332,7 @@ BEGIN
332332
SET loop_limit = @kea_recursion_limit;
333333
SET next_start_address = p_start_address;
334334
SET next_end_address = p_start_address;
335-
WHILE next_start_address < p_end_address DO
335+
WHILE next_start_address <= p_end_address DO
336336
SET remaining = p_end_address - next_start_address;
337337
IF (remaining > loop_limit)
338338
THEN
@@ -370,7 +370,7 @@ DELIMITER $$
370370
CREATE FUNCTION sflqPickFreeLease4(alloc_start_address INT UNSIGNED,
371371
alloc_end_address INT UNSIGNED)
372372
RETURNS INT UNSIGNED
373-
DETERMINISTIC
373+
READS SQL DATA
374374
BEGIN
375375
-- Declarations
376376
DECLARE pool_id BIGINT(20);
@@ -402,17 +402,19 @@ BEGIN
402402
LEFT JOIN lease4 on f.address = lease4.address
403403
WHERE (f.address > last_address and f.address <= alloc_end_address)
404404
AND (lease4.address IS NULL OR lease4.state = 2)
405+
ORDER BY f.address ASC
405406
LIMIT 1;
406407
407408
-- Didn't find one, so try front half of the range, including
408409
-- the last pick. This avoids returning nothing if there is only
409410
-- one address free.
410-
IF (free_address = 0 AND last_address != alloc_start_address)
411+
IF (free_address = 0)
411412
THEN
412413
SELECT f.address INTO free_address FROM free_lease4 f
413414
LEFT JOIN lease4 on f.address = lease4.address
414415
WHERE (f.address >= alloc_start_address AND f.address <= last_address)
415416
AND (lease4.address IS NULL OR lease4.state = 2)
417+
ORDER BY f.address ASC
416418
LIMIT 1;
417419
END IF;
418420
@@ -519,7 +521,7 @@ DELIMITER $$
519521
CREATE FUNCTION sflqPickFreeLease6(alloc_start_address VARCHAR(45),
520522
alloc_end_address VARCHAR(45))
521523
RETURNS VARCHAR(45)
522-
DETERMINISTIC
524+
READS SQL DATA
523525
BEGIN
524526
-- Declarations
525527
DECLARE pool_id BIGINT(20);

0 commit comments

Comments
 (0)