]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3753] backport #3631 to 2.6.2
authorRazvan Becheriu <razvan@isc.org>
Tue, 4 Mar 2025 08:19:12 +0000 (10:19 +0200)
committerRazvan Becheriu <razvan@isc.org>
Tue, 4 Mar 2025 15:55:41 +0000 (17:55 +0200)
14 files changed:
configure.ac
src/bin/admin/kea-admin.in
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_022.1_to_022.2.sh.in [new file with mode: 0644]
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_022.1_to_022.2.sh.in [new file with mode: 0644]

index 28a6c69b48dc814fe8ad63d41adf58a625cedc20..57c5f80b0ef63800599b39933a511a50f06b86f9 100644 (file)
@@ -1769,6 +1769,8 @@ AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_021_to_022.sh],
                 [chmod +x src/share/database/scripts/mysql/upgrade_021_to_022.sh])
 AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_022_to_022.1.sh],
                 [chmod +x src/share/database/scripts/mysql/upgrade_022_to_022.1.sh])
+AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_022.1_to_022.2.sh],
+                [chmod +x src/share/database/scripts/mysql/upgrade_022.1_to_022.2.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])
@@ -1828,6 +1830,8 @@ AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_021_to_022.sh],
                 [chmod +x src/share/database/scripts/pgsql/upgrade_021_to_022.sh])
 AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_022_to_022.1.sh],
                 [chmod +x src/share/database/scripts/pgsql/upgrade_022_to_022.1.sh])
+AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_022.1_to_022.2.sh],
+                [chmod +x src/share/database/scripts/pgsql/upgrade_022.1_to_022.2.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 b1172ff8ca6f87334f41a27dd18b11fa0acd0037..6a321a349615ff968da20dbba925e5fe12c2e4f5 100644 (file)
@@ -371,7 +371,7 @@ mysql_upgrade() {
     printf "Verifying upgrade permissions for %s\n" "$db_user"
     mysql_can_create
 
-    upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -V)
+    upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -t'_' -k4 -V)
     for script in ${upgrade_scripts}
     do
         echo "Processing $script file..."
@@ -419,7 +419,7 @@ pgsql_upgrade() {
     # thru an env
     export PGPASSWORD=$db_password
 
-    upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -V)
+    upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -t'_' -k4 -V)
     for script in ${upgrade_scripts}
     do
         echo "Processing $script file..."
index 097cbd8c97a63d26967e6a51eec16bbad2683f30..792d41407df1abc00eb426e335262cee83e8ad4a 100644 (file)
@@ -821,6 +821,122 @@ mysql_upgrade_22_0_to_22_1_test() {
     assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
 }
 
+mysql_upgrade_22_1_to_22_2_test() {
+    query="SELECT count(id) FROM option_def_data_type"
+    run_command \
+        mysql_execute "${query}"
+    assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
+    assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 0"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'empty' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 1"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'binary' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 2"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'boolean' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 3"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'int8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 4"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'int16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 5"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'int32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 6"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'uint8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 7"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'uint16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 8"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'uint32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 10"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'ipv4-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 11"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'ipv6-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 12"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'ipv6-prefix' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 13"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'psid' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 14"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'string' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 15"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'tuple' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 16"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'fqdn' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 17"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'internal' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 254"
+    run_command \
+        mysql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'record' "${OUTPUT}" "${query}: expected output %s, returned %s"
+}
+
 mysql_upgrade_test() {
 
     test_start "mysql.upgrade"
@@ -842,7 +958,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 "22.1" "${version}" "Expected kea-admin to return %s, returned value was %s"
+    assert_str_eq "22.2" "${version}" "Expected kea-admin to return %s, returned value was %s"
 
     # Let's check that the new tables are indeed there.
 
@@ -1507,6 +1623,9 @@ SET @disable_audit = 0"
 
     # Check upgrade from 22.0 to 22.1.
     mysql_upgrade_22_0_to_22_1_test
+
+    # Check upgrade from 22.1 to 22.2.
+    mysql_upgrade_22_1_to_22_2_test
     # Let's wipe the whole database
     mysql_wipe
 
index e877fbfec5232f2de3d9ae0e230b01e59f4497eb..362e73b95b794712bcd8f23da95c2f0709375261 100644 (file)
@@ -142,7 +142,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 "22.1" "${version}" "Expected kea-admin to return %s, returned value was %s"
+    assert_str_eq "22.2" "${version}" "Expected kea-admin to return %s, returned value was %s"
 
     # Let's wipe the whole database
     pgsql_wipe
@@ -909,7 +909,7 @@ pgsql_upgrade_20_to_21_test() {
     assert_str_eq '4' "${OUTPUT}" "${query}: expected output %s, returned %s"
 }
 
-pgsql_upgrade_22_to_22_1_test() {
+pgsql_upgrade_22_0_to_22_1_test() {
     query="SELECT count(id) FROM option_def_data_type"
     run_command \
         pgsql_execute "${query}"
@@ -917,6 +917,122 @@ pgsql_upgrade_22_to_22_1_test() {
     assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
 }
 
+pgsql_upgrade_22_1_to_22_2_test() {
+    query="SELECT count(id) FROM option_def_data_type"
+    run_command \
+        pgsql_execute "${query}"
+    assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
+    assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 0"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'empty' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 1"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'binary' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 2"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'boolean' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 3"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'int8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 4"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'int16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 5"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'int32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 6"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'uint8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 7"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'uint16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 8"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'uint32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 10"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'ipv4-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 11"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'ipv6-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 12"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'ipv6-prefix' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 13"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'psid' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 14"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'string' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 15"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'tuple' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 16"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'fqdn' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 17"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'internal' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+    qry="select name from option_def_data_type where id = 254"
+    run_command \
+        pgsql_execute "${qry}"
+    assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+    assert_str_eq 'record' "${OUTPUT}" "${query}: expected output %s, returned %s"
+}
+
 pgsql_upgrade_test() {
     test_start "pgsql.upgrade"
 
@@ -935,7 +1051,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 "22.1" "${version}" 'Expected kea-admin to return %s, returned value was %s'
+    assert_str_eq "22.2" "${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
@@ -994,8 +1110,11 @@ pgsql_upgrade_test() {
     # Check 20 to 21 upgrade
     pgsql_upgrade_20_to_21_test
 
-    # Check 22 to 22.1 upgrade
-    pgsql_upgrade_22_to_22_1_test
+    # Check 22.0 to 22.1 upgrade
+    pgsql_upgrade_22_0_to_22_1_test
+
+    # Check 22.1 to 22.2 upgrade
+    pgsql_upgrade_22_1_to_22_2_test
 
     # Let's wipe the whole database
     pgsql_wipe
index 964ab792d141f3f15ea42d922ce782b90ec65d79..6e1813e44319a03408ba5a1ace19f51346875fe8 100644 (file)
@@ -53,7 +53,7 @@ const int MLM_MYSQL_FETCH_FAILURE = 0;
 /// @name Current database schema version values.
 //@{
 const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 22;
-const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 1;
+const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 2;
 
 //@}
 
index 495478e7f3105b2e2623f886aba6a8313923fd81..208fa1a7a14f088de3aa260b1c740321fed0b16f 100644 (file)
@@ -19,7 +19,7 @@ namespace db {
 
 /// @brief Define the PostgreSQL backend version.
 const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 22;
-const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 1;
+const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 2;
 
 // Maximum number of parameters that can be used a statement
 // @todo This allows us to use an initializer list (since we can't
index 45e5c49db34dff5e14ccaeaf02032c31311e1b22..3292703425c5c3c61c2a854d1eb35da78b4c4721 100644 (file)
@@ -31,4 +31,5 @@
 /upgrade_020_to_021.sh
 /upgrade_021_to_022.sh
 /upgrade_022_to_022.1.sh
+/upgrade_022.1_to_022.2.sh
 /wipe_data.sh
index 5825abb03385744467bf67dc26408c364e1d9ce5..a86c15710ba00436d21418bccc91deaf356c1185 100644 (file)
@@ -42,6 +42,7 @@ mysql_SCRIPTS += upgrade_019_to_020.sh
 mysql_SCRIPTS += upgrade_020_to_021.sh
 mysql_SCRIPTS += upgrade_021_to_022.sh
 mysql_SCRIPTS += upgrade_022_to_022.1.sh
+mysql_SCRIPTS += upgrade_022.1_to_022.2.sh
 mysql_SCRIPTS += wipe_data.sh
 
 DISTCLEANFILES = ${mysql_SCRIPTS}
index c79c942eff2eef24657f93c5ed6174895198d302..9df1d084bc8ccab8dbab0c79a600ac290c129276 100644 (file)
@@ -5925,7 +5925,7 @@ INSERT INTO option_def_data_type VALUES
     (0, 'empty'),
     (1, 'binary'),
     (2, 'boolean'),
-    (3, 'int8"'),
+    (3, 'int8'),
     (4, 'int16'),
     (5, 'int32'),
     (6, 'uint8'),
@@ -5955,6 +5955,16 @@ UPDATE schema_version
 
 -- This line concludes the schema upgrade to version 22.1.
 
+-- This line starts the schema upgrade to version 22.2.
+
+UPDATE option_def_data_type SET name='int8' where id = 3;
+
+-- Update the schema version number.
+UPDATE schema_version
+    SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+
 # Notes:
 #
 # Indexes
diff --git a/src/share/database/scripts/mysql/upgrade_022.1_to_022.2.sh.in b/src/share/database/scripts/mysql/upgrade_022.1_to_022.2.sh.in
new file mode 100644 (file)
index 0000000..62539af
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# Copyright (C) 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}" != "22.1"; then
+    printf 'This script upgrades 22.1 to 22.2. '
+    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 22.2.
+
+UPDATE option_def_data_type SET name='int8' WHERE id = 3;
+
+-- Update the schema version number.
+UPDATE schema_version
+    SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+EOF
index a8763c537f8f00e913477ade4329aae6bed65a10..1fed27d121e7244d1b6e8d08803f9c17c09258af 100644 (file)
@@ -26,4 +26,5 @@
 /upgrade_020_to_021.sh
 /upgrade_021_to_022.sh
 /upgrade_022_to_022.1.sh
+/upgrade_022.1_to_022.2.sh
 /wipe_data.sh
index 293080749a934dc246bfabcec6021e0b717a6f84..e8346181098058cfb3a66476d0428477f0979932 100644 (file)
@@ -37,6 +37,7 @@ pgsql_SCRIPTS += upgrade_019_to_020.sh
 pgsql_SCRIPTS += upgrade_020_to_021.sh
 pgsql_SCRIPTS += upgrade_021_to_022.sh
 pgsql_SCRIPTS += upgrade_022_to_022.1.sh
+pgsql_SCRIPTS += upgrade_022.1_to_022.2.sh
 pgsql_SCRIPTS += wipe_data.sh
 
 DISTCLEANFILES = ${pgsql_SCRIPTS}
index 8b469cfc9346a9d179439875f762f9e0229bba04..4ba828022acca6b1ee8b67f7f982cea2da4265d1 100644 (file)
@@ -6397,7 +6397,7 @@ INSERT INTO option_def_data_type VALUES
     (0, 'empty'),
     (1, 'binary'),
     (2, 'boolean'),
-    (3, 'int8"'),
+    (3, 'int8'),
     (4, 'int16'),
     (5, 'int32'),
     (6, 'uint8'),
@@ -6421,11 +6421,23 @@ ALTER TABLE dhcp6_option_def
     ADD CONSTRAINT fk_option_def_data_type6 FOREIGN KEY (type) REFERENCES option_def_data_type(id);
 
 SELECT set_config('kea.disable_audit', 'false', false);
+
+-- Update the schema version number.
 UPDATE schema_version
     SET version = '22', minor = '1';
 
 -- This line concludes the schema upgrade to version 22.1.
 
+-- This line starts the schema upgrade to version 22.2.
+
+UPDATE option_def_data_type SET name='int8' where id = 3;
+
+-- Update the schema version number.
+UPDATE schema_version
+    SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+
 -- Commit the script transaction.
 COMMIT;
 
diff --git a/src/share/database/scripts/pgsql/upgrade_022.1_to_022.2.sh.in b/src/share/database/scripts/pgsql/upgrade_022.1_to_022.2.sh.in
new file mode 100644 (file)
index 0000000..4fc5b17
--- /dev/null
@@ -0,0 +1,52 @@
+#!/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" != "22.1" ]; then
+    printf 'This script upgrades 22.1 to 22.2. '
+    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 22.2.
+
+UPDATE option_def_data_type SET name='int8' WHERE id = 3;
+
+UPDATE schema_version
+    SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+
+-- Commit the script transaction.
+COMMIT;
+
+EOF