2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 22:15:23 +00:00

[#2438] prevent MySQL lease counters from going negative

This commit is contained in:
Andrei Pavel
2022-06-22 15:53:20 +03:00
parent fe29c8ec7f
commit 774b84db35
3 changed files with 77 additions and 22 deletions

View File

@@ -4521,7 +4521,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -4578,7 +4579,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(old_client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease4_stat_by_client_class SET leases = leases - 1
UPDATE lease4_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class;
SET i = i + 1;
@@ -4618,7 +4619,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -4635,7 +4637,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease4_stat_by_client_class SET leases = leases - 1
UPDATE lease4_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class;
SET i = i + 1;
@@ -4656,7 +4658,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -4714,7 +4717,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(old_client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease6_stat_by_client_class SET leases = leases - 1
UPDATE lease6_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class AND lease_type = old_lease_type;
SET i = i + 1;
@@ -4755,7 +4758,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -4772,7 +4776,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease6_stat_by_client_class SET leases = leases - 1
UPDATE lease6_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class AND lease_type = old_lease_type;
SET i = i + 1;

View File

@@ -283,7 +283,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -340,7 +341,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(old_client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease4_stat_by_client_class SET leases = leases - 1
UPDATE lease4_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class;
SET i = i + 1;
@@ -380,7 +381,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -397,7 +399,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease4_stat_by_client_class SET leases = leases - 1
UPDATE lease4_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class;
SET i = i + 1;
@@ -418,7 +420,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -476,7 +479,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(old_client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease6_stat_by_client_class SET leases = leases - 1
UPDATE lease6_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class AND lease_type = old_lease_type;
SET i = i + 1;
@@ -517,7 +520,8 @@ BEGIN
DECLARE length INT;
DECLARE i INT;
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 3141 (22032) at line 1: Invalid JSON text in argument 1 to
-- function json_extract: "The document is empty." at position 0.
-- Ignore ERROR 4037 (HY000): Unexpected end of JSON text in argument 1 to function 'json_extract'
-- These situations are handled with a propagating NULL result from JSON_EXTRACT.
DECLARE CONTINUE HANDLER FOR 3141 BEGIN END;
@@ -534,7 +538,7 @@ BEGIN
SET class = JSON_UNQUOTE(JSON_EXTRACT(client_classes, CONCAT('\$[', i, ']')));
-- Decrement the lease count if the record exists.
UPDATE lease6_stat_by_client_class SET leases = leases - 1
UPDATE lease6_stat_by_client_class SET leases = IF(leases > 0, leases - 1, 0)
WHERE client_class = class AND lease_type = old_lease_type;
SET i = i + 1;