}
mysql_upgrade_23_to_24_test() {
- query="SELECT count(id) from option_def_data_type"
+ query="SELECT COUNT(id) FROM option_def_data_type"
run_command \
mysql_execute "${query}"
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
insert into dhcp6_option_def (code,name,space,type,modification_ts,record_types, is_array, encapsulate)\
values ('224','bar2','dhcp6',18,current_timestamp,'10, 7, 2, 14', false, false);
"
- run_statement "insert otion definitions" "$sql"
+ run_statement "insert option definitions" "$sql"
# Verify the inserted record counts.
qry="select count(*) from dhcp4_option_def;"
mysql_upgrade_schema_to_version 24.0
# Verify the migrated records.
- qry="select type from dhcp4_option_def where name = 'foo';"
+ qry="select type from dhcp4_option_def where name = 'foo';"
run_statement "#get 4_option_def_foo after update" "$qry" 17
- qry="select type from dhcp4_option_def where name = 'bar';"
- run_statement "#get 4_option_def_bar after update" "$qry" 254
+ qry="select type from dhcp4_option_def where name = 'bar';"
+ run_statement "#get 4_option_def_bar after update" "$qry" 254
- qry="select type from dhcp4_option_def where name = 'bar2';"
+ qry="select type from dhcp4_option_def where name = 'bar2';"
run_statement "#get 4_option_def_bar2 after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'foo';"
+ qry="select type from dhcp6_option_def where name = 'foo';"
run_statement "#get 6_option_def_foo after update" "$qry" 17
- qry="select type from dhcp6_option_def where name = 'bar';"
- run_statement "#get 6_option_def_bar after update" "$qry" 254
+ qry="select type from dhcp6_option_def where name = 'bar';"
+ run_statement "#get 6_option_def_bar after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'bar2';"
+ qry="select type from dhcp6_option_def where name = 'bar2';"
run_statement "#get 6_option_def_bar2 after update" "$qry" 254
# Let's wipe the whole database
}
pgsql_upgrade_23_to_24_test() {
- query="SELECT count(id) from option_def_data_type"
+ query="SELECT COUNT(id) FROM option_def_data_type"
run_command \
pgsql_execute "${query}"
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
insert into dhcp6_option_def (code,name,space,type,modification_ts,record_types, is_array, encapsulate)\
values ('224','bar2','dhcp6',18,current_timestamp,'10, 7, 2, 14', false, false);
"
- run_statement "insert otion definitions" "$sql"
+ run_statement "insert option definitions" "$sql"
# Verify the inserted record counts.
qry="select count(*) from dhcp4_option_def;"
pgsql_upgrade_schema_to_version 24.0
# Verify the migrated records.
- qry="select type from dhcp4_option_def where name = 'foo';"
+ qry="select type from dhcp4_option_def where name = 'foo';"
run_statement "#get 4_option_def_foo after update" "$qry" 17
- qry="select type from dhcp4_option_def where name = 'bar';"
- run_statement "#get 4_option_def_bar after update" "$qry" 254
+ qry="select type from dhcp4_option_def where name = 'bar';"
+ run_statement "#get 4_option_def_bar after update" "$qry" 254
- qry="select type from dhcp4_option_def where name = 'bar2';"
+ qry="select type from dhcp4_option_def where name = 'bar2';"
run_statement "#get 4_option_def_bar2 after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'foo';"
+ qry="select type from dhcp6_option_def where name = 'foo';"
run_statement "#get 6_option_def_foo after update" "$qry" 17
- qry="select type from dhcp6_option_def where name = 'bar';"
- run_statement "#get 6_option_def_bar after update" "$qry" 254
+ qry="select type from dhcp6_option_def where name = 'bar';"
+ run_statement "#get 6_option_def_bar after update" "$qry" 254
- qry="select type from dhcp6_option_def where name = 'bar2';"
+ qry="select type from dhcp6_option_def where name = 'bar2';"
run_statement "#get 6_option_def_bar2 after update" "$qry" 254
# Let's wipe the whole database
GenericConfigBackendDHCPv4Test::invalidOptionDefDataType4Test() {
OptionDefinitionPtr test_def;
ASSERT_NO_THROW_LOG(test_def.reset(new OptionDefinition("foobar", 234, DHCP4_OPTION_SPACE,
- "unknown", true)));
+ "unknown", true)));
ASSERT_TRUE(test_def);
- ASSERT_THROW(cbptr_->createUpdateOptionDef4(ServerSelector::ALL(), test_def),
+ ASSERT_THROW(cbptr_->createUpdateOptionDef4(ServerSelector::ALL(), test_def),
DbOperationError);
}
ASSERT_NO_THROW_LOG(parser.parse(storage, defs_elem));
auto test_defs = storage->getAll("dhcp4");
- ASSERT_EQ(test_defs->size(), 18);
+ ASSERT_EQ(test_defs->size(), 18);
// Insert each option definition into the database.
for (auto const& test_def : *test_defs) {
GenericConfigBackendDHCPv6Test::invalidOptionDefDataType6Test() {
OptionDefinitionPtr test_def;
ASSERT_NO_THROW_LOG(test_def.reset(new OptionDefinition("foobar", 234, DHCP6_OPTION_SPACE,
- "unknown", true)));
+ "unknown", true)));
ASSERT_TRUE(test_def);
- ASSERT_THROW(cbptr_->createUpdateOptionDef6(ServerSelector::ALL(), test_def),
+ ASSERT_THROW(cbptr_->createUpdateOptionDef6(ServerSelector::ALL(), test_def),
DbOperationError);
}
ASSERT_NO_THROW_LOG(parser.parse(storage, defs_elem));
auto test_defs = storage->getAll("dhcp6");
- ASSERT_EQ(test_defs->size(), 18);
+ ASSERT_EQ(test_defs->size(), 18);
// Insert each option definition into the database.
for (auto const& test_def : *test_defs) {
DECLARE skipper TINYINT;
SELECT COUNT(table_name) FROM information_schema.tables
- WHERE table_schema LIKE database() AND table_name = 'option_def_data_type' into skipper;
+ WHERE table_schema LIKE database() AND table_name = 'option_def_data_type' INTO skipper;
IF skipper = 0 THEN
-- First we migrate existing OPT_RECORD_TYPE values
END $$
DELIMITER ;
-call updateOptionDataDef();
+CALL updateOptionDataDef();
-- Get rid of the now obsolete function.
DROP PROCEDURE IF EXISTS updateOptionDataDef;
DECLARE skipper TINYINT;
SELECT COUNT(table_name) FROM information_schema.tables
- WHERE table_schema LIKE database() AND table_name = 'option_def_data_type' into skipper;
+ WHERE table_schema LIKE database() AND table_name = 'option_def_data_type' INTO skipper;
IF skipper = 0 THEN
-- First we migrate existing OPT_RECORD_TYPE values
END $$
DELIMITER ;
-call updateOptionDataDef();
+CALL updateOptionDataDef();
-- Get rid of the now obsolete function.
DROP PROCEDURE IF EXISTS updateOptionDataDef;
UPDATE schema_version
SET version = '23', minor = '0';
+-- This line concludes the schema upgrade to version 23.0.
+
-- This line starts the schema upgrade to version 24.0.
-- Create a function to conditionally migrate option_def data type
CREATE OR REPLACE FUNCTION updateOptionDataDef() RETURNS text AS $$
DECLARE skipper BOOLEAN;
BEGIN
- SELECT exists(SELECT FROM pg_tables WHERE tablename = 'option_def_data_type') into skipper;
+ SELECT exists(SELECT FROM pg_tables WHERE tablename = 'option_def_data_type') INTO skipper;
IF skipper THEN
-- Table already exists which means the migration was already done.
RETURN 'EXISTS';
END;
$$ LANGUAGE plpgsql;
-select updateOptionDataDef();
+SELECT updateOptionDataDef();
-- Get rid of the now obsolete function.
DROP FUNCTION IF EXISTS updateOptionDataDef();
CREATE OR REPLACE FUNCTION updateOptionDataDef() RETURNS text AS \$\$
DECLARE skipper BOOLEAN;
BEGIN
- SELECT exists(SELECT FROM pg_tables WHERE tablename = 'option_def_data_type') into skipper;
+ SELECT exists(SELECT FROM pg_tables WHERE tablename = 'option_def_data_type') INTO skipper;
IF skipper THEN
-- Table already exists which means the migration was already done.
RETURN 'EXISTS';
END;
\$\$ LANGUAGE plpgsql;
-select updateOptionDataDef();
+SELECT updateOptionDataDef();
-- Get rid of the now obsolete function.
DROP FUNCTION IF EXISTS updateOptionDataDef();