]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3683] Checkpoint: update after rebase
authorFrancis Dupont <fdupont@isc.org>
Thu, 6 Feb 2025 21:48:48 +0000 (22:48 +0100)
committerFrancis Dupont <fdupont@isc.org>
Fri, 21 Feb 2025 09:45:02 +0000 (10:45 +0100)
15 files changed:
configure.ac
src/bin/admin/tests/mysql_tests.sh.in
src/bin/admin/tests/pgsql_tests.sh.in
src/lib/mysql/mysql_constants.h
src/lib/pgsql/pgsql_connection.h
src/share/database/scripts/mysql/.gitignore
src/share/database/scripts/mysql/Makefile.am
src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_027_to_028.sh.in
src/share/database/scripts/mysql/upgrade_028_to_029.sh.in [new file with mode: 0755]
src/share/database/scripts/pgsql/.gitignore
src/share/database/scripts/pgsql/Makefile.am
src/share/database/scripts/pgsql/dhcpdb_create.pgsql
src/share/database/scripts/pgsql/upgrade_027_to_028.sh.in
src/share/database/scripts/pgsql/upgrade_028_to_029.sh.in [new file with mode: 0644]

index 85ccc1e099377d9b25b9a491fbe5cf4f628eb877..72c19b80a89c5a9f46fa47e48c1aa8cc0baac96b 100644 (file)
@@ -1825,6 +1825,8 @@ AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_026_to_027.sh],
                 [chmod +x src/share/database/scripts/mysql/upgrade_026_to_027.sh])
 AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_027_to_028.sh],
                 [chmod +x src/share/database/scripts/mysql/upgrade_027_to_028.sh])
+AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_028_to_029.sh],
+                [chmod +x src/share/database/scripts/mysql/upgrade_028_to_029.sh])
 AC_CONFIG_FILES([src/share/database/scripts/mysql/wipe_data.sh],
                 [chmod +x src/share/database/scripts/mysql/wipe_data.sh])
 AC_CONFIG_FILES([src/share/database/scripts/pgsql/Makefile])
@@ -1894,6 +1896,8 @@ AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_026_to_027.sh],
                 [chmod +x src/share/database/scripts/pgsql/upgrade_026_to_027.sh])
 AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_027_to_028.sh],
                 [chmod +x src/share/database/scripts/pgsql/upgrade_027_to_028.sh])
+AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_028_to_029.sh],
+                [chmod +x src/share/database/scripts/pgsql/upgrade_028_to_029.sh])
 AC_CONFIG_FILES([src/share/database/scripts/pgsql/wipe_data.sh],
                 [chmod +x src/share/database/scripts/pgsql/wipe_data.sh])
 AC_CONFIG_FILES([src/share/yang/Makefile])
index 234d1dc1bb379ca48dea878d3c8a24851e858e10..f0a24db7824302dafc2b9addb34f9ad4eed0f181 100644 (file)
@@ -1020,6 +1020,9 @@ mysql_upgrade_27_to_28_test() {
     check_table_column ddns_ttl dhcp6_subnet
     check_table_column ddns_ttl_min dhcp6_subnet
     check_table_column ddns_ttl_max dhcp6_subnet
+}
+
+mysql_upgrade_28_to_29_test() {
 
     # check registered were added tp lease_state
     qry="SELECT name FROM lease_state WHERE state = 4"
@@ -1050,7 +1053,7 @@ mysql_upgrade_test() {
 
     # Verify that the upgraded schema reports the latest version.
     version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
-    assert_str_eq "28.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
+    assert_str_eq "29.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
 
     # Let's check that the new tables are indeed there.
 
@@ -1731,6 +1734,9 @@ SET @disable_audit = 0"
     # Check upgrade from 27.0 to 28.0.
     mysql_upgrade_27_to_28_test
 
+    # Check upgrade from 28.0 to 29.0.
+    mysql_upgrade_28_to_29_test
+
     # Let's wipe the whole database
     mysql_wipe
 
index 2463f993e1ba3bff19d2615c064a66985095534f..010f9cde278d458876969f929d3d93279a8d095a 100644 (file)
@@ -158,7 +158,7 @@ pgsql_db_version_test() {
     run_command \
         "${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}"
     version="${OUTPUT}"
-    assert_str_eq "28.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
+    assert_str_eq "29.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
 
     # Let's wipe the whole database
     pgsql_wipe
@@ -1111,6 +1111,9 @@ pgsql_upgrade_27_to_28_test() {
     check_table_column ddns_ttl dhcp6_subnet
     check_table_column ddns_ttl_min dhcp6_subnet
     check_table_column ddns_ttl_max dhcp6_subnet
+}
+
+pgsql_upgrade_28_to_29_test() {
 
     # check registered were added tp lease_state
     query="SELECT name FROM lease_state WHERE state = 4"
@@ -1138,7 +1141,7 @@ pgsql_upgrade_test() {
 
     # Verify upgraded schema reports the latest version.
     version=$("${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
-    assert_str_eq "28.0" "${version}" 'Expected kea-admin to return %s, returned value was %s'
+    assert_str_eq "29.0" "${version}" 'Expected kea-admin to return %s, returned value was %s'
 
     # Check 1.0 to 2.0 upgrade
     pgsql_upgrade_1_0_to_2_0_test
@@ -1215,6 +1218,9 @@ pgsql_upgrade_test() {
     # Check 27 to 28 upgrade
     pgsql_upgrade_27_to_28_test
 
+    # Check 28 to 29 upgrade
+    pgsql_upgrade_28_to_29_test
+
     # Let's wipe the whole database
     pgsql_wipe
 
index a5e2787499be501e99bb68be5db07f6d60a8c6ab..ebda258fe9df3c8fc4043538308633ec590fc8e3 100644 (file)
@@ -52,7 +52,7 @@ const int MLM_MYSQL_FETCH_FAILURE = 0;
 
 /// @name Current database schema version values.
 //@{
-const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 28;
+const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 29;
 const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
 
 //@}
index 91b5d4cb4e04ffc1e5be5d01c69407336568fc67..baf346719ff122372b980ad1d32a604c8581c73f 100644 (file)
@@ -18,7 +18,7 @@ namespace isc {
 namespace db {
 
 /// @brief Define the PostgreSQL backend version.
-const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 28;
+const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 29;
 const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 0;
 
 // Maximum number of parameters that can be used a statement
index 892cfe31907209b8439d9bab5c1db717924f81fb..b74e05b3df8d76a33bfd1c4bcd6c31db2929787e 100644 (file)
@@ -36,4 +36,5 @@
 /upgrade_025_to_026.sh
 /upgrade_026_to_027.sh
 /upgrade_027_to_028.sh
+/upgrade_028_to_029.sh
 /wipe_data.sh
index ff312fb6d48004e4fe0c7393bbc48b9cb71b22fc..38cbe66c66428414bd4e90d3825c57f3c3a6211e 100644 (file)
@@ -47,6 +47,7 @@ mysql_SCRIPTS += upgrade_024_to_025.sh
 mysql_SCRIPTS += upgrade_025_to_026.sh
 mysql_SCRIPTS += upgrade_026_to_027.sh
 mysql_SCRIPTS += upgrade_027_to_028.sh
+mysql_SCRIPTS += upgrade_028_to_029.sh
 mysql_SCRIPTS += wipe_data.sh
 
 DISTCLEANFILES = ${mysql_SCRIPTS}
index 6dc07036ab4843a4fe8e3e29e46ab86c82a72800..aa07efcfa40317b2f746e538a1925c20516a408e 100644 (file)
@@ -6157,14 +6157,22 @@ ALTER TABLE dhcp6_subnet
     ADD COLUMN ddns_ttl_min     INT(10) DEFAULT NULL,
     ADD COLUMN ddns_ttl_max     INT(10) DEFAULT NULL;
 
+-- Update the schema version number.
+UPDATE schema_version
+    SET version = '28', minor = '0';
+
+-- This line concludes the schema upgrade to version 28.0.
+
+-- This line starts the schema upgrade to version 29.0.
+
 -- New lease state for address registration
 INSERT INTO lease_state VALUES (4, 'registered');
 
 -- Update the schema version number.
 UPDATE schema_version
-    SET version = '28', minor = '0';
+    SET version = '29', minor = '0';
 
--- This line concludes the schema upgrade to version 28.0.
+-- This line concludes the schema upgrade to version 29.0.
 
 # Notes:
 #
index 3a7c7843585228253436d2d3bfce399358694bff..0d117349002fd20c1270f7ba5d660c75237147a3 100755 (executable)
@@ -80,9 +80,6 @@ ALTER TABLE dhcp6_subnet
     ADD COLUMN ddns_ttl_min     INT(10) DEFAULT NULL,
     ADD COLUMN ddns_ttl_max     INT(10) DEFAULT NULL;
 
--- New lease state for address registration
-INSERT INTO lease_state VALUES (4, 'registered');
-
 -- Update the schema version number.
 UPDATE schema_version
     SET version = '28', minor = '0';
diff --git a/src/share/database/scripts/mysql/upgrade_028_to_029.sh.in b/src/share/database/scripts/mysql/upgrade_028_to_029.sh.in
new file mode 100755 (executable)
index 0000000..4c8eefa
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Exit with error if commands exit with non-zero and if undefined variables are
+# used.
+set -eu
+
+# shellcheck disable=SC2034
+# SC2034: ... appears unused. Verify use (or export if used externally).
+prefix="@prefix@"
+
+# Include utilities based on location of this script. Check for sources first,
+# so that the unexpected situations with weird paths fall on the default
+# case of installed.
+script_path=$(cd "$(dirname "${0}")" && pwd)
+if test "${script_path}" = "@abs_top_builddir@/src/share/database/scripts/mysql"; then
+    # shellcheck source=./src/bin/admin/admin-utils.sh.in
+    . "@abs_top_builddir@/src/bin/admin/admin-utils.sh"
+else
+    # shellcheck source=./src/bin/admin/admin-utils.sh.in
+    . "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"
+fi
+
+# Check version.
+version=$(mysql_version "${@}")
+if test "${version}" != "27.0"; then
+    printf 'This script upgrades 28.0 to 29.0. '
+    printf 'Reported version is %s. Skipping upgrade.\n' "${version}"
+    exit 0
+fi
+
+# Get the schema name from database argument. We need this to
+# query information_schema for the right database.
+for arg in "${@}"
+do
+    if ! printf '%s' "${arg}" | grep -Eq -- '^--'
+    then
+        schema="$arg"
+        break
+    fi
+done
+
+# Make sure we have the schema.
+if [ -z "$schema" ]
+then
+    printf "Could not find database schema name in cmd line args: %s\n" "${*}"
+    exit 255
+fi
+
+mysql "$@" <<EOF
+
+-- This line starts the schema upgrade to version 29.0.
+
+-- New lease state for address registration
+INSERT INTO lease_state VALUES (4, 'registered');
+
+-- Update the schema version number.
+UPDATE schema_version
+    SET version = '29', minor = '0';
+
+-- This line concludes the schema upgrade to version 29.0.
+
+EOF
index 50299b57e0661b21669d74ec35018516cba7581e..499579f4623691e9d04125bf4e649093d25d7929 100644 (file)
@@ -31,4 +31,5 @@
 /upgrade_025_to_026.sh
 /upgrade_026_to_027.sh
 /upgrade_027_to_028.sh
+/upgrade_028_to_029.sh
 /wipe_data.sh
index c0b6f9504d0fff09983ff26c55b198c11a62d2ab..2713ef37f46975cf4d04d08acb048943b0ca2d6a 100644 (file)
@@ -42,6 +42,7 @@ pgsql_SCRIPTS += upgrade_024_to_025.sh
 pgsql_SCRIPTS += upgrade_025_to_026.sh
 pgsql_SCRIPTS += upgrade_026_to_027.sh
 pgsql_SCRIPTS += upgrade_027_to_028.sh
+pgsql_SCRIPTS += upgrade_028_to_029.sh
 pgsql_SCRIPTS += wipe_data.sh
 
 DISTCLEANFILES = ${pgsql_SCRIPTS}
index 1d3edcc5c3e9cd61848ed2b419cebc90bcee1aa3..48ad4cde8109f65d019761317e0c032561be66d7 100644 (file)
@@ -6625,6 +6625,17 @@ UPDATE schema_version
 
 -- This line concludes the schema upgrade to version 28.0.
 
+-- This line starts the schema upgrade to version 29.0.
+
+-- New lease state for address registration
+INSERT INTO lease_state VALUES (4, 'registered');
+
+-- Update the schema version number.
+UPDATE schema_version
+    SET version = '29', minor = '0';
+
+-- This line concludes the schema upgrade to version 29.0.
+
 -- Commit the script transaction.
 COMMIT;
 
index dca5dc2a4d8fce75479aa5e325faa0dbd62c3281..7b1d464615243c8714b3d3e0546c83ec0f944a5a 100644 (file)
@@ -66,10 +66,6 @@ ALTER TABLE dhcp6_subnet
 -- New lease state for address registration
 INSERT INTO lease_state VALUES (4, 'registered');
 
--- Update the schema version number.
-UPDATE schema_version
-    SET version = '28', minor = '0';
-
 -- This line concludes the schema upgrade to version 28.0.
 
 -- Commit the script transaction.
diff --git a/src/share/database/scripts/pgsql/upgrade_028_to_029.sh.in b/src/share/database/scripts/pgsql/upgrade_028_to_029.sh.in
new file mode 100644 (file)
index 0000000..6a00992
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Exit with error if commands exit with non-zero and if undefined variables are
+# used.
+set -eu
+
+# shellcheck disable=SC2034
+# SC2034: ... appears unused. Verify use (or export if used externally).
+prefix="@prefix@"
+
+# Include utilities based on location of this script. Check for sources first,
+# so that the unexpected situations with weird paths fall on the default
+# case of installed.
+script_path=$(cd "$(dirname "${0}")" && pwd)
+if test "${script_path}" = "@abs_top_builddir@/src/share/database/scripts/pgsql"; then
+    # shellcheck source=./src/bin/admin/admin-utils.sh.in
+    . "@abs_top_builddir@/src/bin/admin/admin-utils.sh"
+else
+    # shellcheck source=./src/bin/admin/admin-utils.sh.in
+    . "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"
+fi
+
+VERSION=$(pgsql_version "$@")
+
+if [ "$VERSION" != "28.0" ]; then
+    printf 'This script upgrades 28.0 to 29.0. '
+    printf 'Reported version is %s. Skipping upgrade.\n' "${VERSION}"
+    exit 0
+fi
+
+psql "$@" >/dev/null <<EOF
+START TRANSACTION;
+
+-- This line starts the schema upgrade to version 29.0.
+
+-- New lease state for address registration
+INSERT INTO lease_state VALUES (4, 'registered');
+
+-- Update the schema version number.
+UPDATE schema_version
+    SET version = '29', minor = '0';
+
+-- This line concludes the schema upgrade to version 29.0.
+
+-- Commit the script transaction.
+COMMIT;
+
+EOF