Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/util/upgrade_checker/upgrade_check_creators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ std::unique_ptr<Sql_upgrade_check> get_old_temporal_check() {
std::unique_ptr<Sql_upgrade_check> get_reserved_keywords_check(
const Upgrade_info &info) {
std::string keywords;
const auto add_keywords = [&keywords, &info](const char *v, const char *kws) {
const auto add_keywords = [&keywords, &info](const char *v, const char *kws,
const char *max_v = nullptr) {
Version kv(v);
if (info.server_version < kv && info.target_version >= kv) {
if (info.server_version < kv && info.target_version >= kv &&
(max_v == nullptr || info.target_version < Version(max_v))) {
if (!keywords.empty()) keywords += ", ";
keywords += kws;
}
Expand All @@ -83,6 +85,10 @@ std::unique_ptr<Sql_upgrade_check> get_reserved_keywords_check(

add_keywords("8.0.17", "'ARRAY' ,'MEMBER'");
add_keywords("8.0.31", "'FULL', 'INTERSECT'");
add_keywords("8.4.0", "'QUALIFY', 'TABLESAMPLE'");
add_keywords("8.4.0", "'MANUAL', 'PARALLEL'", "8.4.11");
add_keywords("9.2.0", "'LIBRARY'");
add_keywords("9.4.0", "'EXTERNAL'");

keywords = "(" + keywords + ");";
return std::make_unique<Sql_upgrade_check>(
Expand Down
3 changes: 2 additions & 1 deletion modules/util/upgrade_checker/upgrade_check_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ namespace {
[[maybe_unused]] bool register_reserved =
Upgrade_check_registry::register_check(&get_reserved_keywords_check,
Target::OBJECT_DEFINITIONS, "8.0.11",
"8.0.14", "8.0.17", "8.0.31");
"8.0.14", "8.0.17", "8.0.31", "8.4.0",
"9.2.0", "9.4.0");

[[maybe_unused]] bool register_utf8mb3 = Upgrade_check_registry::register_check(
std::bind(&get_utf8mb3_check), Target::OBJECT_DEFINITIONS, "8.0.11");
Expand Down
61 changes: 61 additions & 0 deletions unittest/modules/util/upgrade_checker/upgrade_check_creators_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,66 @@ TEST(Upgrade_check_creators,
}
}

TEST(Upgrade_check_creators, get_reserved_keywords_check_test) {
// Every per-object-type query produced by the reserved keywords check embeds
// the same keyword IN-list, so inspecting the first query is enough to verify
// which keywords are included for a given source -> target version pair.
const auto keyword_list = [](const Version &server, const Version &target) {
const auto info = upgrade_info(server, target);
const auto check = get_reserved_keywords_check(info);
return check->get_queries().front().first;
};
const auto has = [](const std::string &query, const char *keyword) {
return query.find(keyword) != std::string::npos;
};

// 8.0 -> 8.4.8: QUALIFY/TABLESAMPLE plus MANUAL/PARALLEL, which are still
// reserved below 8.4.11. LIBRARY/EXTERNAL do not apply yet (target < 9.x).
{
const auto query = keyword_list(Version(8, 0, 0), Version(8, 4, 8));
EXPECT_TRUE(has(query, "'QUALIFY'"));
EXPECT_TRUE(has(query, "'TABLESAMPLE'"));
EXPECT_TRUE(has(query, "'MANUAL'"));
EXPECT_TRUE(has(query, "'PARALLEL'"));
EXPECT_FALSE(has(query, "'LIBRARY'"));
EXPECT_FALSE(has(query, "'EXTERNAL'"));
}

// 8.0 -> 8.4.11: MANUAL/PARALLEL became nonreserved in 8.4.11 and must drop
// out (upper bound of the ranged add_keywords call); QUALIFY/TABLESAMPLE stay.
{
const auto query = keyword_list(Version(8, 0, 0), Version(8, 4, 11));
EXPECT_TRUE(has(query, "'QUALIFY'"));
EXPECT_TRUE(has(query, "'TABLESAMPLE'"));
EXPECT_FALSE(has(query, "'MANUAL'"));
EXPECT_FALSE(has(query, "'PARALLEL'"));
}

// 8.4.0 -> 9.2.0: LIBRARY (reserved since 9.2.0) applies; EXTERNAL (9.4.0)
// does not. The 8.4.0 words are not re-reported since the source is 8.4.0.
{
const auto query = keyword_list(Version(8, 4, 0), Version(9, 2, 0));
EXPECT_TRUE(has(query, "'LIBRARY'"));
EXPECT_FALSE(has(query, "'EXTERNAL'"));
EXPECT_FALSE(has(query, "'QUALIFY'"));
EXPECT_FALSE(has(query, "'MANUAL'"));
}

// 8.4.0 -> 9.4.0: both LIBRARY (9.2.0) and EXTERNAL (9.4.0) apply.
{
const auto query = keyword_list(Version(8, 4, 0), Version(9, 4, 0));
EXPECT_TRUE(has(query, "'LIBRARY'"));
EXPECT_TRUE(has(query, "'EXTERNAL'"));
}

// 9.2.0 -> 9.4.0: LIBRARY is already reserved on the source, so only EXTERNAL
// is newly reserved on the target.
{
const auto query = keyword_list(Version(9, 2, 0), Version(9, 4, 0));
EXPECT_TRUE(has(query, "'EXTERNAL'"));
EXPECT_FALSE(has(query, "'LIBRARY'"));
}
}

} // namespace upgrade_checker
} // namespace mysqlsh
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,20 @@ TEST(Upgrade_check_registry, create_checklist) {
{{v5_7_0, Version(8, 0, 11)},
{Version(8, 0, 11), Version(8, 0, 14)},
{Version(8, 0, 14), Version(8, 0, 17)},
{Version(8, 0, 17), Version(8, 0, 31)}});
{Version(8, 0, 17), Version(8, 0, 31)},
{Version(8, 0, 31), Version(8, 4, 0)},
{Version(8, 4, 0), Version(9, 2, 0)},
{Version(9, 2, 0), Version(9, 4, 0)},
{Version(8, 0, 31), vShell}});

test_check_availability(ids::k_reserved_keywords_check, false,
{{v5_7_0, Version(8, 0, 10)},
{Version(8, 0, 11), Version(8, 0, 13)},
{Version(8, 0, 14), Version(8, 0, 16)},
{Version(8, 0, 17), Version(8, 0, 30)},
{Version(8, 0, 31), vShell}});
{Version(8, 4, 0), Version(8, 4, 11)},
{Version(8, 4, 1), Version(9, 1, 0)},
{Version(9, 4, 0), vShell}});

// syntax_check:
// available: always between series versions
Expand Down