summaryrefslogtreecommitdiffstats
path: root/src/share
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2022-06-29 19:58:54 +0200
committerAndrei Pavel <andrei@isc.org>2022-06-30 14:31:05 +0200
commitad5cc13b6c58ea1b957d3289b5f84af5114899d5 (patch)
tree37d829cbfa51358a72df1f217617861236182193 /src/share
parent[#2445] add getClassLeaseCount() for MySQL and PostgreSQL (diff)
downloadkea-ad5cc13b6c58ea1b957d3289b5f84af5114899d5.tar.xz
kea-ad5cc13b6c58ea1b957d3289b5f84af5114899d5.zip
[#2445] trim double quotes from classes in PostgreSQL update triggers
Diffstat (limited to 'src/share')
-rw-r--r--src/share/database/scripts/pgsql/dhcpdb_create.pgsql8
-rw-r--r--src/share/database/scripts/pgsql/upgrade_012_to_013.sh.in8
2 files changed, 16 insertions, 0 deletions
diff --git a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
index c44a32e415..21d8fb6f06 100644
--- a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
+++ b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
@@ -5222,6 +5222,8 @@ BEGIN
IF old_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(old_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Decrement the lease count if the record exists.
UPDATE lease4_stat_by_client_class SET leases = GREATEST(leases - 1, 0)
WHERE client_class = class;
@@ -5232,6 +5234,8 @@ BEGIN
IF new_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(new_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Upsert to increment the lease count.
UPDATE lease4_stat_by_client_class SET leases = leases + 1
WHERE client_class = class;
@@ -5316,6 +5320,8 @@ BEGIN
IF old_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(old_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Decrement the lease count if the record exists.
UPDATE lease6_stat_by_client_class SET leases = GREATEST(leases - 1, 0)
WHERE client_class = class AND lease_type = old_lease_type;
@@ -5326,6 +5332,8 @@ BEGIN
IF new_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(new_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Upsert to increment the lease count.
UPDATE lease6_stat_by_client_class SET leases = leases + 1
WHERE client_class = class AND lease_type = new_lease_type;
diff --git a/src/share/database/scripts/pgsql/upgrade_012_to_013.sh.in b/src/share/database/scripts/pgsql/upgrade_012_to_013.sh.in
index e29197449a..e73e573eca 100644
--- a/src/share/database/scripts/pgsql/upgrade_012_to_013.sh.in
+++ b/src/share/database/scripts/pgsql/upgrade_012_to_013.sh.in
@@ -271,6 +271,8 @@ BEGIN
IF old_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(old_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Decrement the lease count if the record exists.
UPDATE lease4_stat_by_client_class SET leases = GREATEST(leases - 1, 0)
WHERE client_class = class;
@@ -281,6 +283,8 @@ BEGIN
IF new_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(new_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Upsert to increment the lease count.
UPDATE lease4_stat_by_client_class SET leases = leases + 1
WHERE client_class = class;
@@ -365,6 +369,8 @@ BEGIN
IF old_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(old_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Decrement the lease count if the record exists.
UPDATE lease6_stat_by_client_class SET leases = GREATEST(leases - 1, 0)
WHERE client_class = class AND lease_type = old_lease_type;
@@ -375,6 +381,8 @@ BEGIN
IF new_state = 0 THEN
-- Dive into client classes.
FOR class IN SELECT * FROM JSON_ARRAY_ELEMENTS(json_cast(new_client_classes)) LOOP
+ SELECT TRIM('"' FROM class) INTO class;
+
-- Upsert to increment the lease count.
UPDATE lease6_stat_by_client_class SET leases = leases + 1
WHERE client_class = class AND lease_type = new_lease_type;