From: Razvan Becheriu Date: Tue, 9 May 2023 08:53:31 +0000 (+0300) Subject: [#2786] addressed comments X-Git-Tag: Kea-2.3.8~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82c33e04b1d08d38c104165086e0fc30460ab326;p=thirdparty%2Fkea.git [#2786] addressed comments --- diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index 6a74cab3ce..ba20fdb340 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -767,14 +767,14 @@ mysql_upgrade_test() { version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}") assert_str_eq "1.0" "${version}" "Expected kea-admin to return %s, returned value was %s" - # Ok, we have a 1.0 database. Let's upgrade it to the latest version. + # Let's upgrade it to the latest version. run_command \ "${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}" assert_eq 0 "${EXIT_CODE}" "kea-admin db-upgrade mysql failed, expected %d, returned non-zero status code %d\n" # 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 "17.0" "${version}" "Expected kea-admin to return %s, returned value was %s" + assert_str_eq "18.0" "${version}" "Expected kea-admin to return %s, returned value was %s" # Let's check that the new tables are indeed there. @@ -1886,7 +1886,7 @@ mysql_lease_stat_upgrade_test() { insert into lease6 (address, lease_type, subnet_id, state) values (666,1,40,2);" run_statement "insert v6 leases" "$qry" - # Ok, we have a 4.0 database with leases. Let's upgrade it to the latest version. + # Let's upgrade it to the latest version. run_command \ "${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}" @@ -2187,7 +2187,7 @@ mysql_reservation_mode_upgrade_test() { mysql_wipe # We need to create an older database with lease data so we can - # verify the upgrade mechanisms which convert reservations values + # verify the upgrade mechanisms which convert reservation values # # Initialize database to schema 1.0. mysql -u"${db_user}" -p"${db_password}" "${db_name}" < "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.mysql" @@ -2525,7 +2525,7 @@ mysql_update_empty_duid_test() { run_statement "insert v6 leases" "$sql" - # Ok, we have a 14.0 database with leases. Let's upgrade it to latest version. + # Let's upgrade it to the latest version. run_command \ "${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}" diff --git a/src/bin/admin/tests/pgsql_tests.sh.in b/src/bin/admin/tests/pgsql_tests.sh.in index d7c616bad7..27a0a0d639 100644 --- a/src/bin/admin/tests/pgsql_tests.sh.in +++ b/src/bin/admin/tests/pgsql_tests.sh.in @@ -143,7 +143,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 "16.0" "${version}" "Expected kea-admin to return %s, returned value was %s" + assert_str_eq "17.0" "${version}" "Expected kea-admin to return %s, returned value was %s" # Let's wipe the whole database pgsql_wipe @@ -847,14 +847,14 @@ pgsql_upgrade_test() { pgsql_execute_script "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.pgsql" assert_eq 0 "${EXIT_CODE}" "cannot initialize the database, expected exit code: %d, actual: %d" - # Ok, we have a 1.0 database. Let's upgrade it to the latest version. + # Let's upgrade it to the latest version. run_command \ "${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}" assert_eq 0 "${EXIT_CODE}" "db-upgrade failed, expected exit code: %d, actual: %d" # 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 "16.0" "${version}" 'Expected kea-admin to return %s, returned value was %s' + assert_str_eq "17.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 @@ -1403,7 +1403,7 @@ pgsql_lease_stat_upgrade_test() { insert into lease6 (address, lease_type, subnet_id, state) values (666,1,40,2);" run_statement "insert v6 leases" "$qry" - # Ok, we have a 2.0 database with leases. Let's upgrade it to latest version. + # Let's upgrade it to the latest version. run_command \ "${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}" @@ -1648,7 +1648,7 @@ pgsql_unused_subnet_id_test() { run_statement "insert options" "$qry" - # Ok, we have a 4.0 database with hosts and options. Let's upgrade it to latest version. + # Let's upgrade it to the latest version. run_command \ "${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}" @@ -1718,7 +1718,7 @@ pgsql_update_empty_duid_test() { run_statement "insert v6 leases" "$qry" - # Ok, we have a 14.0 database with leases. Let's upgrade it to latest version. + # Let's upgrade it to the latest version. run_command \ "${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}" diff --git a/src/bin/dhcp4/client_handler.cc b/src/bin/dhcp4/client_handler.cc index b45e9a8cc1..6190cd5de9 100644 --- a/src/bin/dhcp4/client_handler.cc +++ b/src/bin/dhcp4/client_handler.cc @@ -50,7 +50,7 @@ ClientHandler::ClientPtr ClientHandler::lookup(const ClientIdPtr& client_id) { // Sanity check. if (!client_id) { - isc_throw(InvalidParameter, "null duid in ClientHandler::lookup"); + isc_throw(InvalidParameter, "null client-id in ClientHandler::lookup"); } auto it = clients_client_id_.find(client_id->getClientId()); diff --git a/src/bin/dhcp4/tests/decline_unittest.cc b/src/bin/dhcp4/tests/decline_unittest.cc index b34d6e007b..458458d7ca 100644 --- a/src/bin/dhcp4/tests/decline_unittest.cc +++ b/src/bin/dhcp4/tests/decline_unittest.cc @@ -190,7 +190,7 @@ Dhcpv4SrvTest::acquireAndDecline(Dhcp4Client& client, // We check if the decline process was successful by checking if the // lease is in the database and what is its state. if (expected_result == SHOULD_PASS) { - EXPECT_EQ(Lease::STATE_DECLINED, lease->state_); + ASSERT_EQ(Lease::STATE_DECLINED, lease->state_); ASSERT_TRUE(lease->hwaddr_); ASSERT_TRUE(lease->hwaddr_->hwaddr_.empty()); @@ -201,12 +201,11 @@ Dhcpv4SrvTest::acquireAndDecline(Dhcp4Client& client, // The decline succeeded, so the declined-addresses statistic should // be increased by one - EXPECT_EQ(after, before + 1); - - EXPECT_EQ(after_global, before_global + 1); + ASSERT_EQ(after, before + 1); + ASSERT_EQ(after_global, before_global + 1); } else { // the decline was supposed, to be rejected. - EXPECT_EQ(Lease::STATE_DEFAULT, lease->state_); + ASSERT_EQ(Lease::STATE_DEFAULT, lease->state_); ASSERT_TRUE(lease->hwaddr_); ASSERT_FALSE(lease->hwaddr_->hwaddr_.empty()); @@ -216,8 +215,8 @@ Dhcpv4SrvTest::acquireAndDecline(Dhcp4Client& client, // The decline failed, so the declined-addresses should be the same // as before - EXPECT_EQ(before, after); - EXPECT_EQ(before_global, after_global); + ASSERT_EQ(before, after); + ASSERT_EQ(before_global, after_global); } } diff --git a/src/bin/dhcp6/tests/decline_unittest.cc b/src/bin/dhcp6/tests/decline_unittest.cc index 375053eab8..509c5e8d22 100644 --- a/src/bin/dhcp6/tests/decline_unittest.cc +++ b/src/bin/dhcp6/tests/decline_unittest.cc @@ -209,7 +209,7 @@ Dhcpv6SrvTest::acquireAndDecline(Dhcp6Client& client, // We check if the decline process was successful by checking if the // lease is in the database and what is its state. if (expected_result == SHOULD_PASS) { - EXPECT_EQ(Lease::STATE_DECLINED, lease->state_); + ASSERT_EQ(Lease::STATE_DECLINED, lease->state_); ASSERT_FALSE(lease->hwaddr_); ASSERT_TRUE(lease->duid_); @@ -221,11 +221,11 @@ Dhcpv6SrvTest::acquireAndDecline(Dhcp6Client& client, // The decline succeeded, so the declined-addresses statistic should // be increased by one - EXPECT_EQ(after, before + 1); - EXPECT_EQ(after_global, before_global + 1); + ASSERT_EQ(after, before + 1); + ASSERT_EQ(after_global, before_global + 1); } else { // the decline was supposed, to be rejected. - EXPECT_EQ(Lease::STATE_DEFAULT, lease->state_); + ASSERT_EQ(Lease::STATE_DEFAULT, lease->state_); ASSERT_TRUE(lease->hwaddr_); ASSERT_TRUE(lease->duid_); @@ -236,8 +236,8 @@ Dhcpv6SrvTest::acquireAndDecline(Dhcp6Client& client, // The decline failed, so the declined-addresses should be the same // as before - EXPECT_EQ(before, after); - EXPECT_EQ(before_global, after_global); + ASSERT_EQ(before, after); + ASSERT_EQ(before_global, after_global); } } diff --git a/src/lib/dhcp/duid.h b/src/lib/dhcp/duid.h index b61b22aae1..9c3be8a279 100644 --- a/src/lib/dhcp/duid.h +++ b/src/lib/dhcp/duid.h @@ -139,11 +139,13 @@ class DUID : public IdentifierType<3, 130> { public: /// @brief minimum duid size - /// The minimal DUID size specified in RFC 8415 is 1. + /// The minimal DUID size specified in RFC 8415, section 11.1 is 3: + /// 2 fixed octets for the type + 1 minimum octet for the value. static constexpr size_t MIN_DUID_LEN = IdentifierType::getMinSize(); /// @brief maximum duid size - /// As defined in RFC 8415, section 11.1 + /// The maximum DUID size specified in RFC 8415, section 11.1 is 130: + /// 2 fixed octets for the type + 128 maximum octets for the value. static constexpr size_t MAX_DUID_LEN = IdentifierType::getMaxSize(); /// @brief specifies DUID type diff --git a/src/lib/dhcp/pkt4.cc b/src/lib/dhcp/pkt4.cc index 7f630f2a29..f6947da40d 100644 --- a/src/lib/dhcp/pkt4.cc +++ b/src/lib/dhcp/pkt4.cc @@ -477,8 +477,8 @@ Pkt4::setHWAddrMember(const uint8_t htype, const uint8_t hlen, /// @todo Rewrite this once support for client-identifier option /// is implemented (ticket 1228?) if (hlen > MAX_CHADDR_LEN) { - isc_throw(OutOfRange, "Hardware address (len=" << hlen - << " too long. Max " << MAX_CHADDR_LEN << " supported."); + isc_throw(OutOfRange, "Hardware address (len=" << static_cast(hlen) + << ") too long. Max " << MAX_CHADDR_LEN << " supported."); } else if (mac_addr.empty() && (hlen > 0) ) { isc_throw(OutOfRange, "Invalid HW Address specified"); diff --git a/src/lib/dhcp_ddns/tests/ncr_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_unittests.cc index 08aacbfb77..5f6dcfb10a 100644 --- a/src/lib/dhcp_ddns/tests/ncr_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_unittests.cc @@ -388,7 +388,7 @@ TEST_F(DhcidTest, fromMinDUID) { // Create DUID. std::vector duid_data(DUID::MIN_DUID_LEN, 1); - DUID duid(&duid_data[0], duid_data.size()); + DUID duid(duid_data.data(), duid_data.size()); // Create DHCID. ASSERT_NO_THROW(dhcid.fromDUID(duid, wire_fqdn_)); diff --git a/src/lib/mysql/mysql_constants.h b/src/lib/mysql/mysql_constants.h index 58160bdbdd..26a3557bce 100644 --- a/src/lib/mysql/mysql_constants.h +++ b/src/lib/mysql/mysql_constants.h @@ -52,7 +52,7 @@ const int MLM_MYSQL_FETCH_FAILURE = 0; /// @name Current database schema version values. //@{ -const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 17; +const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 18; const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0; //@} diff --git a/src/lib/pgsql/pgsql_connection.h b/src/lib/pgsql/pgsql_connection.h index 51fa34c282..7d1e5c4505 100644 --- a/src/lib/pgsql/pgsql_connection.h +++ b/src/lib/pgsql/pgsql_connection.h @@ -18,7 +18,7 @@ namespace isc { namespace db { /// @brief Define the PostgreSQL backend version. -const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 16; +const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 17; const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 0; // Maximum number of parameters that can be used a statement diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index 442c4a8fd8..09876c443c 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -145,7 +145,7 @@ INSERT INTO lease_hwaddr_source VALUES (32, 'HWADDR_SOURCE_SUBSCRIBER_ID'); # Hardware address extracted from docsis options INSERT INTO lease_hwaddr_source VALUES (64, 'HWADDR_SOURCE_DOCSIS'); -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '2', minor = '0'; @@ -235,7 +235,7 @@ END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '3', minor = '0'; @@ -379,7 +379,7 @@ ORDER BY l.address; END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '4', minor = '0'; @@ -391,13 +391,13 @@ UPDATE schema_version # foreign key constraint between lease6 and lease_hardware_source INSERT INTO lease_hwaddr_source VALUES (0, 'HWADDR_SOURCE_UNKNOWN'); -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '4', minor = '1'; # This line concludes the schema upgrade to version 4.1. -# This line starts the schema upgrade to version 5. +# This line starts the schema upgrade to version 5.0. # Update index used for searching DHCPv4 reservations by identifier and subnet id. # This index is now unique (to prevent duplicates) and includes DHCPv4 subnet @@ -484,7 +484,7 @@ ALTER TABLE hosts ADD COLUMN dhcp4_next_server INT UNSIGNED NULL; ALTER TABLE hosts ADD COLUMN dhcp4_server_hostname VARCHAR(64) NULL; ALTER TABLE hosts ADD COLUMN dhcp4_boot_file_name VARCHAR(128) NULL; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '5', minor = '0'; @@ -510,7 +510,7 @@ END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '5', minor = '1'; @@ -522,7 +522,7 @@ UPDATE schema_version ALTER TABLE dhcp4_options MODIFY dhcp4_subnet_id INT UNSIGNED; ALTER TABLE dhcp6_options MODIFY dhcp6_subnet_id INT UNSIGNED; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '5', minor = '2'; @@ -688,7 +688,7 @@ CREATE TRIGGER stat_lease6_delete AFTER DELETE ON lease6 END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '6', minor = '0'; @@ -1342,7 +1342,7 @@ END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '7', minor = '0'; @@ -2301,7 +2301,7 @@ CREATE TRIGGER dhcp6_options_ADEL AFTER DELETE ON dhcp6_options END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '8', minor = '0'; @@ -2388,7 +2388,7 @@ DELIMITER ; ALTER TABLE hosts MODIFY COLUMN auth_key VARCHAR(32) NULL; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '8', minor = '1'; @@ -2793,7 +2793,7 @@ CREATE TRIGGER dhcp6_options_ADEL AFTER DELETE ON dhcp6_options END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '8', minor = '2'; @@ -2810,7 +2810,7 @@ CREATE INDEX lease4_by_hostname ON lease4 (hostname); # Create hostname index for lease6 CREATE INDEX lease6_by_hostname ON lease6 (hostname); -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '9', minor = '0'; @@ -2851,7 +2851,7 @@ ALTER TABLE dhcp6_subnet ADD COLUMN ddns_generated_prefix VARCHAR(255) DEFAULT NULL, ADD COLUMN ddns_qualifying_suffix VARCHAR(255) DEFAULT NULL; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '9', minor = '1'; @@ -2896,7 +2896,7 @@ ALTER TABLE dhcp6_options ADD CONSTRAINT fk_dhcp6_options_pd_pool REFERENCES dhcp6_pd_pool(id) ON DELETE CASCADE ON UPDATE CASCADE; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '9', minor = '2'; @@ -3000,7 +3000,7 @@ CREATE TRIGGER stat_lease6_delete AFTER DELETE ON lease6 END $$ DELIMITER ; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '9', minor = '3'; @@ -3048,7 +3048,7 @@ ALTER TABLE dhcp6_options ADD CONSTRAINT fk_dhcp6_options_Host REFERENCES hosts(host_id) ON DELETE CASCADE ON UPDATE CASCADE; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '9', minor = '4'; @@ -3083,7 +3083,7 @@ ALTER TABLE dhcp4_shared_network DROP COLUMN reservation_mode; ALTER TABLE dhcp6_subnet DROP COLUMN reservation_mode; ALTER TABLE dhcp6_shared_network DROP COLUMN reservation_mode; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '9', minor = '5'; @@ -3112,13 +3112,13 @@ ALTER TABLE dhcp6_shared_network ALTER TABLE logs ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '9', minor = '6'; # This line concludes the schema upgrade to version 9.6. -# This line starts the schema upgrade to version 10. +# This line starts the schema upgrade to version 10.0. -- ----------------------------------------------------------------------- -- Create a table holding the DHCPv4 client classes. Most table @@ -4043,13 +4043,13 @@ ALTER TABLE dhcp6_option_def ON DELETE CASCADE ON UPDATE CASCADE; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '10', minor = '0'; -# This line concludes the schema upgrade to version 10. +# This line concludes the schema upgrade to version 10.0. -# This line starts the schema upgrade to version 11. +# This line starts the schema upgrade to version 11.0. # Reverse index order to improve reclamation query performance # Add a constraint that any state value added to the lease4 must @@ -4075,13 +4075,13 @@ ALTER TABLE dhcp6_client_class ADD COLUMN min_preferred_lifetime INT(10) DEFAULT NULL, ADD COLUMN max_preferred_lifetime INT(10) DEFAULT NULL; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '11', minor = '0'; -# This line concludes the schema upgrade to version 11. +# This line concludes the schema upgrade to version 11.0. -# This line starts the schema upgrade to version 12. +# This line starts the schema upgrade to version 12.0. # Ensure that dhcp_client_class is NULL when an option does not # belong to any client class. Later, we will add foreign keys for @@ -4109,13 +4109,13 @@ ALTER TABLE dhcp6_options REFERENCES dhcp6_client_class (name) ON DELETE CASCADE ON UPDATE CASCADE; -# Update the schema version number +# Update the schema version number. UPDATE schema_version SET version = '12', minor = '0'; --- This line concludes the schema upgrade to version 12. +-- This line concludes the schema upgrade to version 12.0. --- This line starts the schema upgrade to version 13. +-- This line starts the schema upgrade to version 13.0. -- Create a function that separates a contiguous hexadecimal string -- into groups of two hexadecimals separated by colons. @@ -4325,9 +4325,9 @@ DELIMITER ; UPDATE schema_version SET version = '13', minor = '0'; --- This line concludes the schema upgrade to version 13. +-- This line concludes the schema upgrade to version 13.0. --- This line starts the schema upgrade to version 14. +-- This line starts the schema upgrade to version 14.0. -- Modify shared-network-name foreign key constraint on dhcp4_subnet to not perform -- the update when the network is deleted the cascaded update will not execute @@ -5097,9 +5097,9 @@ DELIMITER ; UPDATE schema_version SET version = '14', minor = '0'; --- This line concludes the schema upgrade to version 14. +-- This line concludes the schema upgrade to version 14.0. --- This line starts the schema upgrade to version 15. +-- This line starts the schema upgrade to version 15.0. -- Add cancelled (aka never-send) column to option tables. ALTER TABLE dhcp4_options @@ -5122,9 +5122,9 @@ ALTER TABLE dhcp4_client_class UPDATE schema_version SET version = '15', minor = '0'; --- This line concludes the schema upgrade to version 15. +-- This line concludes the schema upgrade to version 15.0. --- This line starts the schema upgrade to version 16. +-- This line starts the schema upgrade to version 16.0. -- Add relay and remote id columns to DHCPv4 leases. -- @@ -5142,9 +5142,9 @@ CREATE INDEX lease4_by_remote_id ON lease4 (remote_id); UPDATE schema_version SET version = '16', minor = '0'; --- This line concludes the schema upgrade to version 16. +-- This line concludes the schema upgrade to version 16.0. --- This line starts the schema upgrade to version 17. +-- This line starts the schema upgrade to version 17.0. -- Add the allocator column to the DHCPv4 tables. ALTER TABLE dhcp4_subnet ADD COLUMN allocator TEXT NULL; @@ -5162,9 +5162,9 @@ ALTER TABLE dhcp6_shared_network ADD COLUMN pd_allocator TEXT NULL; UPDATE schema_version SET version = '17', minor = '0'; --- This line concludes the schema upgrade to version 17. +-- This line concludes the schema upgrade to version 17.0. --- This line starts the schema upgrade to version 18. +-- This line starts the schema upgrade to version 18.0. -- Extend lease4 client_id to 255 bytes. ALTER TABLE lease4 @@ -5304,7 +5304,7 @@ DELIMITER ; UPDATE schema_version SET version = '18', minor = '0'; --- This line concludes the schema upgrade to version 18. +-- This line concludes the schema upgrade to version 18.0. # Notes: # diff --git a/src/share/database/scripts/mysql/upgrade_001.0_to_002.0.sh.in b/src/share/database/scripts/mysql/upgrade_001.0_to_002.0.sh.in index a8d36ea614..208afbce12 100644 --- a/src/share/database/scripts/mysql/upgrade_001.0_to_002.0.sh.in +++ b/src/share/database/scripts/mysql/upgrade_001.0_to_002.0.sh.in @@ -34,6 +34,8 @@ if [ "$VERSION" != "1.0" ]; then fi mysql "$@" < 0); --- Set 3.2 schema version. +-- Update the schema version number. UPDATE schema_version SET version = '3', minor = '2'; --- Schema 3.2 specification ends here. +-- This line concludes the schema upgrade to version 3.2. --- Upgrade to schema 3.3 begins here: +-- This line starts the schema upgrade to version 3.3. -- Change subnet ID columns type to BIGINT to match lease4/6 tables ALTER TABLE hosts ALTER COLUMN dhcp4_subnet_id TYPE BIGINT; @@ -540,13 +540,13 @@ ALTER TABLE hosts ALTER COLUMN dhcp6_subnet_id TYPE BIGINT; ALTER TABLE dhcp4_options ALTER COLUMN dhcp4_subnet_id TYPE BIGINT; ALTER TABLE dhcp6_options ALTER COLUMN dhcp6_subnet_id TYPE BIGINT; --- Set 3.3 schema version. +-- Update the schema version number. UPDATE schema_version SET version = '3', minor = '3'; --- Schema 3.3 specification ends here. +-- This line concludes the schema upgrade to version 3.3. --- Upgrade to schema 4.0 begins here: +-- This line starts the schema upgrade to version 4.0. -- Add a column holding hosts for user context. ALTER TABLE hosts ADD COLUMN user_context TEXT; @@ -745,13 +745,13 @@ CREATE TRIGGER stat_lease6_delete AFTER DELETE ON lease6 FOR EACH ROW EXECUTE PROCEDURE proc_stat_lease6_delete(); --- Set 4.0 schema version. +-- Update the schema version number. UPDATE schema_version SET version = '4', minor = '0'; --- Schema 4.0 specification ends here. +-- This line concludes the schema upgrade to version 4.0. --- Upgrade to schema 5.0 begins here: +-- This line starts the schema upgrade to version 5.0. -- Add a column holding leases for user context. ALTER TABLE lease4 ADD COLUMN user_context TEXT; @@ -867,24 +867,24 @@ CREATE INDEX address_id ON logs (address); -- Create auth_key in hosts table for storing keys for DHCPv6 reconfigure. ALTER TABLE hosts ADD COLUMN auth_key VARCHAR(16) DEFAULT NULL; --- Set schema 5.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '5', minor = '0'; --- Schema 5.0 specification ends here. +-- This line concludes the schema upgrade to version 5.0. --- Upgrade to schema 5.1 begins here: +-- This line starts the schema upgrade to version 5.1. -- Put the auth key in hexadecimal (double size but far more user friendly). ALTER TABLE hosts ALTER COLUMN auth_key TYPE VARCHAR(32); --- Set schema 5.1 version. +-- Update the schema version number. UPDATE schema_version SET version = '5', minor = '1'; --- Schema 5.1 specification ends here. +-- This line concludes the schema upgrade to version 5.1. --- Upgrade to schema 6.0 begins here: +-- This line starts the schema upgrade to version 6.0. -- Create a lower case hostname index for hosts. CREATE INDEX hosts_by_hostname ON hosts (lower(hostname)) @@ -898,13 +898,13 @@ WHERE hostname IS NOT NULL; CREATE INDEX lease6_by_hostname ON lease6 (lower(hostname)) WHERE hostname IS NOT NULL; --- Set 6.0 schema version. +-- Update the schema version number. UPDATE schema_version SET version = '6', minor = '0'; --- Schema 6.0 specification ends here. +-- This line concludes the schema upgrade to version 6.0. --- Upgrade to schema 6.1 begins here: +-- This line starts the schema upgrade to version 6.1. -- Fix v4 update trigger procedure CREATE OR REPLACE FUNCTION proc_stat_lease4_update() RETURNS trigger AS $stat_lease4_update$ @@ -996,13 +996,13 @@ BEGIN END; $stat_lease6_delete$ LANGUAGE plpgsql; --- Set 6.1 schema version. +-- Update the schema version number. UPDATE schema_version SET version = '6', minor = '1'; --- Schema 6.1 specification ends here. +-- This line concludes the schema upgrade to version 6.1. --- Upgrade to schema 6.2 begins here: +-- This line starts the schema upgrade to version 6.2. -- Starting from this version we allow specifying multiple IP reservations -- for the same address in certain DHCP configurations. The server may check @@ -1022,13 +1022,13 @@ ALTER TABLE ipv6_reservations DROP CONSTRAINT IF EXISTS key_dhcp6_address_prefix CREATE INDEX key_dhcp6_address_prefix_len ON ipv6_reservations (address ASC, prefix_len ASC); --- Set schema 6.2 version. +-- Update the schema version number. UPDATE schema_version SET version = '6', minor = '2'; --- Schema 6.2 specification ends here. +-- This line concludes the schema upgrade to version 6.2. --- Upgrade to schema 7.0 begins here: +-- This line starts the schema upgrade to version 7.0. -- Add a lot (20+) of tables for the config backend. @@ -3726,13 +3726,13 @@ END; $dhcp6_pd_pool_BDEL$ LANGUAGE plpgsql; --- Set schema 7.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '7', minor = '0'; --- Schema 7.0 specification ends here. +-- This line concludes the schema upgrade to version 7.0. --- Upgrade to schema 8.0 begins here: +-- This line starts the schema upgrade to version 8.0. -- Add a few missing elements for CB and functions for kea-admin's lease-dump -- and lease-upload commands. @@ -4201,13 +4201,13 @@ BEGIN END $$ LANGUAGE plpgsql; --- Set schema 8.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '8', minor = '0'; --- Schema 8.0 specification ends here. +-- This line concludes the schema upgrade to version 8.0. --- Upgrade to schema 9.0 begins here: +-- This line starts the schema upgrade to version 9.0. -- Add missing cascade to constraint on dhcp4/6_subnet_server tables. ALTER TABLE dhcp4_subnet_server @@ -4453,13 +4453,13 @@ BEGIN END;$$ LANGUAGE plpgsql; --- Set schema 9.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '9', minor = '0'; --- Schema 9.0 specification ends here. +-- This line concludes the schema upgrade to version 9.0. --- Upgrade to schema 10.0 begins here: +-- This line starts the schema upgrade to version 10.0. -- It adds corrections for client classes for CB @@ -4749,13 +4749,13 @@ END; $dhcp6_client_class_check_dependency_BINS$ LANGUAGE plpgsql; --- Set schema 10.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '10', minor = '0'; --- Schema 10.0 specification ends here. +-- This line concludes the schema upgrade to version 10.0. --- Upgrade to schema 11.0 begins here: +-- This line starts the schema upgrade to version 11.0. -- Replace createOptionAuditDHCP6() with a version corrected -- where clause when scope is 6 (i.e. PD pool) @@ -4861,13 +4861,13 @@ BEGIN RETURN; END;$$; --- Set schema 11.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '11', minor = '0'; --- Schema 11.0 specification ends here. +-- This line concludes the schema upgrade to version 11.0. --- Upgrade to schema 12.0 begins here: +-- This line starts the schema upgrade to version 12.0. -- Modify shared-network-name foreign key constraint on dhcp4_subnet to not perform -- the update when the network is deleted the cascaded update will not execute @@ -4925,13 +4925,13 @@ LANGUAGE plpgsql; ALTER TABLE dhcp4_client_class ADD COLUMN user_context JSON DEFAULT NULL; ALTER TABLE dhcp6_client_class ADD COLUMN user_context JSON DEFAULT NULL; --- Set schema 12.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '12', minor = '0'; --- Schema 12.0 specification ends here. +-- This line concludes the schema upgrade to version 12.0. --- Upgrade to schema 13.0 begins here: +-- This line starts the schema upgrade to version 13.0. -- JSON functions -- @@ -5564,13 +5564,13 @@ CREATE UNIQUE INDEX key_dhcp6_identifier_subnet_id ON hosts (dhcp_identifier ASC, dhcp_identifier_type ASC, dhcp6_subnet_id ASC) WHERE (dhcp6_subnet_id IS NOT NULL); --- Set schema 13.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '13', minor = '0'; --- Schema 13.0 specification ends here. +-- This line concludes the schema upgrade to version 13.0. --- Upgrade to schema 14.0 begins here: +-- This line starts the schema upgrade to version 14.0. -- Add cancelled (aka never-send) column to option tables. @@ -5587,13 +5587,13 @@ ALTER TABLE dhcp4_subnet ALTER TABLE dhcp4_client_class ADD COLUMN offer_lifetime BIGINT DEFAULT NULL; --- Set schema 14.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '14', minor = '0'; --- Schema 14.0 specification ends here. +-- This line concludes the schema upgrade to version 14.0. --- Upgrade to schema 15.0 begins here: +-- This line starts the schema upgrade to version 15.0. -- Add relay and remote id columns to DHCPv4 leases. -- @@ -5607,23 +5607,13 @@ ALTER TABLE lease4 CREATE INDEX lease4_by_relay_id ON lease4 (relay_id); CREATE INDEX lease4_by_remote_id ON lease4 (remote_id); --- Set schema 15.0 version. +-- Update the schema version number. UPDATE schema_version SET version = '15', minor = '0'; --- Schema 15.0 specification ends here. +-- This line concludes the schema upgrade to version 15.0. --- Upgrade to schema 16.0 begins here: - -UPDATE lease6 SET duid = E'\\x000000' WHERE duid = E'\\x00'; - --- Set 16.0 schema version. -UPDATE schema_version - SET version = '16', minor = '0'; - --- Schema 16.0 specification ends here. - --- Upgrade to schema 16.0 begins here: +-- This line starts the schema upgrade to version 16.0. -- Add the allocator column to the DHCPv4 tables. ALTER TABLE dhcp4_subnet ADD COLUMN allocator TEXT DEFAULT NULL; @@ -5637,11 +5627,21 @@ ALTER TABLE dhcp6_subnet ADD COLUMN pd_allocator TEXT DEFAULT NULL; ALTER TABLE dhcp6_shared_network ADD COLUMN allocator TEXT DEFAULT NULL; ALTER TABLE dhcp6_shared_network ADD COLUMN pd_allocator TEXT DEFAULT NULL; --- Set 17.0 schema version. +-- Update the schema version number. +UPDATE schema_version + SET version = '16', minor = '0'; + +-- This line concludes the schema upgrade to version 16.0. + +-- This line starts the schema upgrade to version 17.0. + +UPDATE lease6 SET duid = E'\\x000000' WHERE duid = E'\\x00'; + +-- Update the schema version number. UPDATE schema_version SET version = '17', minor = '0'; --- Schema 17.0 specification ends here. +-- This line concludes the schema upgrade to version 17.0. -- Commit the script transaction. COMMIT; diff --git a/src/share/database/scripts/pgsql/upgrade_001.0_to_002.0.sh.in b/src/share/database/scripts/pgsql/upgrade_001.0_to_002.0.sh.in index e5348b6ca9..b92e7716b2 100644 --- a/src/share/database/scripts/pgsql/upgrade_001.0_to_002.0.sh.in +++ b/src/share/database/scripts/pgsql/upgrade_001.0_to_002.0.sh.in @@ -35,7 +35,7 @@ fi psql "$@" >/dev/null </dev/null </dev/null < 3.0 upgrade script. However, it was present in the @@ -53,13 +53,13 @@ INSERT INTO host_identifier_type (type, name) -- We also add a new identifier type: flex-id. INSERT INTO host_identifier_type VALUES (4, 'flex-id'); --- Set 3.1 schema version. +-- Update the schema version number. UPDATE schema_version SET version = '3', minor = '1'; --- Schema 3.1 specification ends here. +-- This line concludes the schema upgrade to version 3.1. --- Commit the script transaction +-- Commit the script transaction. COMMIT; EOF diff --git a/src/share/database/scripts/pgsql/upgrade_003.1_to_003.2.sh.in b/src/share/database/scripts/pgsql/upgrade_003.1_to_003.2.sh.in index 757e90c251..51eecee2ac 100644 --- a/src/share/database/scripts/pgsql/upgrade_003.1_to_003.2.sh.in +++ b/src/share/database/scripts/pgsql/upgrade_003.1_to_003.2.sh.in @@ -37,7 +37,7 @@ psql "$@" >/dev/null < 0); --- Set 3.2 schema version. +-- Update the schema version number. UPDATE schema_version SET version = '3', minor = '2'; --- Schema 3.2 specification ends here. +-- This line concludes the schema upgrade to version 3.2. --- Commit the script transaction +-- Commit the script transaction. COMMIT; EOF diff --git a/src/share/database/scripts/pgsql/upgrade_003.2_to_003.3.sh.in b/src/share/database/scripts/pgsql/upgrade_003.2_to_003.3.sh.in index c6d7b16c10..95aca7c42b 100644 --- a/src/share/database/scripts/pgsql/upgrade_003.2_to_003.3.sh.in +++ b/src/share/database/scripts/pgsql/upgrade_003.2_to_003.3.sh.in @@ -37,7 +37,7 @@ psql "$@" >/dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null </dev/null <